Build Fixes and more

This commit is contained in:
shabinder 2021-08-25 21:00:31 +05:30
parent ba9f3a36aa
commit 363f0663c7
10 changed files with 37 additions and 37 deletions

View File

@ -91,8 +91,7 @@ class MainActivity : ComponentActivity() {
private val trackStatusFlow = MutableSharedFlow<HashMap<String, DownloadStatus>>(1) private val trackStatusFlow = MutableSharedFlow<HashMap<String, DownloadStatus>>(1)
private var permissionGranted = mutableStateOf(true) private var permissionGranted = mutableStateOf(true)
private val internetAvailability by lazy { ConnectionLiveData(applicationContext) } private val internetAvailability by lazy { ConnectionLiveData(applicationContext) }
private lateinit var rootComponent: SpotiFlyerRoot
private val rootComponent = spotiFlyerRoot(defaultComponentContext())
// private val visibleChild get(): SpotiFlyerRoot.Child = root.routerState.value.activeChild.instance // private val visibleChild get(): SpotiFlyerRoot.Child = root.routerState.value.activeChild.instance
// Variable for storing instance of our service class // Variable for storing instance of our service class
@ -105,7 +104,7 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
// This app draws behind the system bars, so we want to handle fitting system windows // This app draws behind the system bars, so we want to handle fitting system windows
WindowCompat.setDecorFitsSystemWindows(window, false) WindowCompat.setDecorFitsSystemWindows(window, false)
rootComponent = spotiFlyerRoot(defaultComponentContext())
setContent { setContent {
SpotiFlyerTheme { SpotiFlyerTheme {
Surface(contentColor = colorOffWhite) { Surface(contentColor = colorOffWhite) {

View File

@ -51,15 +51,15 @@ internal class AndroidAnalyticsManager(private val mainActivity: Activity) : Ana
Countly.sharedInstance().consent().removeConsentAll() Countly.sharedInstance().consent().removeConsentAll()
} }
override fun sendView(name: String, extras: Map<String, Any>) { override fun sendView(name: String, extras: MutableMap<String, Any>) {
Countly.sharedInstance().views().recordView(name, extras) Countly.sharedInstance().views().recordView(name, extras)
} }
override fun sendEvent(eventName: String, extras: Map<String, Any>) { override fun sendEvent(eventName: String, extras: MutableMap<String, Any>) {
Countly.sharedInstance().events().recordEvent(eventName, extras) Countly.sharedInstance().events().recordEvent(eventName, extras)
} }
override fun sendCrashReport(error: Throwable, extras: Map<String, Any>) { override fun sendCrashReport(error: Throwable, extras: MutableMap<String, Any>) {
Countly.sharedInstance().crashes().recordUnhandledException(error, extras) Countly.sharedInstance().crashes().recordUnhandledException(error, extras)
} }
} }

View File

@ -145,6 +145,7 @@ class AndroidFileManager(
} }
SuspendableEvent.success(trackDetails.outputFilePath) SuspendableEvent.success(trackDetails.outputFilePath)
} catch (e: Throwable) { } catch (e: Throwable) {
e.printStackTrace()
if (songFile.exists()) songFile.delete() if (songFile.exists()) songFile.delete()
logger.e { "${songFile.absolutePath} could not be created" } logger.e { "${songFile.absolutePath} could not be created" }
SuspendableEvent.error(e) SuspendableEvent.error(e)

View File

@ -15,9 +15,9 @@ class AndroidMediaConverter : MediaConverter() {
progressCallbacks: (Long) -> Unit, progressCallbacks: (Long) -> Unit,
) = executeSafelyInPool { ) = executeSafelyInPool {
val kbpsArg = if (audioQuality == AudioQuality.UNKNOWN) "" else "-b:a ${audioQuality.kbps}k" val kbpsArg = if (audioQuality == AudioQuality.UNKNOWN) "" else "-b:a ${audioQuality.kbps}k"
// -acodec libmp3lame
val session = FFmpegKit.execute( val session = FFmpegKit.execute(
"-i $inputFilePath -y $kbpsArg -acodec libmp3lame -vn $outputFilePath" "-i $inputFilePath -y $kbpsArg -vn $outputFilePath"
) )
when (session.returnCode.value) { when (session.returnCode.value) {

View File

@ -9,10 +9,10 @@ interface AnalyticsManager {
fun giveConsent() fun giveConsent()
fun isTracking(): Boolean fun isTracking(): Boolean
fun revokeConsent() fun revokeConsent()
fun sendView(name: String, extras: Map<String, Any> = emptyMap()) fun sendView(name: String, extras: MutableMap<String, Any> = mutableMapOf())
fun sendEvent(eventName: String, extras: Map<String, Any> = emptyMap()) fun sendEvent(eventName: String, extras: MutableMap<String, Any> = mutableMapOf())
fun track(event: AnalyticsAction) = event.track(this) fun track(event: AnalyticsAction) = event.track(this)
fun sendCrashReport(error: Throwable, extras: Map<String, Any> = emptyMap()) fun sendCrashReport(error: Throwable, extras: MutableMap<String, Any> = mutableMapOf())
companion object { companion object {
abstract class AnalyticsAction { abstract class AnalyticsAction {

View File

@ -1,6 +1,6 @@
package com.shabinder.common.core_components.analytics package com.shabinder.common.core_components.analytics
sealed class AnalyticsEvent(private val eventName: String, private val extras: Map<String, Any> = emptyMap()): AnalyticsManager.Companion.AnalyticsAction() { sealed class AnalyticsEvent(private val eventName: String, private val extras: MutableMap<String, Any> = mutableMapOf()): AnalyticsManager.Companion.AnalyticsAction() {
override fun track(analyticsManager: AnalyticsManager) = analyticsManager.sendEvent(eventName,extras) override fun track(analyticsManager: AnalyticsManager) = analyticsManager.sendEvent(eventName,extras)

View File

@ -2,7 +2,7 @@ package com.shabinder.common.core_components.analytics
import com.shabinder.common.core_components.analytics.AnalyticsManager.Companion.AnalyticsAction import com.shabinder.common.core_components.analytics.AnalyticsManager.Companion.AnalyticsAction
sealed class AnalyticsView(private val viewName: String, private val extras: Map<String, Any> = emptyMap()) : AnalyticsAction() { sealed class AnalyticsView(private val viewName: String, private val extras: MutableMap<String, Any> = mutableMapOf()) : AnalyticsAction() {
override fun track(analyticsManager: AnalyticsManager) = analyticsManager.sendView(viewName,extras) override fun track(analyticsManager: AnalyticsManager) = analyticsManager.sendView(viewName,extras)
object HomeScreen: AnalyticsView("home_screen") object HomeScreen: AnalyticsView("home_screen")

View File

@ -43,21 +43,21 @@ internal class DesktopAnalyticsManager(
Countly.onConsentRemoval(*featuresSet) Countly.onConsentRemoval(*featuresSet)
} }
override fun sendView(name: String, extras: Map<String, Any>) { override fun sendView(name: String, extras: MutableMap<String, Any>) {
Countly.api().view(name) Countly.api().view(name)
} }
override fun sendEvent(eventName: String, extras: Map<String, Any>) { override fun sendEvent(eventName: String, extras: MutableMap<String, Any>) {
Countly.api().event(eventName) Countly.api().event(eventName)
.setSegmentation(extras.filterValues { it is String } as? Map<String, String> ?: emptyMap()).record() .setSegmentation(extras.filterValues { it is String } as? MutableMap<String, String> ?: emptyMap()).record()
} }
override fun sendCrashReport(error: Throwable, extras: Map<String, Any>) { override fun sendCrashReport(error: Throwable, extras: MutableMap<String, Any>) {
Countly.api().addCrashReport( Countly.api().addCrashReport(
error, error,
extras.getOrDefault("fatal", true) as Boolean, extras.getOrDefault("fatal", true) as Boolean,
error.javaClass.simpleName, error.javaClass.simpleName,
extras.filterValues { it is String } as? Map<String, String> ?: emptyMap() extras.filterValues { it is String } as? MutableMap<String, String> ?: emptyMap()
) )
} }

View File

@ -18,11 +18,11 @@ private val webAnalytics =
override fun revokeConsent() {} override fun revokeConsent() {}
override fun sendView(name: String, extras: Map<String, Any>) {} override fun sendView(name: String, extras: MutableMap<String, Any>) {}
override fun sendEvent(eventName: String, extras: Map<String, Any>) {} override fun sendEvent(eventName: String, extras: MutableMap<String, Any>) {}
override fun sendCrashReport(error: Throwable, extras: Map<String, Any>) {} override fun sendCrashReport(error: Throwable, extras: MutableMap<String, Any>) {}
} }
actual fun analyticsModule() = module { actual fun analyticsModule() = module {

View File

@ -124,6 +124,7 @@ class FetchPlatformQueryResult(
null null
} }
} }
}
// if videoID wasn't present || fetching using video ID failed // if videoID wasn't present || fetching using video ID failed
if (downloadLink.isNullOrBlank()) { if (downloadLink.isNullOrBlank()) {
@ -144,7 +145,6 @@ class FetchPlatformQueryResult(
downloadLink = queryResult.component1() downloadLink = queryResult.component1()
} }
} }
}
return if (downloadLink.isNullOrBlank()) SuspendableEvent.error( return if (downloadLink.isNullOrBlank()) SuspendableEvent.error(
SpotiFlyerException.DownloadLinkFetchFailed(errorTrace) SpotiFlyerException.DownloadLinkFetchFailed(errorTrace)
) else SuspendableEvent.success(downloadLink.requireNotNull()) ) else SuspendableEvent.success(downloadLink.requireNotNull())