From 74fab77d6543801ab0bb4a8cd01c9c11c82af5f5 Mon Sep 17 00:00:00 2001 From: Ali Albaali Date: Sat, 23 Jul 2022 22:52:12 +0300 Subject: [PATCH] Update dependencies version and refactor --- buildSrc/src/main/kotlin/Dependencies.kt | 20 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 6 +++--- kamel-core/build.gradle.kts | 2 +- .../io/kamel/core/fetcher/HttpFetcher.kt | 4 +--- kamel-image/build.gradle.kts | 4 ++-- .../kamel/image/fetcher/ResourcesFetcher.kt | 2 -- .../kamel/image/mapper/ResourcesIdMapper.kt | 4 ++-- .../io/kamel/image/LazyPainterResource.kt | 1 - kamel-samples/build.gradle.kts | 4 ++-- .../src/androidMain/AndroidManifest.xml | 4 ++-- .../kotlin/io/kamel/samples/Gallery.kt | 16 +++++++-------- 11 files changed, 31 insertions(+), 36 deletions(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 9e82a78a..2372111b 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -24,22 +24,22 @@ object Dependencies { const val Coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.Coroutines}" const val Compose = "org.jetbrains.compose.ui:ui-test-junit4:${Versions.Compose}" } - + } private object Versions { - const val Kotlin = "1.6.10" - const val Ktor = "2.0.0" - const val Coroutines = "1.6.0" - const val Compose = "1.0.1" - const val AGP = "7.1.3" + const val Kotlin = "1.7.0" + const val Ktor = "2.0.3" + const val Coroutines = "1.6.3" + const val Compose = "1.2.0-alpha01-dev750" + const val AGP = "7.2.1" object Android { - const val Appcompat = "1.4.1" - const val Core = "1.6.0" - const val ActivityCompose = "1.4.0" - const val Material = "1.5.0" + const val Appcompat = "1.4.2" + const val Core = "1.8.0" + const val ActivityCompose = "1.5.0" + const val Material = "1.6.1" } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3f863007..1565a526 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Aug 05 13:20:35 TRT 2021 +#Sun Jul 10 06:06:14 TRT 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME +zipStoreBase=GRADLE_USER_HOME \ No newline at end of file diff --git a/kamel-core/build.gradle.kts b/kamel-core/build.gradle.kts index 4ea5b142..b461c4d6 100644 --- a/kamel-core/build.gradle.kts +++ b/kamel-core/build.gradle.kts @@ -50,7 +50,7 @@ kotlin { all { languageSettings.apply { - useExperimentalAnnotation("kotlin.Experimental") + optIn("kotlin.Experimental") } } diff --git a/kamel-core/src/commonMain/kotlin/io/kamel/core/fetcher/HttpFetcher.kt b/kamel-core/src/commonMain/kotlin/io/kamel/core/fetcher/HttpFetcher.kt index 517ebd62..12ac229c 100644 --- a/kamel-core/src/commonMain/kotlin/io/kamel/core/fetcher/HttpFetcher.kt +++ b/kamel-core/src/commonMain/kotlin/io/kamel/core/fetcher/HttpFetcher.kt @@ -4,12 +4,11 @@ import io.kamel.core.DataSource import io.kamel.core.Resource import io.kamel.core.config.ResourceConfig import io.ktor.client.* -import io.ktor.client.call.* import io.ktor.client.plugins.* import io.ktor.client.request.* +import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.utils.io.* -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.channelFlow @@ -23,7 +22,6 @@ internal class HttpFetcher(private val client: HttpClient) : Fetcher { override val Url.isSupported: Boolean get() = protocol.name == "https" || protocol.name == "http" - @OptIn(ExperimentalCoroutinesApi::class) override fun fetch( data: Url, resourceConfig: ResourceConfig diff --git a/kamel-image/build.gradle.kts b/kamel-image/build.gradle.kts index bd5c19fd..7a616cfb 100644 --- a/kamel-image/build.gradle.kts +++ b/kamel-image/build.gradle.kts @@ -10,11 +10,11 @@ plugins { } android { - compileSdk = 31 + compileSdk = 33 defaultConfig { minSdk = 21 - targetSdk = 31 + targetSdk = 33 multiDexEnabled = true } diff --git a/kamel-image/src/androidMain/kotlin/io/kamel/image/fetcher/ResourcesFetcher.kt b/kamel-image/src/androidMain/kotlin/io/kamel/image/fetcher/ResourcesFetcher.kt index e94da754..212a1835 100644 --- a/kamel-image/src/androidMain/kotlin/io/kamel/image/fetcher/ResourcesFetcher.kt +++ b/kamel-image/src/androidMain/kotlin/io/kamel/image/fetcher/ResourcesFetcher.kt @@ -9,7 +9,6 @@ import io.kamel.core.fetcher.Fetcher import io.kamel.image.utils.path import io.ktor.http.* import io.ktor.utils.io.* -import io.ktor.utils.io.core.* import io.ktor.utils.io.jvm.javaio.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -22,7 +21,6 @@ internal class ResourcesFetcher(private val context: Context) : Fetcher { override val Url.isSupported: Boolean get() = protocol.name == ContentResolver.SCHEME_ANDROID_RESOURCE - @OptIn(ExperimentalIoApi::class) override fun fetch( data: Url, resourceConfig: ResourceConfig diff --git a/kamel-image/src/androidMain/kotlin/io/kamel/image/mapper/ResourcesIdMapper.kt b/kamel-image/src/androidMain/kotlin/io/kamel/image/mapper/ResourcesIdMapper.kt index 5025885a..caf2650f 100644 --- a/kamel-image/src/androidMain/kotlin/io/kamel/image/mapper/ResourcesIdMapper.kt +++ b/kamel-image/src/androidMain/kotlin/io/kamel/image/mapper/ResourcesIdMapper.kt @@ -7,13 +7,13 @@ import io.kamel.core.mapper.Mapper import io.ktor.http.* -internal class ResourcesIdMapper(private val context: Context) : Mapper<@DrawableRes Int, Url> { +internal class ResourcesIdMapper(private val context: Context) : Mapper<@receiver:DrawableRes Int, Url> { override fun map(@DrawableRes input: Int): Url { val packageName = context.packageName val protocol = URLProtocol(name = ContentResolver.SCHEME_ANDROID_RESOURCE, defaultPort = -1) - return URLBuilder(protocol = protocol, host = packageName, encodedPath = input.toString()) + return URLBuilder(protocol = protocol, host = packageName, pathSegments = listOf(input.toString())) .build() } } \ No newline at end of file diff --git a/kamel-image/src/commonMain/kotlin/io/kamel/image/LazyPainterResource.kt b/kamel-image/src/commonMain/kotlin/io/kamel/image/LazyPainterResource.kt index 4deeed59..28e1b0fc 100644 --- a/kamel-image/src/commonMain/kotlin/io/kamel/image/LazyPainterResource.kt +++ b/kamel-image/src/commonMain/kotlin/io/kamel/image/LazyPainterResource.kt @@ -12,7 +12,6 @@ import io.kamel.core.config.ResourceConfig import io.kamel.core.config.ResourceConfigBuilder import io.kamel.image.config.LocalKamelConfig import io.ktor.http.* -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext diff --git a/kamel-samples/build.gradle.kts b/kamel-samples/build.gradle.kts index 88e7d56c..37b43c98 100644 --- a/kamel-samples/build.gradle.kts +++ b/kamel-samples/build.gradle.kts @@ -7,11 +7,11 @@ plugins { } android { - compileSdk = 31 + compileSdk = 33 defaultConfig { minSdk = 21 - targetSdk = 31 + targetSdk = 33 versionCode = 1 versionName = "1.0" multiDexEnabled = true diff --git a/kamel-samples/src/androidMain/AndroidManifest.xml b/kamel-samples/src/androidMain/AndroidManifest.xml index 8f2184d1..008726bd 100644 --- a/kamel-samples/src/androidMain/AndroidManifest.xml +++ b/kamel-samples/src/androidMain/AndroidManifest.xml @@ -16,8 +16,8 @@ android:theme="@style/Theme.MyApplication"> + android:theme="@style/Theme.MyApplication.NoActionBar" + android:exported="true"> diff --git a/kamel-samples/src/commonMain/kotlin/io/kamel/samples/Gallery.kt b/kamel-samples/src/commonMain/kotlin/io/kamel/samples/Gallery.kt index e7ebacf2..0a8d2b96 100644 --- a/kamel-samples/src/commonMain/kotlin/io/kamel/samples/Gallery.kt +++ b/kamel-samples/src/commonMain/kotlin/io/kamel/samples/Gallery.kt @@ -3,30 +3,30 @@ package io.kamel.samples import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring -import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.GridCells -import androidx.compose.foundation.lazy.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Card import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.unit.dp import io.kamel.core.Resource +import io.kamel.image.KamelImage import io.kamel.image.lazyPainterResource private const val ItemsCount: Int = 100 public expect val cellsCount: Int -@OptIn(ExperimentalFoundationApi::class) @Composable public fun Gallery() { - LazyVerticalGrid(cells = GridCells.Fixed(cellsCount), modifier = Modifier.fillMaxSize()) { + LazyVerticalGrid(columns = GridCells.Fixed(cellsCount), modifier = Modifier.fillMaxSize()) { items(ItemsCount) { item -> @@ -38,8 +38,8 @@ public fun Gallery() { modifier = Modifier .animateContentSize(spring(stiffness = Spring.StiffnessLow)) .padding(16.dp) - .fillParentMaxWidth() - .fillParentMaxHeight(0.5F), + .fillMaxWidth() + .fillMaxHeight(0.5F), shape = RoundedCornerShape(16.dp), elevation = 8.dp, ) {