From f9a3533df301a7417c22c5726c7dd2a5a4dec675 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Sat, 4 Feb 2023 12:15:39 +0100 Subject: [PATCH] Updgrade androidx-lifecycle from 2.6.0-alpha03 to 2.6.0-alpha05 > `Transformations` is now written in Kotlin. This is a *source incompatible change* for those classes written in Kotlin that were directly using syntax such as `Transformations.map` > Kotlin code *must* now use the Kotlin extension method syntax that was previously only available when using `lifecycle-livedata-ktx`. > The `collectAsStateWithLifecycle()` APIs of `lifecycle-runtime-compose` are no longer in experimental status. (I09d42, b/258835424) Changelog: https://developer.android.com/jetpack/androidx/releases/lifecycle#2.6.0-alpha05 --- .../com/google/samples/apps/nowinandroid/ui/NiaApp.kt | 2 -- .../nowinandroid/feature/bookmarks/BookmarksScreen.kt | 2 -- .../apps/nowinandroid/feature/foryou/ForYouScreen.kt | 2 -- .../nowinandroid/feature/interests/InterestsScreen.kt | 2 -- .../apps/nowinandroid/feature/settings/SettingsDialog.kt | 2 -- .../apps/nowinandroid/feature/topic/TopicScreen.kt | 2 -- gradle/libs.versions.toml | 2 +- .../sync/status/WorkManagerSyncStatusMonitor.kt | 8 +++----- 8 files changed, 4 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt index 14bc11992..0251c1d6b 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt @@ -50,7 +50,6 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTagsAsResourceId -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavDestination import androidx.navigation.NavDestination.Companion.hierarchy @@ -77,7 +76,6 @@ import com.google.samples.apps.nowinandroid.feature.settings.R as settingsR ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class, ExperimentalComposeUiApi::class, - ExperimentalLifecycleComposeApi::class, ) @Composable fun NiaApp( diff --git a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt index 1169f5777..a9d5a71af 100644 --- a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt +++ b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt @@ -50,7 +50,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel import com.google.samples.apps.nowinandroid.core.designsystem.theme.LocalTintTheme @@ -63,7 +62,6 @@ import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider import com.google.samples.apps.nowinandroid.core.ui.newsFeed -@OptIn(ExperimentalLifecycleComposeApi::class) @Composable internal fun BookmarksRoute( modifier: Modifier = Modifier, diff --git a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index 492660142..8fb44326b 100644 --- a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -74,7 +74,6 @@ import androidx.compose.ui.unit.sp import androidx.compose.ui.util.trace import androidx.core.view.doOnPreDraw import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.component.DynamicAsyncImage import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaButton @@ -89,7 +88,6 @@ import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider import com.google.samples.apps.nowinandroid.core.ui.newsFeed -@OptIn(ExperimentalLifecycleComposeApi::class) @Composable internal fun ForYouRoute( modifier: Modifier = Modifier, diff --git a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt index fd45c7608..abe1569e7 100644 --- a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt +++ b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaBackground import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel @@ -34,7 +33,6 @@ import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.FollowableTopicPreviewParameterProvider -@OptIn(ExperimentalLifecycleComposeApi::class) @Composable internal fun InterestsRoute( navigateToTopic: (String) -> Unit, diff --git a/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt b/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt index bed230d0d..4c4ba727b 100644 --- a/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt +++ b/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt @@ -50,7 +50,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.window.DialogProperties import androidx.core.content.ContextCompat import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.supportsDynamicTheming @@ -65,7 +64,6 @@ import com.google.samples.apps.nowinandroid.feature.settings.R.string import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Success -@ExperimentalLifecycleComposeApi @Composable fun SettingsDialog( onDismiss: () -> Unit, diff --git a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt index e7b218072..656c7d961 100644 --- a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt +++ b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt @@ -44,7 +44,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.component.DynamicAsyncImage import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaBackground @@ -61,7 +60,6 @@ import com.google.samples.apps.nowinandroid.core.ui.userNewsResourceCardItems import com.google.samples.apps.nowinandroid.feature.topic.R.string import com.google.samples.apps.nowinandroid.feature.topic.TopicUiState.Loading -@OptIn(ExperimentalLifecycleComposeApi::class) @Composable internal fun TopicRoute( onBackClick: () -> Unit, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 828e38f12..8af6b9484 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ androidxCoreSplashscreen = "1.0.0" androidxDataStore = "1.0.0" androidxEspresso = "3.5.0" androidxHiltNavigationCompose = "1.0.0" -androidxLifecycle = "2.6.0-alpha03" +androidxLifecycle = "2.6.0-alpha05" androidxMacroBenchmark = "1.1.1" androidxMetrics = "1.0.0-alpha03" androidxNavigation = "2.5.3" diff --git a/sync/work/src/main/java/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncStatusMonitor.kt b/sync/work/src/main/java/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncStatusMonitor.kt index 9edb630eb..f4f9d02cb 100644 --- a/sync/work/src/main/java/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncStatusMonitor.kt +++ b/sync/work/src/main/java/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncStatusMonitor.kt @@ -17,8 +17,8 @@ package com.google.samples.apps.nowinandroid.sync.status import android.content.Context -import androidx.lifecycle.Transformations import androidx.lifecycle.asFlow +import androidx.lifecycle.map import androidx.work.WorkInfo import androidx.work.WorkInfo.State import androidx.work.WorkManager @@ -36,10 +36,8 @@ class WorkManagerSyncStatusMonitor @Inject constructor( @ApplicationContext context: Context, ) : SyncStatusMonitor { override val isSyncing: Flow = - Transformations.map( - WorkManager.getInstance(context).getWorkInfosForUniqueWorkLiveData(SyncWorkName), - MutableList::anyRunning, - ) + WorkManager.getInstance(context).getWorkInfosForUniqueWorkLiveData(SyncWorkName) + .map(MutableList::anyRunning) .asFlow() .conflate() }