From c733b55f69457d0bc6f02f36f4335d2442136279 Mon Sep 17 00:00:00 2001 From: Ben Trengrove Date: Fri, 5 Aug 2022 09:35:22 +1000 Subject: [PATCH 1/6] Upgrade to Compose 1.3 --- .../src/main/java/com/example/crane/buildsrc/Dependencies.kt | 2 +- JetNews/build.gradle | 4 ++-- .../main/java/com/example/jetcaster/buildsrc/dependencies.kt | 4 ++-- .../java/com/example/compose/jetchat/buildsrc/dependencies.kt | 2 +- .../main/java/com/example/jetsnack/buildsrc/Dependencies.kt | 4 ++-- .../com/example/compose/jetsurvey/buildsrc/dependencies.kt | 4 ++-- .../src/main/java/com/example/owl/buildsrc/Dependencies.kt | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt index 1f666529a..67a43cb5c 100644 --- a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt +++ b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt @@ -59,7 +59,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" const val runtime = "androidx.compose.runtime:runtime:$version" const val runtimeLivedata = "androidx.compose.runtime:runtime-livedata:$version" diff --git a/JetNews/build.gradle b/JetNews/build.gradle index 9c952366c..c4be01908 100644 --- a/JetNews/build.gradle +++ b/JetNews/build.gradle @@ -17,10 +17,10 @@ buildscript { ext.kotlin_version = '1.7.0' ext.compose_compiler_version = '1.2.0' - ext.compose_version = '1.2.0' + ext.compose_version = '1.3.0-alpha02' ext.compose_snapshot_version = '' ext.coroutines_version = '1.6.0' - ext.accompanist_version = '0.25.0' + ext.accompanist_version = '0.26.0-alpha' repositories { google() diff --git a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt index ac11d3b07..9e5377b31 100644 --- a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt +++ b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt @@ -25,7 +25,7 @@ object Libs { const val jdkDesugar = "com.android.tools:desugar_jdk_libs:1.1.5" object Accompanist { - const val version = "0.25.0" + const val version = "0.26.0-alpha" const val pager = "com.google.accompanist:accompanist-pager:$version" } @@ -71,7 +71,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" @get:JvmStatic val snapshotUrl: String diff --git a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt index 1b52b84c2..de0e5c73c 100644 --- a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt +++ b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt @@ -53,7 +53,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" const val foundation = "androidx.compose.foundation:foundation:$version" const val layout = "androidx.compose.foundation:foundation-layout:$version" diff --git a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt index 6ccd8197d..d3f3eacb7 100644 --- a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt +++ b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt @@ -24,7 +24,7 @@ object Libs { const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" object Accompanist { - const val version = "0.25.0" + const val version = "0.26.0-alpha" const val systemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:$version" const val flowlayouts = "com.google.accompanist:accompanist-flowlayout:$version" } @@ -49,7 +49,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" const val foundation = "androidx.compose.foundation:foundation:${version}" const val layout = "androidx.compose.foundation:foundation-layout:${version}" diff --git a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt index d925c2ea1..5d10b2dea 100644 --- a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt +++ b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt @@ -27,7 +27,7 @@ object Libs { const val junit = "junit:junit:4.13.2" object Accompanist { - const val version = "0.25.0" + const val version = "0.26.0-alpha" const val permissions = "com.google.accompanist:accompanist-permissions:$version" } @@ -62,7 +62,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" @get:JvmStatic val snapshotUrl: String diff --git a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt index 3c691ac2b..f844a0c03 100644 --- a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt +++ b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt @@ -47,7 +47,7 @@ object Libs { object Compose { const val compilerVersion = "1.2.0" const val snapshot = "" - const val version = "1.2.0" + const val version = "1.3.0-alpha02" const val animation = "androidx.compose.animation:animation:$version" const val foundation = "androidx.compose.foundation:foundation:$version" From fbb1e666b5f22d3e9cdfffc3f943e586dda7fa2c Mon Sep 17 00:00:00 2001 From: Ben Trengrove Date: Fri, 5 Aug 2022 10:59:22 +1000 Subject: [PATCH 2/6] Fix lint on JetNews --- .../main/java/com/example/jetnews/ui/home/HomeScreens.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreens.kt b/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreens.kt index 7acec7422..acf4f6a1b 100644 --- a/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreens.kt +++ b/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeScreens.kt @@ -163,8 +163,10 @@ fun HomeFeedWithArticleDetailsScreen( // Crossfade between different detail posts Crossfade(targetState = hasPostsUiState.selectedPost) { detailPost -> // Get the lazy list state for this detail view - val detailLazyListState by derivedStateOf { - articleDetailLazyListStates.getValue(detailPost.id) + val detailLazyListState by remember { + derivedStateOf { + articleDetailLazyListStates.getValue(detailPost.id) + } } // Key against the post id to avoid sharing any state between different posts From 0f862dfdb77b2a1af2fc0563c23fb0276fd74849 Mon Sep 17 00:00:00 2001 From: Ben Trengrove Date: Fri, 5 Aug 2022 14:21:55 +1000 Subject: [PATCH 3/6] Make reply work with upgrade script --- Reply/build.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Reply/build.gradle b/Reply/build.gradle index ee5ee3095..19c487783 100644 --- a/Reply/build.gradle +++ b/Reply/build.gradle @@ -15,13 +15,15 @@ */ buildscript { + // Extracted for updating via scripts/upgrade_samples.sh + ext.compose_version = '1.3.0-alpha02' + ext { kotlin_version = '1.7.0' - compose_version = '1.2.0' compose_compiler_version = '1.2.0' material3_version = "1.0.0-alpha14" coroutines_version = '1.6.0' - agp_version = "7.2.1" + agp_version = '7.2.1' } } @@ -50,4 +52,4 @@ subprojects { licenseHeaderFile rootProject.file('spotless/copyright.kt') } } -} \ No newline at end of file +} From f1ebfe3c96018ecb0014a4e578a946ccf7a6b770 Mon Sep 17 00:00:00 2001 From: Ben Trengrove Date: Mon, 8 Aug 2022 10:04:35 -0700 Subject: [PATCH 4/6] Upgrade samples to compiler 1.3.0-rc02 --- .../example/crane/buildsrc/Dependencies.kt | 4 ++-- JetNews/build.gradle | 4 ++-- .../jetcaster/buildsrc/dependencies.kt | 4 ++-- .../compose/jetchat/buildsrc/dependencies.kt | 4 ++-- .../example/jetsnack/buildsrc/Dependencies.kt | 4 ++-- .../jetsurvey/buildsrc/dependencies.kt | 4 ++-- .../com/example/owl/buildsrc/Dependencies.kt | 4 ++-- Reply/build.gradle | 6 ++--- scripts/upgrade_samples.sh | 24 ++++++++++++++++++- 9 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt index 67a43cb5c..25d226775 100644 --- a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt +++ b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt @@ -37,7 +37,7 @@ object Libs { } object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -57,7 +57,7 @@ object Libs { const val appcompat = "androidx.appcompat:appcompat:1.4.1" object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/JetNews/build.gradle b/JetNews/build.gradle index c4be01908..5878f129e 100644 --- a/JetNews/build.gradle +++ b/JetNews/build.gradle @@ -15,8 +15,8 @@ */ buildscript { - ext.kotlin_version = '1.7.0' - ext.compose_compiler_version = '1.2.0' + ext.kotlin_version = '1.7.10' + ext.compose_compiler_version = '1.3.0-rc02' ext.compose_version = '1.3.0-alpha02' ext.compose_snapshot_version = '' ext.coroutines_version = '1.6.0' diff --git a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt index 9e5377b31..2f6c36373 100644 --- a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt +++ b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt @@ -30,7 +30,7 @@ object Libs { } object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -69,7 +69,7 @@ object Libs { } object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt index de0e5c73c..14cd9b11d 100644 --- a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt +++ b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt @@ -29,7 +29,7 @@ object Libs { const val material3 = "com.google.android.material:material:1.6.0-alpha03" object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -51,7 +51,7 @@ object Libs { } object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt index d3f3eacb7..d5b8cbcd5 100644 --- a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt +++ b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt @@ -30,7 +30,7 @@ object Libs { } object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -47,7 +47,7 @@ object Libs { const val coreKtx = "androidx.core:core-ktx:1.7.0" object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt index 5d10b2dea..dcae8b2c8 100644 --- a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt +++ b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt @@ -32,7 +32,7 @@ object Libs { } object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -60,7 +60,7 @@ object Libs { } object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt index f844a0c03..39ff4bb47 100644 --- a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt +++ b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt @@ -22,7 +22,7 @@ object Versions { object Libs { const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" object Kotlin { - private const val version = "1.7.0" + private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -45,7 +45,7 @@ object Libs { const val activityCompose = "androidx.activity:activity-compose:1.4.0" } object Compose { - const val compilerVersion = "1.2.0" + const val compilerVersion = "1.3.0-rc02" const val snapshot = "" const val version = "1.3.0-alpha02" diff --git a/Reply/build.gradle b/Reply/build.gradle index 19c487783..951597515 100644 --- a/Reply/build.gradle +++ b/Reply/build.gradle @@ -17,10 +17,10 @@ buildscript { // Extracted for updating via scripts/upgrade_samples.sh ext.compose_version = '1.3.0-alpha02' - + ext.compose_compiler_version = '1.3.0-rc02' + ext.kotlin_version = '1.7.10' + ext { - kotlin_version = '1.7.0' - compose_compiler_version = '1.2.0' material3_version = "1.0.0-alpha14" coroutines_version = '1.6.0' agp_version = '7.2.1' diff --git a/scripts/upgrade_samples.sh b/scripts/upgrade_samples.sh index 4adbf3a3a..0b4f19c01 100755 --- a/scripts/upgrade_samples.sh +++ b/scripts/upgrade_samples.sh @@ -36,6 +36,12 @@ fi echo "Version to change Compose to (e.g 1.2.0-alpha06): "; read compose_version; +echo "Version to change Compose Compiler to (e.g 1.2.0): "; +read compose_compiler_version; + +echo "Version to change Kotlin to (e.g 1.7.10): "; +read kotlin_version; + echo "Snapshot ID: (Blank for none)"; read snapshot_version; @@ -61,12 +67,19 @@ fi for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do COMPOSE_BLOCK=false; ACCOMPANIST_BLOCK=false; + KOTLIN_BLOCK=false; MADE_CHANGE=false; TEMP_FILENAME="${DEPENDENCIES_FILE}_new"; while IFS= read -r line; do if [[ $line == *"val version ="* && "$compose_version" != "" ]] && $COMPOSE_BLOCK = true; then echo "$line" | sed -En 's/".*"/"'$compose_version'"/p' MADE_CHANGE=true; + elif [[ $line == *"val compilerVersion ="* && "$compose_compiler_version" != "" ]] && $COMPOSE_BLOCK = true; then + echo "$line" | sed -En 's/".*"/"'$compose_compiler_version'"/p' + MADE_CHANGE=true; + elif [[ $line == *"val version ="* && "$kotlin_version" != "" ]] && $KOTLIN_BLOCK = true; then + echo "$line" | sed -En 's/".*"/"'$kotlin_version'"/p' + MADE_CHANGE=true; elif [[ $line == *"val snapshot ="* ]] && $COMPOSE_BLOCK = true; then echo "$line" | sed -En 's/".*"/"'$snapshot_version'"/p' MADE_CHANGE=true; @@ -84,9 +97,12 @@ for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do COMPOSE_BLOCK=true; elif [[ $line == *"object Accompanist {"* ]]; then ACCOMPANIST_BLOCK=true; - elif [[ $line == *"}"* ]]; then + elif [[ $line == *"object Kotlin {"* ]]; then + KOTLIN_BLOCK=true; + elif [[ $line == *"}"* ]] || [[ $line == *"object Coroutines {"* ]]; then COMPOSE_BLOCK=false; ACCOMPANIST_BLOCK=false; + KOTLIN_BLOCK=false; fi echo "$line"; fi @@ -108,6 +124,12 @@ for DEPENDENCIES_FILE in `find . -type f -iname "build.gradle"` ; do if [[ $line == *"ext.compose_version ="* && "$compose_version" != "" ]]; then echo "$line" | sed -En "s/\'.*'/\'$compose_version\'/p" MADE_CHANGE=true; + elif [[ $line == *"ext.compose_compiler_version ="* && "$compose_compiler_version" != "" ]]; then + echo "$line" | sed -En "s/\'.*'/\'$compose_compiler_version\'/p" + MADE_CHANGE=true; + elif [[ $line == *"ext.kotlin_version ="* && "$kotlin_version" != "" ]]; then + echo "$line" | sed -En "s/\'.*'/\'$kotlin_version\'/p" + MADE_CHANGE=true; elif [[ $line == *"ext.compose_snapshot_version ="* ]]; then echo "$line" | sed -En "s/\'.*'/\'$snapshot_version\'/p" MADE_CHANGE=true; From 69f4ea766a3323a992774cd1a676542cbd1f48c9 Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Fri, 12 Aug 2022 15:14:09 +0100 Subject: [PATCH 5/6] Update compose-latest | Compose 1.3.0-alpha03 | Compiler 1.3.0 | Kotlin 1.7.10 (#925) * Update versions * Fix review comments --- Crane/app/build.gradle | 8 +-- .../example/crane/buildsrc/Dependencies.kt | 16 ++--- JetNews/app/build.gradle | 4 +- JetNews/build.gradle | 8 +-- Jetcaster/app/build.gradle | 4 +- .../jetcaster/buildsrc/dependencies.kt | 8 +-- Jetchat/app/build.gradle | 4 +- .../compose/jetchat/buildsrc/dependencies.kt | 6 +- Jetsnack/app/build.gradle | 4 +- .../example/jetsnack/buildsrc/Dependencies.kt | 8 +-- Jetsurvey/app/build.gradle | 4 +- .../jetsurvey/buildsrc/dependencies.kt | 8 +-- Owl/app/build.gradle | 4 +- .../com/example/owl/buildsrc/Dependencies.kt | 6 +- Reply/app/build.gradle | 4 +- Reply/build.gradle | 6 +- scripts/upgrade_samples.sh | 61 ++++++++++++------- 17 files changed, 91 insertions(+), 72 deletions(-) diff --git a/Crane/app/build.gradle b/Crane/app/build.gradle index d50f679b5..d5a80fe54 100644 --- a/Crane/app/build.gradle +++ b/Crane/app/build.gradle @@ -25,11 +25,11 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId "androidx.compose.samples.crane" minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName "1.0" vectorDrawables.useSupportLibrary = true @@ -104,7 +104,7 @@ android { dependencies { implementation Libs.Kotlin.stdlib - implementation Libs.Kotlin.Coroutines.android + implementation Libs.Coroutines.android implementation Libs.GoogleMaps.maps implementation Libs.GoogleMaps.composeMaps constraints { @@ -144,7 +144,7 @@ dependencies { androidTestImplementation Libs.AndroidX.Test.espressoCore androidTestImplementation Libs.AndroidX.Test.rules androidTestImplementation Libs.AndroidX.Test.Ext.junit - androidTestImplementation Libs.Kotlin.Coroutines.test + androidTestImplementation Libs.Coroutines.test androidTestImplementation Libs.AndroidX.Compose.uiTest androidTestImplementation Libs.Hilt.android androidTestImplementation Libs.Hilt.testing diff --git a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt index 25d226775..13ae025f3 100644 --- a/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt +++ b/Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt @@ -21,7 +21,7 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" const val secretsGradlePlugin = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" const val ktLint = "com.pinterest:ktlint:${Versions.ktlint}" @@ -41,12 +41,12 @@ object Libs { const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" + } - object Coroutines { - private const val version = "1.6.0" - const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version" - const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$version" - } + object Coroutines { + private const val version = "1.6.0" + const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version" + const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$version" } object AndroidX { @@ -57,9 +57,9 @@ object Libs { const val appcompat = "androidx.appcompat:appcompat:1.4.1" object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" const val runtime = "androidx.compose.runtime:runtime:$version" const val runtimeLivedata = "androidx.compose.runtime:runtime-livedata:$version" diff --git a/JetNews/app/build.gradle b/JetNews/app/build.gradle index d1bd45cd8..0b06c3221 100644 --- a/JetNews/app/build.gradle +++ b/JetNews/app/build.gradle @@ -20,11 +20,11 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId 'com.example.jetnews' minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName '1.0' vectorDrawables.useSupportLibrary = true diff --git a/JetNews/build.gradle b/JetNews/build.gradle index 5878f129e..afa1322f6 100644 --- a/JetNews/build.gradle +++ b/JetNews/build.gradle @@ -16,11 +16,11 @@ buildscript { ext.kotlin_version = '1.7.10' - ext.compose_compiler_version = '1.3.0-rc02' - ext.compose_version = '1.3.0-alpha02' + ext.compose_compiler_version = '1.3.0' + ext.compose_version = '1.3.0-alpha03' ext.compose_snapshot_version = '' ext.coroutines_version = '1.6.0' - ext.accompanist_version = '0.26.0-alpha' + ext.accompanist_version = '0.26.1-alpha' repositories { google() @@ -29,7 +29,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/Jetcaster/app/build.gradle b/Jetcaster/app/build.gradle index 1855228ac..d11671637 100644 --- a/Jetcaster/app/build.gradle +++ b/Jetcaster/app/build.gradle @@ -28,12 +28,12 @@ kapt { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId 'com.example.jetcaster' minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName '1.0' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt index 2f6c36373..ce2175c1f 100644 --- a/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt +++ b/Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt @@ -21,11 +21,11 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" const val jdkDesugar = "com.android.tools:desugar_jdk_libs:1.1.5" object Accompanist { - const val version = "0.26.0-alpha" + const val version = "0.26.1-alpha" const val pager = "com.google.accompanist:accompanist-pager:$version" } @@ -69,9 +69,9 @@ object Libs { } object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" @get:JvmStatic val snapshotUrl: String diff --git a/Jetchat/app/build.gradle b/Jetchat/app/build.gradle index f1c2afedc..8d0560c73 100644 --- a/Jetchat/app/build.gradle +++ b/Jetchat/app/build.gradle @@ -22,12 +22,12 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId "com.example.compose.jetchat" minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName '1.0' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt index 14cd9b11d..09251e6a9 100644 --- a/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt +++ b/Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt @@ -21,7 +21,7 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" const val jdkDesugar = "com.android.tools:desugar_jdk_libs:1.1.5" const val junit = "junit:junit:4.13" @@ -51,9 +51,9 @@ object Libs { } object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" const val foundation = "androidx.compose.foundation:foundation:$version" const val layout = "androidx.compose.foundation:foundation-layout:$version" diff --git a/Jetsnack/app/build.gradle b/Jetsnack/app/build.gradle index 469e5ceae..2aa413d34 100644 --- a/Jetsnack/app/build.gradle +++ b/Jetsnack/app/build.gradle @@ -23,12 +23,12 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId 'com.example.jetsnack' minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName '1.0' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt index d5b8cbcd5..9b602e5a5 100644 --- a/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt +++ b/Jetsnack/buildSrc/src/main/java/com/example/jetsnack/buildsrc/Dependencies.kt @@ -21,10 +21,10 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" object Accompanist { - const val version = "0.26.0-alpha" + const val version = "0.26.1-alpha" const val systemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:$version" const val flowlayouts = "com.google.accompanist:accompanist-flowlayout:$version" } @@ -47,9 +47,9 @@ object Libs { const val coreKtx = "androidx.core:core-ktx:1.7.0" object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" const val foundation = "androidx.compose.foundation:foundation:${version}" const val layout = "androidx.compose.foundation:foundation-layout:${version}" diff --git a/Jetsurvey/app/build.gradle b/Jetsurvey/app/build.gradle index e3cefdcf9..845b38832 100644 --- a/Jetsurvey/app/build.gradle +++ b/Jetsurvey/app/build.gradle @@ -21,12 +21,12 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId "com.example.compose.jetsurvey" minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt index dcae8b2c8..76011cbd2 100644 --- a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt +++ b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt @@ -21,13 +21,13 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" const val jdkDesugar = "com.android.tools:desugar_jdk_libs:1.1.5" const val junit = "junit:junit:4.13.2" object Accompanist { - const val version = "0.26.0-alpha" + const val version = "0.26.1-alpha" const val permissions = "com.google.accompanist:accompanist-permissions:$version" } @@ -60,9 +60,9 @@ object Libs { } object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" @get:JvmStatic val snapshotUrl: String diff --git a/Owl/app/build.gradle b/Owl/app/build.gradle index f519729ae..7ad3c34dd 100644 --- a/Owl/app/build.gradle +++ b/Owl/app/build.gradle @@ -22,11 +22,11 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId 'com.example.owl' minSdkVersion 21 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName '1.0' vectorDrawables.useSupportLibrary true diff --git a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt index 39ff4bb47..433f57992 100644 --- a/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt +++ b/Owl/buildSrc/src/main/java/com/example/owl/buildsrc/Dependencies.kt @@ -20,7 +20,7 @@ object Versions { const val ktlint = "0.45.2" } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.1" + const val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2" object Kotlin { private const val version = "1.7.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" @@ -45,9 +45,9 @@ object Libs { const val activityCompose = "androidx.activity:activity-compose:1.4.0" } object Compose { - const val compilerVersion = "1.3.0-rc02" + const val compilerVersion = "1.3.0" const val snapshot = "" - const val version = "1.3.0-alpha02" + const val version = "1.3.0-alpha03" const val animation = "androidx.compose.animation:animation:$version" const val foundation = "androidx.compose.foundation:foundation:$version" diff --git a/Reply/app/build.gradle b/Reply/app/build.gradle index 0930c2f27..6c29e8889 100644 --- a/Reply/app/build.gradle +++ b/Reply/app/build.gradle @@ -20,12 +20,12 @@ plugins { } android { - compileSdk 32 + compileSdk 33 defaultConfig { applicationId "com.example.reply" minSdk 21 - targetSdk 32 + targetSdk 33 versionCode 1 versionName "1.0" diff --git a/Reply/build.gradle b/Reply/build.gradle index 951597515..ecc2ee2ee 100644 --- a/Reply/build.gradle +++ b/Reply/build.gradle @@ -16,14 +16,14 @@ buildscript { // Extracted for updating via scripts/upgrade_samples.sh - ext.compose_version = '1.3.0-alpha02' - ext.compose_compiler_version = '1.3.0-rc02' + ext.compose_version = '1.3.0-alpha03' + ext.compose_compiler_version = '1.3.0' ext.kotlin_version = '1.7.10' ext { material3_version = "1.0.0-alpha14" coroutines_version = '1.6.0' - agp_version = '7.2.1' + agp_version = '7.2.2' } } diff --git a/scripts/upgrade_samples.sh b/scripts/upgrade_samples.sh index 0b4f19c01..92aa113e1 100755 --- a/scripts/upgrade_samples.sh +++ b/scripts/upgrade_samples.sh @@ -27,7 +27,7 @@ set -e # Check for clean git status if [[ `git status --porcelain` ]]; then - read -r -p "You have uncommited git changes. Are you sure you want to continue? [y/N] " response + read -r -p "You have uncommited git changes. Are you sure you want to continue? [Y/n] " response if [[ "$response" =~ ^([nN])$ ]]; then exit 0; fi @@ -36,21 +36,28 @@ fi echo "Version to change Compose to (e.g 1.2.0-alpha06): "; read compose_version; -echo "Version to change Compose Compiler to (e.g 1.2.0): "; +echo "Snapshot ID: (Blank for none)"; +read snapshot_version; + +echo "Version to change Compose Compiler to (e.g 1.3.0): "; read compose_compiler_version; -echo "Version to change Kotlin to (e.g 1.7.10): "; -read kotlin_version; +echo "Compiler snapshot ID: (Blank for none)"; +read compiler_snapshot_version; -echo "Snapshot ID: (Blank for none)"; -read snapshot_version; +echo "Each Compose Compiler version is linked to a Kotlin version, see: https://developer.android.com/jetpack/androidx/releases/compose-kotlin#pre-release_kotlin_compatibility" +echo "Version to change Kotlin to (e.g. 1.7.10): "; +read kotlin_version; +echo "Find Spotless Gradle releases at: https://github.com/diffplug/spotless/tags" echo "Version to change Spotless to (e.g 6.4.2): "; read spotless_version; +echo "Find ktlint releases at: https://github.com/pinterest/ktlint/tags" echo "Version to change ktlint to (e.g 0.45.2): "; read ktlint_version; +echo "Find Accompanist releases at: https://google.github.io/accompanist/#compose-versions" echo "Version to change Accompanist to (e.g 0.24.9-beta): "; read accompanist_version; @@ -63,6 +70,12 @@ else echo "Changing Compose version to $compose_version Snapshot $snapshot_version" fi +if [ -z "$compiler_snapshot_version" ]; then + echo "Changing Compose Compiler version to $compose_compiler_version" +else + echo "Changing Compose Compiler version to $compose_compiler_version Snapshot $compiler_snapshot_version" +fi + # Change Dependencies.kt versions for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do COMPOSE_BLOCK=false; @@ -77,12 +90,15 @@ for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do elif [[ $line == *"val compilerVersion ="* && "$compose_compiler_version" != "" ]] && $COMPOSE_BLOCK = true; then echo "$line" | sed -En 's/".*"/"'$compose_compiler_version'"/p' MADE_CHANGE=true; - elif [[ $line == *"val version ="* && "$kotlin_version" != "" ]] && $KOTLIN_BLOCK = true; then - echo "$line" | sed -En 's/".*"/"'$kotlin_version'"/p' + elif [[ $line == *"val compilerSnapshot ="* ]] && $COMPOSE_BLOCK = true; then + echo "$line" | sed -En 's/".*"/"'$compiler_snapshot_version'"/p' MADE_CHANGE=true; elif [[ $line == *"val snapshot ="* ]] && $COMPOSE_BLOCK = true; then echo "$line" | sed -En 's/".*"/"'$snapshot_version'"/p' MADE_CHANGE=true; + elif [[ $line == *"val version ="* && "$kotlin_version" != "" ]] && $KOTLIN_BLOCK = true; then + echo "$line" | sed -En 's/".*"/"'$kotlin_version'"/p' + MADE_CHANGE=true; elif [[ $line == *"val version ="* && "$accompanist_version" != "" ]] && $ACCOMPANIST_BLOCK = true; then echo "$line" | sed -En 's/".*"/"'$accompanist_version'"/p' MADE_CHANGE=true; @@ -90,8 +106,8 @@ for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do echo "$line" | sed -En 's/".*"/"'$ktlint_version'"/p' MADE_CHANGE=true; elif [[ $line == *"val androidGradlePlugin ="* && "$androidGradlePlugin_version" != "" ]]; then - echo "$line" | sed -En 's/".*"/"com.android.tools.build:gradle:'$androidGradlePlugin_version'"/p' - MADE_CHANGE=true; + echo "$line" | sed -En 's/".*"/"com.android.tools.build:gradle:'$androidGradlePlugin_version'"/p' + MADE_CHANGE=true; else if [[ $line == *"object Compose {"* ]]; then COMPOSE_BLOCK=true; @@ -99,7 +115,7 @@ for DEPENDENCIES_FILE in `find . -type f -iname "dependencies.kt"` ; do ACCOMPANIST_BLOCK=true; elif [[ $line == *"object Kotlin {"* ]]; then KOTLIN_BLOCK=true; - elif [[ $line == *"}"* ]] || [[ $line == *"object Coroutines {"* ]]; then + elif [[ $line == *"}"* ]]; then COMPOSE_BLOCK=false; ACCOMPANIST_BLOCK=false; KOTLIN_BLOCK=false; @@ -122,25 +138,28 @@ for DEPENDENCIES_FILE in `find . -type f -iname "build.gradle"` ; do TEMP_FILENAME="${DEPENDENCIES_FILE}_new"; while IFS= read -r line; do if [[ $line == *"ext.compose_version ="* && "$compose_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'$compose_version\'/p" + echo "$line" | sed -En "s/'.*'/'$compose_version'/p" + MADE_CHANGE=true; + elif [[ $line == *"ext.compose_snapshot_version ="* ]]; then + echo "$line" | sed -En "s/'.*'/'$snapshot_version'/p" MADE_CHANGE=true; elif [[ $line == *"ext.compose_compiler_version ="* && "$compose_compiler_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'$compose_compiler_version\'/p" + echo "$line" | sed -En "s/'.*'/'$compose_compiler_version'/p" MADE_CHANGE=true; - elif [[ $line == *"ext.kotlin_version ="* && "$kotlin_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'$kotlin_version\'/p" + elif [[ $line == *"ext.compose_compiler_snapshot_version ="* ]]; then + echo "$line" | sed -En "s/'.*'/'$compiler_snapshot_version'/p" MADE_CHANGE=true; - elif [[ $line == *"ext.compose_snapshot_version ="* ]]; then - echo "$line" | sed -En "s/\'.*'/\'$snapshot_version\'/p" + elif [[ $line == *"ext.kotlin_version ="* ]]; then + echo "$line" | sed -En "s/'.*'/'$kotlin_version'/p" MADE_CHANGE=true; elif [[ $line == *"ext.accompanist_version ="* && "$accompanist_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'$accompanist_version\'/p" + echo "$line" | sed -En "s/'.*'/'$accompanist_version'/p" MADE_CHANGE=true; - elif [[ $line == *"ext.androidGradlePlugin_version ="* && "$androidGradlePlugin_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'com.android.tools.build:gradle:$androidGradlePlugin_version\'/p" + elif [[ $line == *"ext.agp_version ="* && "$androidGradlePlugin_version" != "" ]]; then + echo "$line" | sed -En "s/'.*'/'$androidGradlePlugin_version'/p" MADE_CHANGE=true; elif [[ $line == *"'com.diffplug.spotless' version"* && "$spotless_version" != "" ]]; then - echo "$line" | sed -En "s/\'.*'/\'com.diffplug.spotless\' version \'$spotless_version\'/p" + echo "$line" | sed -En "s/'.*'/'com.diffplug.spotless' version '$spotless_version'/p" MADE_CHANGE=true; elif [[ $line == *"ktlint(\""* && "$ktlint_version" != "" ]]; then echo "$line" | sed -En 's/".*"/"'$ktlint_version'"/p' From 9302ed065449f2c78c9970e1ac6ccc999a059d17 Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Mon, 15 Aug 2022 15:42:03 +0100 Subject: [PATCH 6/6] [compose-latest Crane] Bugfix for destinations not found in Crane (#939) * [Crane] Fix destinations not in list issue. --- .../samples/crane/details/CityMapViewTests.kt | 3 ++- .../crane/details/DetailsContentTests.kt | 5 +--- .../compose/samples/crane/data/Cities.kt | 5 ++++ .../crane/data/DestinationsLocalDataSource.kt | 7 ++++- .../crane/data/DestinationsRepository.kt | 7 ++--- .../samples/crane/details/DetailsActivity.kt | 27 +++++++++---------- .../samples/crane/details/DetailsViewModel.kt | 4 +-- .../compose/samples/crane/home/CraneHome.kt | 2 +- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/CityMapViewTests.kt b/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/CityMapViewTests.kt index 95a9c9e2a..b0a45d055 100644 --- a/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/CityMapViewTests.kt +++ b/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/CityMapViewTests.kt @@ -17,6 +17,7 @@ package androidx.compose.samples.crane.details import androidx.compose.foundation.layout.Column +import androidx.compose.samples.crane.data.City import androidx.compose.samples.crane.data.DestinationsRepository import androidx.compose.samples.crane.data.ExploreModel import androidx.compose.samples.crane.data.MADRID @@ -47,7 +48,7 @@ class CityMapViewTests { @Inject lateinit var destinationsRepository: DestinationsRepository - private lateinit var cityDetails: ExploreModel + private lateinit var cityDetails: City private val city = MADRID private val testExploreModel = ExploreModel(city, "description", "imageUrl") diff --git a/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/DetailsContentTests.kt b/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/DetailsContentTests.kt index fe60c9457..4d9d8121d 100644 --- a/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/DetailsContentTests.kt +++ b/Crane/app/src/androidTest/java/androidx/compose/samples/crane/details/DetailsContentTests.kt @@ -17,7 +17,6 @@ package androidx.compose.samples.crane.details import androidx.compose.material.Surface -import androidx.compose.samples.crane.data.ExploreModel import androidx.compose.samples.crane.data.MADRID import androidx.compose.samples.crane.ui.CraneTheme import androidx.compose.ui.test.assertIsDisplayed @@ -32,7 +31,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class DetailsContentTests { private val city = MADRID - private val testExploreModel = ExploreModel(city, "description", "imageUrl") @get:Rule val composeTestRule = createComposeRule() @@ -42,7 +40,7 @@ class DetailsContentTests { composeTestRule.setContent { CraneTheme { Surface { - DetailsContent(exploreModel = testExploreModel) + DetailsContent(city = city) } } } @@ -51,6 +49,5 @@ class DetailsContentTests { @Test fun detailsScreen_detailsDisplayed() { composeTestRule.onNodeWithText(city.nameToDisplay).assertIsDisplayed() - composeTestRule.onNodeWithText(testExploreModel.description).assertIsDisplayed() } } diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/data/Cities.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/data/Cities.kt index 9ae8efad8..09213fe97 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/data/Cities.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/data/Cities.kt @@ -113,3 +113,8 @@ val CRETE = City( latitude = "35.2401", longitude = "24.8093" ) + +val listCities = listOf( + ROME, GRANADA, WASHINGTONDC, BARCELONA, CRETE, KHUMBUVALLEY, BIGSUR, + BALI, ASPEN, MADRID, NAPLES, DALLAS, CORDOBA, BIGSUR, MALDIVAS +) diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsLocalDataSource.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsLocalDataSource.kt index bb5d17918..f7e5e96d8 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsLocalDataSource.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsLocalDataSource.kt @@ -148,6 +148,11 @@ class DestinationsLocalDataSource @Inject constructor() { city = CRETE, description = "Nonstop - 1h 50m+", imageUrl = "https://images.unsplash.com/photo-1486575008575-27670acb58db?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=$DEFAULT_IMAGE_WIDTH" - ) + ), + ExploreModel( + city = NAPLES, + description = "1286 Restaurants", + imageUrl = "https://images.unsplash.com/photo-1534308983496-4fabb1a015ee?ixlib=rb-1.2.1&auto=format&fit=crop&w=$DEFAULT_IMAGE_WIDTH" + ), ) } diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsRepository.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsRepository.kt index df419033a..674ba219b 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsRepository.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/data/DestinationsRepository.kt @@ -24,10 +24,11 @@ class DestinationsRepository @Inject constructor( val destinations: List = destinationsLocalDataSource.craneDestinations val hotels: List = destinationsLocalDataSource.craneHotels val restaurants: List = destinationsLocalDataSource.craneRestaurants + val cities: List = listCities - fun getDestination(cityName: String): ExploreModel? { - return destinationsLocalDataSource.craneDestinations.firstOrNull { - it.city.name == cityName + fun getDestination(cityName: String): City? { + return cities.firstOrNull { + it.name == cityName } } } diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsActivity.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsActivity.kt index 46c53d6a1..6807af679 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsActivity.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsActivity.kt @@ -19,6 +19,7 @@ package androidx.compose.samples.crane.details import android.content.Context import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.annotation.VisibleForTesting @@ -46,6 +47,7 @@ import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.samples.crane.base.Result +import androidx.compose.samples.crane.data.City import androidx.compose.samples.crane.data.ExploreModel import androidx.compose.samples.crane.ui.CraneTheme import androidx.compose.ui.Alignment @@ -91,7 +93,10 @@ class DetailsActivity : ComponentActivity() { CraneTheme { Surface { DetailsScreen( - onErrorLoading = { finish() }, + onErrorLoading = { + Log.e("DetailsActivity", "Error loading screen") + finish() + }, modifier = Modifier .statusBarsPadding() .navigationBarsPadding() @@ -103,7 +108,7 @@ class DetailsActivity : ComponentActivity() { } private data class DetailsScreenUiState( - val exploreModel: ExploreModel? = null, + val city: City? = null, val isLoading: Boolean = false, val throwError: Boolean = false ) @@ -121,7 +126,7 @@ fun DetailsScreen( initialValue = DetailsScreenUiState(isLoading = true) ) { val cityDetailsResult = viewModel.cityDetails - value = if (cityDetailsResult is Result.Success) { + value = if (cityDetailsResult is Result.Success) { DetailsScreenUiState(cityDetailsResult.data) } else { DetailsScreenUiState(throwError = true) @@ -130,8 +135,8 @@ fun DetailsScreen( Crossfade(targetState = uiState, modifier) { currentUiState -> when { - currentUiState.exploreModel != null -> { - DetailsContent(currentUiState.exploreModel, Modifier.fillMaxSize()) + currentUiState.city != null -> { + DetailsContent(currentUiState.city, Modifier.fillMaxSize()) } currentUiState.isLoading -> { Box(Modifier.fillMaxSize()) { @@ -150,25 +155,19 @@ fun DetailsScreen( @Composable fun DetailsContent( - exploreModel: ExploreModel, + city: City, modifier: Modifier = Modifier ) { Column(modifier = modifier, verticalArrangement = Arrangement.Center) { Spacer(Modifier.height(32.dp)) Text( modifier = Modifier.align(Alignment.CenterHorizontally), - text = exploreModel.city.nameToDisplay, + text = city.nameToDisplay, style = MaterialTheme.typography.h4, textAlign = TextAlign.Center ) - Text( - modifier = Modifier.align(Alignment.CenterHorizontally), - text = exploreModel.description, - style = MaterialTheme.typography.h6, - textAlign = TextAlign.Center - ) Spacer(Modifier.height(16.dp)) - CityMapView(exploreModel.city.latitude, exploreModel.city.longitude) + CityMapView(city.latitude, city.longitude) } } diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsViewModel.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsViewModel.kt index 1d52b524e..d1c1983d6 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsViewModel.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/details/DetailsViewModel.kt @@ -17,8 +17,8 @@ package androidx.compose.samples.crane.details import androidx.compose.samples.crane.base.Result +import androidx.compose.samples.crane.data.City import androidx.compose.samples.crane.data.DestinationsRepository -import androidx.compose.samples.crane.data.ExploreModel import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel @@ -32,7 +32,7 @@ class DetailsViewModel @Inject constructor( private val cityName = savedStateHandle.get(KEY_ARG_DETAILS_CITY_NAME)!! - val cityDetails: Result + val cityDetails: Result get() { val destination = destinationsRepository.getDestination(cityName) return if (destination != null) { diff --git a/Crane/app/src/main/java/androidx/compose/samples/crane/home/CraneHome.kt b/Crane/app/src/main/java/androidx/compose/samples/crane/home/CraneHome.kt index 1bc421e52..c99ea5f90 100644 --- a/Crane/app/src/main/java/androidx/compose/samples/crane/home/CraneHome.kt +++ b/Crane/app/src/main/java/androidx/compose/samples/crane/home/CraneHome.kt @@ -207,7 +207,7 @@ private fun HomeTabBar( } } -private const val ANIMATED_CONTENT_ANIMATION_DURATION = 600 +private const val ANIMATED_CONTENT_ANIMATION_DURATION = 300 @OptIn(ExperimentalAnimationApi::class) @Composable private fun SearchContent(