diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro index 3ecf9dfd..07eaa0a0 100644 --- a/android/proguard-rules.pro +++ b/android/proguard-rules.pro @@ -32,6 +32,7 @@ kotlinx.serialization.KSerializer serializer(...); } -keep class com.shabinder.** { *; } +-keep class com.mpatric.** { *; } -keep,includedescriptorclasses class com.shabinder.**$$serializer { *; } # <-- change package name to your app's -keepclassmembers class com.shabinder.** { # <-- change package name to your app's *** Companion; diff --git a/build.gradle.kts b/build.gradle.kts index 7fe993a5..482c379e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,8 @@ allprojects { maven(url = "https://dl.bintray.com/ekito/koin") maven(url = "https://kotlin.bintray.com/kotlinx/") maven(url = "https://dl.bintray.com/icerockdev/moko") - maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers/") + //maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers/") + maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers") maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a7f96ee8..4322dd17 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -9,16 +9,18 @@ version = "2.1" repositories { jcenter() mavenLocal() + mavenCentral() google() maven(url = "https://jitpack.io") - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers") + maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") } dependencies { - implementation("com.android.tools.build:gradle:4.0.1") + implementation("com.android.tools.build:gradle:4.0.2") implementation("com.google.gms:google-services:4.3.5") - implementation("com.google.firebase:perf-plugin:1.3.4") - implementation("com.google.firebase:firebase-crashlytics-gradle:2.5.0") + implementation("com.google.firebase:perf-plugin:1.3.5") + implementation("com.google.firebase:firebase-crashlytics-gradle:2.5.1") implementation(JetBrains.Compose.gradlePlugin) implementation(JetBrains.Kotlin.gradlePlugin) implementation(JetBrains.Kotlin.serialization) diff --git a/buildSrc/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/buildSrc/src/main/kotlin/Versions.kt index 6c5a6212..2e7fece5 100644 --- a/buildSrc/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/buildSrc/src/main/kotlin/Versions.kt @@ -2,7 +2,7 @@ object Versions { const val versionName = "2.2.0" - const val kotlinVersion = "1.4.30" + const val kotlinVersion = "1.4.31" const val coroutinesVersion = "1.4.2" //const val compose = "1.0.0-alpha12" @@ -67,7 +67,7 @@ object JetBrains { object Compose { // __LATEST_COMPOSE_RELEASE_VERSION__ - const val VERSION = "0.4.0-build168" + const val VERSION = "0.3.2" const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" } } diff --git a/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts index 75ad5b35..ca88a8c5 100644 --- a/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts @@ -7,36 +7,36 @@ plugins { kotlin { jvm("desktop") android() - // Remove After upgrading dependency - /*configurations.all { - resolutionStrategy.eachDependency { - if (requested.group.contains("org.jetbrains.compose")) { - useVersion(JetBrains.Compose.VERSION) - } - if (requested.group.contains("androidx.compose")) { - useVersion(Versions.compose) - } - } - }*/ + js { + browser() + nodejs() + } sourceSets { named("commonMain") { dependencies { - api(compose.runtime) - api(compose.foundation) - api(compose.material) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) } } named("androidMain") { dependencies { - api("androidx.appcompat:appcompat:1.2.0") - api(Androidx.core) + implementation("androidx.appcompat:appcompat:1.2.0") + implementation(Androidx.core) } } named("desktopMain") { dependencies { - api(compose.desktop.common) + implementation(compose.desktop.common) + } + } + named("jsMain") { + dependencies { + implementation("org.jetbrains:kotlin-react:17.0.1-pre.148-kotlin-1.4.30") + implementation("org.jetbrains:kotlin-styled:1.0.0-pre.115-kotlin-1.4.10") + implementation("org.jetbrains:kotlin-react-dom:17.0.1-pre.148-kotlin-1.4.30") } } } diff --git a/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts index 75cedec1..6f128d50 100644 --- a/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts @@ -7,7 +7,10 @@ kotlin { jvm("desktop") android() //ios() - + js { + browser() + nodejs() + } sourceSets { named("commonTest") { dependencies { @@ -26,6 +29,11 @@ kotlin { implementation(JetBrains.Kotlin.testJunit) } } + named("jsTest") { + dependencies { + + } + } } tasks.withType { diff --git a/common/database/src/androidMain/kotlin/com/shabinder/common/database/Actual.kt b/common/database/src/androidMain/kotlin/com/shabinder/common/database/Actual.kt index fa7a76a6..e3480626 100644 --- a/common/database/src/androidMain/kotlin/com/shabinder/common/database/Actual.kt +++ b/common/database/src/androidMain/kotlin/com/shabinder/common/database/Actual.kt @@ -15,7 +15,8 @@ lateinit var appContext: Context @SuppressLint("StaticFieldLeak") lateinit var activityContext: Context -actual fun createDatabase(): Database { +@Suppress("RedundantNullableReturnType") +actual fun createDatabase(): Database? { val driver = AndroidSqliteDriver(Database.Schema, appContext, "Database.db") return Database(driver) } diff --git a/common/database/src/commonMain/kotlin/com/shabinder/common/database/Expect.kt b/common/database/src/commonMain/kotlin/com/shabinder/common/database/Expect.kt index 563725a8..188a9e0d 100644 --- a/common/database/src/commonMain/kotlin/com/shabinder/common/database/Expect.kt +++ b/common/database/src/commonMain/kotlin/com/shabinder/common/database/Expect.kt @@ -3,5 +3,5 @@ package com.shabinder.common.database import co.touchlab.kermit.Logger import com.shabinder.database.Database -expect fun createDatabase() : Database +expect fun createDatabase() : Database? expect fun getLogger(): Logger \ No newline at end of file diff --git a/common/database/src/desktopMain/kotlin/com/shabinder/common/database/Actual.kt b/common/database/src/desktopMain/kotlin/com/shabinder/common/database/Actual.kt index 51d1ddfd..96f43944 100644 --- a/common/database/src/desktopMain/kotlin/com/shabinder/common/database/Actual.kt +++ b/common/database/src/desktopMain/kotlin/com/shabinder/common/database/Actual.kt @@ -6,7 +6,8 @@ import com.shabinder.database.Database import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver import java.io.File -actual fun createDatabase(): Database { +@Suppress("RedundantNullableReturnType") +actual fun createDatabase(): Database? { val databasePath = File(System.getProperty("java.io.tmpdir"), "Database.db") val driver = JdbcSqliteDriver(url = "jdbc:sqlite:${databasePath.absolutePath}") .also { Database.Schema.create(it) } diff --git a/common/database/src/jsMain/kotlin/com/shabinder/common/database/Actual.kt b/common/database/src/jsMain/kotlin/com/shabinder/common/database/Actual.kt new file mode 100644 index 00000000..7b73ffa1 --- /dev/null +++ b/common/database/src/jsMain/kotlin/com/shabinder/common/database/Actual.kt @@ -0,0 +1,8 @@ +package com.shabinder.common.database + +import co.touchlab.kermit.CommonLogger +import co.touchlab.kermit.Logger +import com.shabinder.database.Database + +actual fun createDatabase(): Database? = null +actual fun getLogger(): Logger = CommonLogger() \ No newline at end of file diff --git a/common/dependency-injection/build.gradle.kts b/common/dependency-injection/build.gradle.kts index c99266c4..78430ba3 100644 --- a/common/dependency-injection/build.gradle.kts +++ b/common/dependency-injection/build.gradle.kts @@ -15,7 +15,7 @@ kotlin { implementation(project(":common:database")) implementation(project(":fuzzywuzzy:app")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.1") implementation(Ktor.clientCore) implementation(Ktor.clientCio) @@ -43,7 +43,6 @@ kotlin { } desktopMain { dependencies{ - implementation("com.github.kokorin.jaffree:jaffree:0.9.10") implementation(Ktor.clientApache) implementation(Ktor.slf4j) } diff --git a/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebActual.kt b/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebActual.kt new file mode 100644 index 00000000..34de4243 --- /dev/null +++ b/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebActual.kt @@ -0,0 +1,62 @@ +package com.shabinder.common.di + +import com.shabinder.common.models.DownloadStatus +import com.shabinder.common.models.TrackDetails +import io.ktor.client.request.* +import kotlinx.coroutines.* +import kotlinx.coroutines.flow.MutableSharedFlow + +actual fun openPlatform(packageID:String, platformLink:String){ + //TODO +} + +actual fun shareApp(){ + //TODO +} + +actual fun giveDonation(){ + //TODO +} + +actual fun queryActiveTracks(){} +actual fun showPopUpMessage(text:String){} + +actual val dispatcherIO: CoroutineDispatcher = Dispatchers.Default + +/* +* Refactor This +* */ +private suspend fun isInternetAvailable(): Boolean { + return withContext(dispatcherIO) { + try { + ktorHttpClient.head("http://google.com") + true + } catch (e: Exception) { + println(e.message) + false + } + } +} + +actual val isInternetAvailable:Boolean + get(){ + var result = false + val job = GlobalScope.launch { result = isInternetAvailable() } + while(job.isActive){} + return result + } + +val DownloadProgressFlow: MutableSharedFlow> = MutableSharedFlow(1) + +actual suspend fun downloadTracks( + list: List, + getYTIDBestMatch:suspend (String,TrackDetails)->String?, + saveFileWithMetaData:suspend (mp3ByteArray:ByteArray, trackDetails: TrackDetails) -> Unit +){ + list.forEach { + if (!it.videoID.isNullOrBlank()) {//Video ID already known! + } else { + + } + } +} diff --git a/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebDir.kt b/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebDir.kt new file mode 100644 index 00000000..f59c0f36 --- /dev/null +++ b/common/dependency-injection/src/jsMain/kotlin/com/shabinder/common/di/WebDir.kt @@ -0,0 +1,57 @@ +package com.shabinder.common.di + +import co.touchlab.kermit.Kermit +import com.shabinder.common.models.TrackDetails +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import org.w3c.dom.ImageBitmap + +actual class Dir actual constructor(private val logger: Kermit) { + + /*init { + createDirectories() + }*/ +/* +* TODO +* */ + actual fun fileSeparator(): String = "/" + + actual fun imageCacheDir(): String = "TODO" + + fileSeparator() + "SpotiFlyer/.images" + fileSeparator() + + actual fun defaultDir(): String = "TODO" + fileSeparator() + + "SpotiFlyer" + fileSeparator() + + actual fun isPresent(path: String): Boolean = false + + actual fun createDirectory(dirPath:String){ + + } + + actual suspend fun clearCache() { + } + + actual suspend fun cacheImage(image: Any,path:String) {} + + @Suppress("BlockingMethodInNonBlockingContext") + actual suspend fun saveFileWithMetadata( + mp3ByteArray: ByteArray, + trackDetails: TrackDetails + ) { + } + + actual fun addToLibrary(path:String){} + + actual suspend fun loadImage(url: String): ImageBitmap? { + return null + } + + private fun loadCachedImage(cachePath: String): ImageBitmap? { + return null + } + + private suspend fun freshImage(url:String): ImageBitmap?{ + return null + } +} diff --git a/common/root/build.gradle.kts b/common/root/build.gradle.kts index 18edb6f7..f67f9492 100644 --- a/common/root/build.gradle.kts +++ b/common/root/build.gradle.kts @@ -12,7 +12,6 @@ kotlin { dependencies { implementation(compose.materialIconsExtended) implementation(project(":common:dependency-injection")) - //implementation("com.alialbaali.kamel:kamel-image:0.1.0") implementation(project(":common:data-models")) implementation(project(":common:database")) implementation(project(":common:list")) diff --git a/desktop/src/jvmMain/kotlin/Main.kt b/desktop/src/jvmMain/kotlin/Main.kt index eb30c810..2c2647d7 100644 --- a/desktop/src/jvmMain/kotlin/Main.kt +++ b/desktop/src/jvmMain/kotlin/Main.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import com.arkivanov.decompose.ComponentContext -import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent +import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent import com.arkivanov.mvikotlin.core.lifecycle.LifecycleRegistry import com.arkivanov.mvikotlin.core.lifecycle.resume import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory @@ -15,11 +15,7 @@ import com.shabinder.common.di.DownloadProgressFlow import com.shabinder.common.di.FetchPlatformQueryResult import com.shabinder.common.di.initKoin import com.shabinder.common.root.SpotiFlyerRoot -import com.shabinder.common.root.SpotiFlyerRootContent -import com.shabinder.common.uikit.SpotiFlyerColors -import com.shabinder.common.uikit.SpotiFlyerShapes -import com.shabinder.common.uikit.SpotiFlyerTypography -import com.shabinder.common.uikit.colorOffWhite +import com.shabinder.common.uikit.* import com.shabinder.database.Database import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch @@ -42,13 +38,7 @@ fun main(){ typography = SpotiFlyerTypography, shapes = SpotiFlyerShapes ) { - val callBacks = SpotiFlyerRootContent(rootComponent(factory = ::spotiFlyerRoot)).callBacks - val scope = rememberCoroutineScope() - scope.launch { - DownloadProgressFlow.collect { - - } - } + val callBacks = SpotiFlyerRootContent(rememberRootComponent(factory = ::spotiFlyerRoot)).callBacks } } }