diff --git a/Crane/app/build.gradle.kts b/Crane/app/build.gradle.kts index ac53f5f49a..21c6a5d736 100644 --- a/Crane/app/build.gradle.kts +++ b/Crane/app/build.gradle.kts @@ -98,6 +98,10 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) diff --git a/Crane/benchmark/build.gradle.kts b/Crane/benchmark/build.gradle.kts index 848492c471..cbc8356b4f 100644 --- a/Crane/benchmark/build.gradle.kts +++ b/Crane/benchmark/build.gradle.kts @@ -39,6 +39,9 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + implementation(libs.androidx.test.ext.junit) implementation(libs.androidx.test.espresso.core) implementation(libs.androidx.test.uiautomator) diff --git a/Crane/gradle/libs.versions.toml b/Crane/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Crane/gradle/libs.versions.toml +++ b/Crane/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/JetNews/app/build.gradle.kts b/JetNews/app/build.gradle.kts index 0b7a08cfcc..927401b234 100644 --- a/JetNews/app/build.gradle.kts +++ b/JetNews/app/build.gradle.kts @@ -94,33 +94,25 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) - // TODO: Replace when all samples use the same Material3 & Compose version - implementation("androidx.compose.animation:animation:1.3.0-beta03") - implementation("androidx.compose.foundation:foundation-layout:1.3.0-beta03") - implementation("androidx.compose.material:material-icons-extended:1.3.0-beta03") - implementation("androidx.compose.material3:material3:1.0.0-beta03") - implementation("androidx.compose.material3:material3-window-size-class:1.0.0-beta03") - implementation("androidx.compose.runtime:runtime-livedata:1.3.0-beta03") - implementation("androidx.compose.ui:ui-tooling-preview:1.3.0-beta03") - debugImplementation("androidx.compose.ui:ui-test-manifest:1.3.0-beta03") - debugImplementation("androidx.compose.ui:ui-tooling:1.3.0-beta03") -// implementation(libs.androidx.compose.animation) -// implementation(libs.androidx.compose.foundation.layout) -// implementation(libs.androidx.compose.material.iconsExtended) -// implementation(libs.androidx.compose.material3) -// implementation(libs.androidx.compose.materialWindow) -// implementation(libs.androidx.compose.runtime.livedata) -// implementation(libs.androidx.compose.ui.tooling.preview) -// debugImplementation(libs.androidx.compose.ui.test.manifest) -// debugImplementation(libs.androidx.compose.ui.tooling) - - implementation("com.google.accompanist:accompanist-swiperefresh:0.26.4-beta") - implementation("com.google.accompanist:accompanist-systemuicontroller:0.26.4-beta") -// implementation(libs.accompanist.swiperefresh) -// implementation(libs.accompanist.systemuicontroller) + implementation(libs.androidx.compose.animation) + implementation(libs.androidx.compose.foundation.layout) + implementation(libs.androidx.compose.material.iconsExtended) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.materialWindow) + implementation(libs.androidx.compose.runtime.livedata) + implementation(libs.androidx.compose.ui.tooling.preview) + debugImplementation(libs.androidx.compose.ui.test.manifest) + debugImplementation(libs.androidx.compose.ui.tooling) + + implementation(libs.accompanist.swiperefresh) + implementation(libs.accompanist.systemuicontroller) implementation(libs.androidx.appcompat) implementation(libs.androidx.activity.ktx) @@ -131,7 +123,7 @@ dependencies { implementation(libs.androidx.lifecycle.viewmodel.savedstate) implementation(libs.androidx.lifecycle.livedata.ktx) implementation(libs.androidx.lifecycle.viewModelCompose) - + implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.navigation.compose) implementation(libs.androidx.window) @@ -147,9 +139,7 @@ dependencies { androidTestImplementation(libs.androidx.compose.ui.test) androidTestImplementation(libs.androidx.compose.ui.test.junit4) // Robolectric dependencies - // TODO: Replace when all samples use the same Material3 & Compose version - implementation("androidx.compose.ui:ui-test-junit4:1.3.0-beta03") -// testImplementation(libs.androidx.compose.ui.test.junit4) + testImplementation(libs.androidx.compose.ui.test.junit4) testImplementation(libs.robolectric) } diff --git a/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeRoute.kt b/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeRoute.kt index b6617d932c..cf7907ba7e 100644 --- a/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeRoute.kt +++ b/JetNews/app/src/main/java/com/example/jetnews/ui/home/HomeRoute.kt @@ -21,10 +21,11 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.remember +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.example.jetnews.ui.article.ArticleScreen import com.example.jetnews.ui.home.HomeScreenType.ArticleDetails import com.example.jetnews.ui.home.HomeScreenType.Feed @@ -40,6 +41,7 @@ import com.example.jetnews.ui.home.HomeScreenType.FeedWithArticleDetails * @param openDrawer (event) request opening the app drawer * @param snackbarHostState (state) state for the [Scaffold] component on this screen */ +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun HomeRoute( homeViewModel: HomeViewModel, @@ -48,7 +50,7 @@ fun HomeRoute( snackbarHostState: SnackbarHostState = remember { SnackbarHostState() } ) { // UiState of the HomeScreen - val uiState by homeViewModel.uiState.collectAsState() + val uiState by homeViewModel.uiState.collectAsStateWithLifecycle() HomeRoute( uiState = uiState, diff --git a/JetNews/app/src/main/java/com/example/jetnews/ui/interests/InterestsScreen.kt b/JetNews/app/src/main/java/com/example/jetnews/ui/interests/InterestsScreen.kt index 20e0e7b8b0..00cf3ef3c0 100644 --- a/JetNews/app/src/main/java/com/example/jetnews/ui/interests/InterestsScreen.kt +++ b/JetNews/app/src/main/java/com/example/jetnews/ui/interests/InterestsScreen.kt @@ -51,7 +51,6 @@ import androidx.compose.material3.Tab import androidx.compose.material3.TabRow import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable @@ -69,6 +68,8 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.constrainHeight import androidx.compose.ui.unit.constrainWidth import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.example.jetnews.R import com.example.jetnews.data.Result import com.example.jetnews.data.interests.InterestSection @@ -166,15 +167,16 @@ fun InterestsScreen( * Remembers the content for each tab on the Interests screen * gathering application data from [InterestsViewModel] */ +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun rememberTabContent(interestsViewModel: InterestsViewModel): List { // UiState of the InterestsScreen - val uiState by interestsViewModel.uiState.collectAsState() + val uiState by interestsViewModel.uiState.collectAsStateWithLifecycle() // Describe the screen sections here since each section needs 2 states and 1 event. // Pass them to the stateless InterestsScreen using a tabContent. val topicsSection = TabContent(Sections.Topics) { - val selectedTopics by interestsViewModel.selectedTopics.collectAsState() + val selectedTopics by interestsViewModel.selectedTopics.collectAsStateWithLifecycle() TabWithSections( sections = uiState.topics, selectedTopics = selectedTopics, @@ -183,7 +185,7 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List } val peopleSection = TabContent(Sections.People) { - val selectedPeople by interestsViewModel.selectedPeople.collectAsState() + val selectedPeople by interestsViewModel.selectedPeople.collectAsStateWithLifecycle() TabWithTopics( topics = uiState.people, selectedTopics = selectedPeople, @@ -192,7 +194,8 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List } val publicationSection = TabContent(Sections.Publications) { - val selectedPublications by interestsViewModel.selectedPublications.collectAsState() + val selectedPublications by interestsViewModel.selectedPublications + .collectAsStateWithLifecycle() TabWithTopics( topics = uiState.publications, selectedTopics = selectedPublications, diff --git a/JetNews/gradle/libs.versions.toml b/JetNews/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/JetNews/gradle/libs.versions.toml +++ b/JetNews/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Jetcaster/README.md b/Jetcaster/README.md index f852131538..6e52c72bdb 100644 --- a/Jetcaster/README.md +++ b/Jetcaster/README.md @@ -64,11 +64,11 @@ Using the example of the home screen in the [`com.example.jetcaster.ui.home`](ap - The ViewModel is implemented as [`HomeViewModel`][homevm], which exposes a `StateFlow` for the UI to observe. - [`HomeViewState`][homevm] contains the complete view state for the home screen as an [`@Immutable`](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Immutable) `data class`. - - The Home Compose UI in [`Home.kt`][homeui] uses [`HomeViewModel`][homevm], and observes it's [`HomeViewState`][homevm] as Compose [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State), using [`collectAsState()`](https://developer.android.com/reference/kotlin/androidx/compose/package-summary#collectasstate): + - The Home Compose UI in [`Home.kt`][homeui] uses [`HomeViewModel`][homevm], and observes it's [`HomeViewState`][homevm] as Compose [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State), using [`collectAsStateWithLifecycle()`](https://developer.android.com/reference/kotlin/androidx/lifecycle/compose/package-summary#(kotlinx.coroutines.flow.StateFlow).collectAsStateWithLifecycle(androidx.lifecycle.LifecycleOwner,androidx.lifecycle.Lifecycle.State,kotlin.coroutines.CoroutineContext)): ``` kotlin val viewModel: HomeViewModel = viewModel() -val viewState by viewModel.state.collectAsState() +val viewState by viewModel.state.collectAsStateWithLifecycle() ``` This pattern is used across the different screens: diff --git a/Jetcaster/app/build.gradle.kts b/Jetcaster/app/build.gradle.kts index 29394e3d23..e9eff20130 100644 --- a/Jetcaster/app/build.gradle.kts +++ b/Jetcaster/app/build.gradle.kts @@ -87,6 +87,10 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) @@ -105,6 +109,7 @@ dependencies { implementation(libs.androidx.lifecycle.runtime) implementation(libs.androidx.lifecycle.viewModelCompose) + implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.navigation.compose) implementation(libs.androidx.window) diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt index c4e7683aa8..78d3b7ed5f 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -56,7 +56,6 @@ import androidx.compose.material.icons.filled.Search import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -68,6 +67,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import coil.compose.AsyncImage import com.example.jetcaster.R @@ -90,12 +91,13 @@ import java.time.Duration import java.time.LocalDateTime import java.time.OffsetDateTime +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun Home( navigateToPlayer: (String) -> Unit, viewModel: HomeViewModel = viewModel() ) { - val viewState by viewModel.state.collectAsState() + val viewState by viewModel.state.collectAsStateWithLifecycle() Surface(Modifier.fillMaxSize()) { HomeContent( featuredPodcasts = viewState.featuredPodcasts, diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt index e2cbe2b042..30337a599f 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt @@ -49,7 +49,6 @@ import androidx.compose.material.icons.rounded.PlayCircleFilled import androidx.compose.material.ripple.rememberRipple import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -68,6 +67,8 @@ import androidx.compose.ui.unit.dp import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.Dimension.Companion.fillToConstraints import androidx.constraintlayout.compose.Dimension.Companion.preferredWrapContent +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import coil.compose.AsyncImage import coil.request.ImageRequest @@ -85,6 +86,7 @@ import com.example.jetcaster.util.viewModelProviderFactoryOf import java.time.format.DateTimeFormatter import java.time.format.FormatStyle +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun PodcastCategory( categoryId: Long, @@ -101,7 +103,7 @@ fun PodcastCategory( factory = viewModelProviderFactoryOf { PodcastCategoryViewModel(categoryId) } ) - val viewState by viewModel.state.collectAsState() + val viewState by viewModel.state.collectAsStateWithLifecycle() /** * TODO: reset scroll position when category changes diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/discover/Discover.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/discover/Discover.kt index b2c872f0e6..d3fa5ceeb5 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/discover/Discover.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/discover/Discover.kt @@ -30,22 +30,24 @@ import androidx.compose.material.Tab import androidx.compose.material.TabPosition import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import com.example.jetcaster.data.Category import com.example.jetcaster.ui.home.category.PodcastCategory import com.example.jetcaster.ui.theme.Keyline1 +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun Discover( navigateToPlayer: (String) -> Unit, modifier: Modifier = Modifier ) { val viewModel: DiscoverViewModel = viewModel() - val viewState by viewModel.state.collectAsState() + val viewState by viewModel.state.collectAsStateWithLifecycle() val selectedCategory = viewState.selectedCategory diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index f35df88fce..f12f4a0b60 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -59,7 +59,6 @@ import androidx.compose.material.icons.rounded.PlayCircleFilled import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -77,6 +76,8 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.window.layout.FoldingFeature import coil.compose.AsyncImage import coil.request.ImageRequest @@ -94,6 +95,7 @@ import kotlinx.coroutines.flow.StateFlow /** * Stateful version of the Podcast player */ +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun PlayerScreen( viewModel: PlayerViewModel, @@ -101,7 +103,7 @@ fun PlayerScreen( onBackPress: () -> Unit ) { val uiState = viewModel.uiState - val devicePostureValue by devicePosture.collectAsState() + val devicePostureValue by devicePosture.collectAsStateWithLifecycle() PlayerScreen(uiState, devicePostureValue, onBackPress) } diff --git a/Jetcaster/gradle/libs.versions.toml b/Jetcaster/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Jetcaster/gradle/libs.versions.toml +++ b/Jetcaster/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Jetchat/app/build.gradle.kts b/Jetchat/app/build.gradle.kts index 2332845575..a6c0ebab2c 100644 --- a/Jetchat/app/build.gradle.kts +++ b/Jetchat/app/build.gradle.kts @@ -79,6 +79,10 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) diff --git a/Jetchat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt b/Jetchat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt index d6fff7d7f4..aae410cdc6 100644 --- a/Jetchat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt +++ b/Jetchat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt @@ -153,7 +153,10 @@ class ConversationTest { } private fun findJumpToBottom() = - composeTestRule.onNodeWithText(composeTestRule.activity.getString(R.string.jumpBottom)) + composeTestRule.onNodeWithText( + composeTestRule.activity.getString(R.string.jumpBottom), + useUnmergedTree = true + ) private fun openEmojiSelector() = composeTestRule diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/NavActivity.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/NavActivity.kt index 2f03f7ee71..78843674e3 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/NavActivity.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/NavActivity.kt @@ -63,9 +63,9 @@ class NavActivity : AppCompatActivity() { LocalBackPressedDispatcher provides this@NavActivity.onBackPressedDispatcher ) { val drawerState = rememberDrawerState(initialValue = Closed) - val drawerOpen by viewModel.drawerShouldBeOpened .collectAsStateWithLifecycle() + if (drawerOpen) { // Open drawer and reset state in VM. LaunchedEffect(Unit) { diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/AnimatingFabContent.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/AnimatingFabContent.kt index 629fbf8cba..d4617b6f85 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/AnimatingFabContent.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/AnimatingFabContent.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.Layout import androidx.compose.ui.util.lerp import kotlin.math.roundToInt @@ -42,7 +43,7 @@ fun AnimatingFabContent( extended: Boolean = true ) { val currentState = if (extended) ExpandableFabStates.Extended else ExpandableFabStates.Collapsed - val transition = updateTransition(currentState) + val transition = updateTransition(currentState, "fab_transition") val textOpacity by transition.animateFloat( transitionSpec = { @@ -58,9 +59,10 @@ fun AnimatingFabContent( durationMillis = (transitionDuration / 12f * 5).roundToInt() // 5 / 12 frames ) } - } - ) { progress -> - if (progress == ExpandableFabStates.Collapsed) { + }, + label = "fab_text_opacity" + ) { state -> + if (state == ExpandableFabStates.Collapsed) { 0f } else { 1f @@ -79,15 +81,17 @@ fun AnimatingFabContent( durationMillis = transitionDuration ) } - } - ) { progress -> - if (progress == ExpandableFabStates.Collapsed) { + }, + label = "fab_width_factor" + ) { state -> + if (state == ExpandableFabStates.Collapsed) { 0f } else { 1f } } - // Using functions instead of Floats here can improve performance, preventing recompositions. + // Deferring reads using lambdas instead of Floats here can improve performance, + // preventing recompositions. IconAndTextRow( icon, text, @@ -101,7 +105,7 @@ fun AnimatingFabContent( private fun IconAndTextRow( icon: @Composable () -> Unit, text: @Composable () -> Unit, - opacityProgress: () -> Float, // Functions instead of Floats, to slightly improve performance + opacityProgress: () -> Float, // Lambdas instead of Floats, to defer read widthProgress: () -> Float, modifier: Modifier ) { @@ -109,7 +113,7 @@ private fun IconAndTextRow( modifier = modifier, content = { icon() - Box(modifier = Modifier.alpha(opacityProgress())) { + Box(modifier = Modifier.graphicsLayer { alpha = opacityProgress() }) { text() } } diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatAppBar.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatAppBar.kt index 7369f44eef..9d221bd6fa 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatAppBar.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatAppBar.kt @@ -18,28 +18,23 @@ package com.example.compose.jetchat.components -import androidx.compose.animation.core.FastOutLinearInEasing -import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.lerp import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.example.compose.jetchat.R import com.example.compose.jetchat.theme.JetchatTheme +@OptIn(ExperimentalMaterial3Api::class) @Composable fun JetchatAppBar( modifier: Modifier = Modifier, @@ -48,37 +43,24 @@ fun JetchatAppBar( title: @Composable () -> Unit, actions: @Composable RowScope.() -> Unit = {} ) { - val backgroundColors = TopAppBarDefaults.centerAlignedTopAppBarColors() - val backgroundColor = lerp( - backgroundColors.containerColor(colorTransitionFraction = 0f).value, - backgroundColors.containerColor(colorTransitionFraction = 1f).value, - FastOutLinearInEasing.transform(scrollBehavior?.state?.overlappedFraction ?: 0f) + CenterAlignedTopAppBar( + modifier = modifier, + actions = actions, + title = title, + scrollBehavior = scrollBehavior, + navigationIcon = { + JetchatIcon( + contentDescription = stringResource(id = R.string.navigation_drawer_open), + modifier = Modifier + .size(64.dp) + .clickable(onClick = onNavIconPressed) + .padding(16.dp) + ) + } ) - - val foregroundColors = TopAppBarDefaults.centerAlignedTopAppBarColors( - containerColor = Color.Transparent, - scrolledContainerColor = Color.Transparent - ) - Box(modifier = Modifier.background(backgroundColor)) { - CenterAlignedTopAppBar( - modifier = modifier, - actions = actions, - title = title, - scrollBehavior = scrollBehavior, - colors = foregroundColors, - navigationIcon = { - JetchatIcon( - contentDescription = stringResource(id = R.string.navigation_drawer_open), - modifier = Modifier - .size(64.dp) - .clickable(onClick = onNavIconPressed) - .padding(16.dp) - ) - } - ) - } } +@OptIn(ExperimentalMaterial3Api::class) @Preview @Composable fun JetchatAppBarPreview() { @@ -87,6 +69,7 @@ fun JetchatAppBarPreview() { } } +@OptIn(ExperimentalMaterial3Api::class) @Preview @Composable fun JetchatAppBarPreviewDark() { diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatScaffold.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatScaffold.kt index 476e51cfe0..579074718b 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatScaffold.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/components/JetchatScaffold.kt @@ -19,6 +19,7 @@ package com.example.compose.jetchat.components import androidx.compose.material3.DrawerState import androidx.compose.material3.DrawerValue.Closed import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ModalDrawerSheet import androidx.compose.material3.ModalNavigationDrawer import androidx.compose.material3.rememberDrawerState import androidx.compose.runtime.Composable @@ -36,10 +37,12 @@ fun JetchatDrawer( ModalNavigationDrawer( drawerState = drawerState, drawerContent = { - JetchatDrawerContent( - onProfileClicked = onProfileClicked, - onChatClicked = onChatClicked - ) + ModalDrawerSheet { + JetchatDrawerContent( + onProfileClicked = onProfileClicked, + onChatClicked = onChatClicked + ) + } }, content = content ) diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt index 6f60f7b0ee..7097a61177 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt @@ -38,7 +38,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.paddingFrom import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars -import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState @@ -108,7 +107,7 @@ fun ConversationContent( val scrollState = rememberLazyListState() val topBarState = rememberTopAppBarState() - val scrollBehavior = remember { TopAppBarDefaults.pinnedScrollBehavior(topBarState) } + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(topBarState) val scope = rememberCoroutineScope() Surface(modifier = modifier) { @@ -148,8 +147,6 @@ fun ConversationContent( channelMembers = uiState.channelMembers, onNavIconPressed = onNavIconPressed, scrollBehavior = scrollBehavior, - // Use statusBarsPadding() to move the app bar content below the status bar - modifier = Modifier.statusBarsPadding(), ) } } diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/data/FakeData.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/data/FakeData.kt index fee5f9639c..9b85a8cc17 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/data/FakeData.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/data/FakeData.kt @@ -40,7 +40,7 @@ private val initialMessages = listOf( ), Message( "Taylor Brooks", - "@aliconors Take a look at the `Flow.collectAsState()` APIs", + "@aliconors Take a look at the `Flow.collectAsStateWithLifecycle()` APIs", "8:05 PM" ), Message( diff --git a/Jetchat/app/src/main/java/com/example/compose/jetchat/profile/Profile.kt b/Jetchat/app/src/main/java/com/example/compose/jetchat/profile/Profile.kt index 5f2f0db63d..0bc8c651ae 100644 --- a/Jetchat/app/src/main/java/com/example/compose/jetchat/profile/Profile.kt +++ b/Jetchat/app/src/main/java/com/example/compose/jetchat/profile/Profile.kt @@ -44,6 +44,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf @@ -104,8 +105,10 @@ fun ProfileScreen( UserInfoFields(userData, this@BoxWithConstraints.maxHeight) } } + + val fabExtended by remember { derivedStateOf { scrollState.value == 0 } } ProfileFab( - extended = scrollState.value == 0, + extended = fabExtended, userIsMe = userData.isMe(), modifier = Modifier .align(Alignment.BottomEnd) @@ -239,7 +242,6 @@ fun ProfileFab( modifier: Modifier = Modifier, onFabClicked: () -> Unit = { } ) { - key(userIsMe) { // Prevent multiple invocations to execute during composition FloatingActionButton( onClick = onFabClicked, @@ -267,7 +269,6 @@ fun ProfileFab( ) }, extended = extended - ) } } diff --git a/Jetchat/gradle/libs.versions.toml b/Jetchat/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Jetchat/gradle/libs.versions.toml +++ b/Jetchat/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Jetsnack/app/build.gradle.kts b/Jetsnack/app/build.gradle.kts index b45c904af4..eea238628e 100644 --- a/Jetsnack/app/build.gradle.kts +++ b/Jetsnack/app/build.gradle.kts @@ -92,12 +92,17 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) implementation(libs.androidx.core.ktx) implementation(libs.androidx.activity.compose) implementation(libs.androidx.lifecycle.viewModelCompose) + implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.navigation.compose) implementation(libs.androidx.constraintlayout.compose) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt index 9a6a636104..3b49a04244 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt @@ -53,7 +53,6 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.DeleteForever import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -70,6 +69,8 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.constraintlayout.compose.ChainStyle import androidx.constraintlayout.compose.ConstraintLayout +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import com.example.jetsnack.R import com.example.jetsnack.model.OrderLine @@ -86,13 +87,14 @@ import com.example.jetsnack.ui.theme.AlphaNearOpaque import com.example.jetsnack.ui.theme.JetsnackTheme import com.example.jetsnack.ui.utils.formatPrice +@OptIn(ExperimentalLifecycleComposeApi::class) @Composable fun Cart( onSnackClick: (Long) -> Unit, modifier: Modifier = Modifier, viewModel: CartViewModel = viewModel(factory = CartViewModel.provideFactory()) ) { - val orderLines by viewModel.orderLines.collectAsState() + val orderLines by viewModel.orderLines.collectAsStateWithLifecycle() val inspiredByCart = remember { SnackRepo.getInspiredByCart() } Cart( orderLines = orderLines, diff --git a/Jetsnack/gradle/libs.versions.toml b/Jetsnack/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Jetsnack/gradle/libs.versions.toml +++ b/Jetsnack/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Jetsurvey/app/build.gradle.kts b/Jetsurvey/app/build.gradle.kts index 4177a5dd50..ecab069b1e 100644 --- a/Jetsurvey/app/build.gradle.kts +++ b/Jetsurvey/app/build.gradle.kts @@ -60,6 +60,10 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt index 8264a27eea..c9a7726d5c 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt @@ -217,6 +217,9 @@ fun Password( PasswordVisualTransformation() }, isError = passwordState.showErrors(), + supportingText = { + passwordState.getError()?.let { error -> TextFieldError(textError = error) } + }, keyboardOptions = KeyboardOptions.Default.copy( imeAction = imeAction, keyboardType = KeyboardType.Password @@ -227,8 +230,6 @@ fun Password( } ), ) - - passwordState.getError()?.let { error -> TextFieldError(textError = error) } } /** diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt index acb1f5923e..36f6392f0e 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/survey/SurveyQuestions.kt @@ -79,7 +79,9 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.MultiplePermissionsState import com.google.accompanist.permissions.rememberMultiplePermissionsState import java.text.SimpleDateFormat -import java.util.* +import java.util.Calendar +import java.util.Locale +import java.util.TimeZone @OptIn(ExperimentalPermissionsApi::class) @Composable @@ -729,7 +731,6 @@ private fun SliderQuestion( mutableStateOf(answer?.answerValue ?: possibleAnswer.defaultValue) } Row(modifier = modifier) { - Slider( value = sliderPosition, onValueChange = { @@ -739,8 +740,8 @@ private fun SliderQuestion( valueRange = possibleAnswer.range, steps = possibleAnswer.steps, modifier = Modifier - .weight(1f) .padding(horizontal = 16.dp) + .weight(1f) ) } Row { diff --git a/Jetsurvey/gradle/libs.versions.toml b/Jetsurvey/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Jetsurvey/gradle/libs.versions.toml +++ b/Jetsurvey/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Owl/app/build.gradle.kts b/Owl/app/build.gradle.kts index 441a3b6115..6139390e73 100644 --- a/Owl/app/build.gradle.kts +++ b/Owl/app/build.gradle.kts @@ -94,6 +94,9 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) diff --git a/Owl/gradle/libs.versions.toml b/Owl/gradle/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/Owl/gradle/libs.versions.toml +++ b/Owl/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/Reply/app/build.gradle.kts b/Reply/app/build.gradle.kts index 5964a05e81..2af6c4dbcb 100644 --- a/Reply/app/build.gradle.kts +++ b/Reply/app/build.gradle.kts @@ -94,6 +94,10 @@ android { } dependencies { + val composeBom = platform(libs.androidx.compose.bom) + implementation(composeBom) + androidTestImplementation(composeBom) + implementation(libs.androidx.core.ktx) implementation(libs.kotlin.stdlib) implementation(libs.kotlinx.coroutines.android) @@ -110,6 +114,7 @@ dependencies { implementation(libs.androidx.lifecycle.runtime) implementation(libs.androidx.lifecycle.viewModelCompose) + implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.androidx.navigation.compose) implementation(libs.androidx.activity.compose) diff --git a/Reply/app/src/main/java/com/example/reply/ui/MainActivity.kt b/Reply/app/src/main/java/com/example/reply/ui/MainActivity.kt index 116fdd6775..b55b6ec0d4 100644 --- a/Reply/app/src/main/java/com/example/reply/ui/MainActivity.kt +++ b/Reply/app/src/main/java/com/example/reply/ui/MainActivity.kt @@ -24,11 +24,12 @@ import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSiz import androidx.compose.material3.windowsizeclass.WindowSizeClass import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.example.reply.data.local.LocalEmailsDataProvider import com.example.reply.ui.theme.ReplyTheme import com.google.accompanist.adaptive.calculateDisplayFeatures @@ -37,7 +38,7 @@ class MainActivity : ComponentActivity() { private val viewModel: ReplyHomeViewModel by viewModels() - @OptIn(ExperimentalMaterial3WindowSizeClassApi::class) + @OptIn(ExperimentalMaterial3WindowSizeClassApi::class, ExperimentalLifecycleComposeApi::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -45,7 +46,7 @@ class MainActivity : ComponentActivity() { ReplyTheme { val windowSize = calculateWindowSizeClass(this) val displayFeatures = calculateDisplayFeatures(this) - val uiState by viewModel.uiState.collectAsState() + val uiState by viewModel.uiState.collectAsStateWithLifecycle() ReplyApp( windowSize = windowSize, diff --git a/Reply/gradle/libs.versions.toml b/Reply/gradle/libs.versions.toml index c9fec39c47..42af37aa03 100644 --- a/Reply/gradle/libs.versions.toml +++ b/Reply/gradle/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -54,7 +50,6 @@ secrets = "2.0.1" targetSdk = "33" [libraries] -accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" } accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "accompanist" } accompanist-pager = { module = "com.google.accompanist:accompanist-pager", version.ref = "accompanist" } accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } @@ -66,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -125,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/scripts/libs.versions.toml b/scripts/libs.versions.toml index 7108feb8c1..42af37aa03 100644 --- a/scripts/libs.versions.toml +++ b/scripts/libs.versions.toml @@ -3,20 +3,21 @@ # Do not add a dependency to an individual sample, edit the global version instead. ##### [versions] -accompanist = "0.25.1" -androidGradlePlugin = "7.3.0" -androidx-activity-compose = "1.5.1" -androidx-appcompat = "1.5.0" +accompanist = "0.26.5-rc" +androidGradlePlugin = "7.3.1" +androidx-activity-compose = "1.6.0" +androidx-appcompat = "1.5.1" androidx-benchmark = "1.1.0" androidx-benchmark-junit4 = "1.1.0-beta04" +androidx-compose-bom = "2022.10.00" androidx-constraintlayout = "1.0.1" -androidx-corektx = "1.8.0" +androidx-corektx = "1.9.0" androidx-lifecycle-compose = "2.5.1" -androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha -androidx-navigation = "2.5.1" +androidx-lifecycle-runtime-compose = "2.6.0-alpha03" +androidx-navigation = "2.5.2" androidx-palette = "1.0.0" -androidx-test = "1.3.0" -androidx-test-espresso = "3.3.0" +androidx-test = "1.4.0" +androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30 androidx-test-ext-junit = "1.1.3" androidx-test-ext-truth = "1.4.0" androidx-window = "1.1.0-alpha03" @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0" coil = "2.2.0" # @keep compileSdk = "33" -compose = "1.2.1" -compose-compiler = "1.3.0" -# @pin to be updated manually - check JetChat tests -compose-material3 = "1.0.0-alpha15" -# @pin to be updated manually - check JetChat tests -compose-materialWindow = "1.0.0-alpha15" +compose-compiler = "1.3.2" compose-snapshot = "-" coroutines = "1.6.4" google-maps = "18.1.0" @@ -39,14 +35,14 @@ hiltExt = "1.0.0" # @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions jdkDesugar = "1.1.5" junit = "4.13.2" -kotlin = "1.7.10" +kotlin = "1.7.20" maps-compose = "2.5.3" -material = "1.7.0-beta01" +material = "1.8.0-alpha01" # @keep minSdk = "21" okhttp = "4.10.0" # @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593) -roboelectric = "4.5.1" +robolectric = "4.5.1" rome = "1.18.0" room = "2.5.0-alpha02" secrets = "2.0.1" @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" } androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" } -androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } -androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" } -androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } -androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } -androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } -androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } -androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } -androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } -androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } -androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } -androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } -androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } -androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } +androidx-compose-animation = { module = "androidx.compose.animation:animation" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } +androidx-compose-material = { module = "androidx.compose.material:material" } +androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } +androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" } +androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" } androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } -robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" } rometools-rome = { module = "com.rometools:rome", version.ref = "rome" } secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" } diff --git a/scripts/test_snapshot.sh b/scripts/test_snapshot.sh index 18e3573341..f0694d9dbd 100755 --- a/scripts/test_snapshot.sh +++ b/scripts/test_snapshot.sh @@ -22,7 +22,7 @@ # ./scripts/test_snapshot.sh # ######################################################################## -set -e +set -xe if [ -z "$1" ]; then read -p "Enter compose version e.g. 1.3.0: " compose_ver @@ -40,7 +40,11 @@ export COMPOSE_SNAPSHOT_ID=$snapshot # Switch version to SNAPSHOT cp ./scripts/libs.versions.toml ./scripts/libs.versions.toml.tmp -sed -i '' -e 's/^compose = ".*"/compose = "'$compose_ver'-SNAPSHOT"/g' ./scripts/libs.versions.toml +if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' -e 's/^compose = ".*"/compose = "'$compose_ver'-SNAPSHOT"/g' ./scripts/libs.versions.toml +else + sed -i -e 's/^compose = ".*"/compose = "'$compose_ver'-SNAPSHOT"/g' ./scripts/libs.versions.toml +fi # Copy to all samples and verify ./scripts/duplicate_version_config.sh