From 148d56956b3b3754dd961f775f8d53fe9c8ebf11 Mon Sep 17 00:00:00 2001 From: shabinder Date: Wed, 28 Apr 2021 14:54:56 +0530 Subject: [PATCH] Dep Updates and Logging --- android/src/main/java/com/shabinder/spotiflyer/App.kt | 5 +++-- .../src/main/java/com/shabinder/spotiflyer/di/AppModule.kt | 7 ++++--- common/dependency-injection/build.gradle.kts | 4 ++-- .../kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt | 3 ++- .../com/shabinder/common/di/providers/YoutubeMusic.kt | 2 +- .../kotlin/com/shabinder/common/di/youtubeMp3/Yt1sMp3.kt | 3 ++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/android/src/main/java/com/shabinder/spotiflyer/App.kt b/android/src/main/java/com/shabinder/spotiflyer/App.kt index cdef2ed9..19c5ea91 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/App.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/App.kt @@ -29,11 +29,12 @@ class App: Application(), KoinComponent { super.onCreate() appContext = this + val loggingEnabled = true - initKoin { + initKoin(loggingEnabled) { androidLogger() androidContext(this@App) - modules(appModule) + modules(appModule(loggingEnabled)) } } } \ No newline at end of file diff --git a/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt b/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt index 3a682f3f..34ff7b9d 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt @@ -21,15 +21,16 @@ import com.tonyodev.fetch2.Fetch import com.tonyodev.fetch2.FetchConfiguration import org.koin.dsl.module -val appModule = module { - single { createFetchInstance() } +fun appModule(enableLogging:Boolean = false) = module { + single { createFetchInstance(enableLogging) } } -private fun createFetchInstance():Fetch{ +private fun createFetchInstance(enableLogging:Boolean = false):Fetch{ val fetchConfiguration = FetchConfiguration.Builder(appContext).run { setNamespace("ForegroundDownloaderService") setDownloadConcurrentLimit(4) + enableLogging(enableLogging) build() } diff --git a/common/dependency-injection/build.gradle.kts b/common/dependency-injection/build.gradle.kts index 5e43ff7a..98089083 100644 --- a/common/dependency-injection/build.gradle.kts +++ b/common/dependency-injection/build.gradle.kts @@ -48,9 +48,9 @@ kotlin { dependencies { implementation(project(":common:data-models")) implementation(project(":common:database")) - implementation("org.jetbrains.kotlinx:atomicfu:0.15.2") + implementation("org.jetbrains.kotlinx:atomicfu:0.16.1") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.0") implementation("com.shabinder.fuzzywuzzy:fuzzywuzzy:1.0") implementation(Ktor.clientCore) implementation(Ktor.clientSerialization) diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt index 6f7ef219..38856d00 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt @@ -25,10 +25,11 @@ import io.ktor.client.HttpClient class YoutubeMp3( override val httpClient: HttpClient, - private val logger: Kermit, + override val logger: Kermit, private val dir: Dir, ) : Yt1sMp3 { suspend fun getMp3DownloadLink(videoID: String): String? = getLinkFromYt1sMp3(videoID)?.let { + logger.i { "Download Link: $it" } if (currentPlatform is AllPlatforms.Js/* && corsProxy !is CorsProxy.PublicProxyWithExtension*/) "https://kind-grasshopper-73.telebit.io/cors/$it" // "https://spotiflyer.azurewebsites.net/$it" // Data OUT Limit issue diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt index a1acf12d..9cf1eb05 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt @@ -20,7 +20,7 @@ import co.touchlab.kermit.Kermit import com.shabinder.common.di.gaana.corsApi import com.shabinder.common.models.TrackDetails import com.shabinder.common.models.YoutubeTrack -import com.willowtreeapps.fuzzywuzzy.diffutils.FuzzySearch +import com.shabinder.fuzzywuzzy.diffutils.FuzzySearch import io.ktor.client.HttpClient import io.ktor.client.request.headers import io.ktor.client.request.post diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/youtubeMp3/Yt1sMp3.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/youtubeMp3/Yt1sMp3.kt index 898aba06..4a1613a5 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/youtubeMp3/Yt1sMp3.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/youtubeMp3/Yt1sMp3.kt @@ -16,6 +16,7 @@ package com.shabinder.common.di.youtubeMp3 +import co.touchlab.kermit.Kermit import com.shabinder.common.di.gaana.corsApi import io.ktor.client.HttpClient import io.ktor.client.request.forms.FormDataContent @@ -31,7 +32,7 @@ import kotlinx.serialization.json.jsonPrimitive interface Yt1sMp3 { val httpClient: HttpClient - + val logger: Kermit /* * Downloadable Mp3 Link for YT videoID. * */