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

View File

@ -51,15 +51,15 @@ internal class AndroidAnalyticsManager(private val mainActivity: Activity) : Ana
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)
}
override fun sendEvent(eventName: String, extras: Map<String, Any>) {
override fun sendEvent(eventName: String, extras: MutableMap<String, Any>) {
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)
}
}

View File

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

View File

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

View File

@ -9,10 +9,10 @@ interface AnalyticsManager {
fun giveConsent()
fun isTracking(): Boolean
fun revokeConsent()
fun sendView(name: String, extras: Map<String, Any> = emptyMap())
fun sendEvent(eventName: String, extras: Map<String, Any> = emptyMap())
fun sendView(name: String, extras: MutableMap<String, Any> = mutableMapOf())
fun sendEvent(eventName: String, extras: MutableMap<String, Any> = mutableMapOf())
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 {
abstract class AnalyticsAction {

View File

@ -1,6 +1,6 @@
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)

View File

@ -2,7 +2,7 @@ package com.shabinder.common.core_components.analytics
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)
object HomeScreen: AnalyticsView("home_screen")

View File

@ -43,21 +43,21 @@ internal class DesktopAnalyticsManager(
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)
}
override fun sendEvent(eventName: String, extras: Map<String, Any>) {
override fun sendEvent(eventName: String, extras: MutableMap<String, Any>) {
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(
error,
extras.getOrDefault("fatal", true) as Boolean,
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 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 {

View File

@ -124,25 +124,25 @@ class FetchPlatformQueryResult(
null
}
}
// if videoID wasn't present || fetching using video ID failed
if (downloadLink.isNullOrBlank()) {
}
// if videoID wasn't present || fetching using video ID failed
if (downloadLink.isNullOrBlank()) {
// Try Fetching Track from Available Sources
val queryResult = saavnProvider.findBestSongDownloadURL(
trackName = track.title,
trackArtists = track.artists,
preferredQuality = preferredQuality
).flatMapError { saavnError ->
appendPadded("Fetching From Saavn Failed:", saavnError.stackTraceToString())
// Saavn Failed, Lets Try Fetching Now From Youtube Music
youtubeMusic.findMp3SongDownloadURLYT(track, preferredQuality).also {
if (it is SuspendableEvent.Failure)
appendPadded("Fetching From YT-Music Failed:", it.component2()?.stackTraceToString())
}
// Try Fetching Track from Available Sources
val queryResult = saavnProvider.findBestSongDownloadURL(
trackName = track.title,
trackArtists = track.artists,
preferredQuality = preferredQuality
).flatMapError { saavnError ->
appendPadded("Fetching From Saavn Failed:", saavnError.stackTraceToString())
// Saavn Failed, Lets Try Fetching Now From Youtube Music
youtubeMusic.findMp3SongDownloadURLYT(track, preferredQuality).also {
if (it is SuspendableEvent.Failure)
appendPadded("Fetching From YT-Music Failed:", it.component2()?.stackTraceToString())
}
downloadLink = queryResult.component1()
}
downloadLink = queryResult.component1()
}
}
return if (downloadLink.isNullOrBlank()) SuspendableEvent.error(