diff --git a/app/build.gradle b/app/build.gradle index 156d67f20..8d8dc3e01 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ dependencies { implementation libs.androidx.activity.compose implementation libs.androidx.appcompat implementation libs.androidx.core.ktx - implementation libs.androidx.compose.material.window + implementation libs.androidx.compose.material3.windowSizeClass implementation libs.androidx.hilt.navigation.compose implementation libs.androidx.navigation.compose implementation libs.androidx.window.manager diff --git a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt index b2ebd3aea..adf3c0f3b 100644 --- a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt +++ b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt @@ -16,7 +16,6 @@ package com.google.samples.apps.nowinandroid.ui -import androidx.compose.material.window.ExperimentalMaterialWindowApi import androidx.compose.ui.test.assertIsOn import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.junit4.createAndroidComposeRule @@ -38,7 +37,6 @@ import org.junit.rules.TemporaryFolder /** * Tests all the navigation flows that are handled by the navigation library. */ -@ExperimentalMaterialWindowApi @HiltAndroidTest class NavigationTest { diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt index 08119bfef..d3330f21e 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt @@ -19,13 +19,13 @@ package com.google.samples.apps.nowinandroid import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.material.window.ExperimentalMaterialWindowApi -import androidx.compose.material.window.calculateSizeClass +import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi +import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.core.view.WindowCompat import com.google.samples.apps.nowinandroid.ui.NiaApp import dagger.hilt.android.AndroidEntryPoint -@ExperimentalMaterialWindowApi +@OptIn(ExperimentalMaterial3WindowSizeClassApi::class) @AndroidEntryPoint class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -35,7 +35,7 @@ class MainActivity : ComponentActivity() { // including IME animations WindowCompat.setDecorFitsSystemWindows(window, false) - setContent { NiaApp(calculateSizeClass()) } + setContent { NiaApp(calculateWindowSizeClass(this)) } reportFullyDrawn() } } 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 d6f85b79d..474f4fff7 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 @@ -33,8 +33,6 @@ import androidx.compose.material.icons.outlined.Bookmarks import androidx.compose.material.icons.outlined.Grid3x3 import androidx.compose.material.icons.outlined.Upcoming import androidx.compose.material.ripple.LocalRippleTheme -import androidx.compose.material.window.SizeClass -import androidx.compose.material.window.WidthSizeClass import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -45,6 +43,8 @@ import androidx.compose.material3.NavigationRailItem import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.windowsizeclass.WindowSizeClass +import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue @@ -63,7 +63,7 @@ import com.google.samples.apps.nowinandroid.core.ui.theme.NiaTheme @OptIn(ExperimentalMaterial3Api::class) @Composable -fun NiaApp(windowSizeClass: SizeClass) { +fun NiaApp(windowSizeClass: WindowSizeClass) { NiaTheme { val navController = rememberNavController() val navigationActions = remember(navController) { @@ -76,7 +76,7 @@ fun NiaApp(windowSizeClass: SizeClass) { Scaffold( modifier = Modifier, bottomBar = { - if (windowSizeClass.width == WidthSizeClass.Compact) { + if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact) { NiABottomBar( navigationActions = navigationActions, currentDestination = currentDestination @@ -86,7 +86,7 @@ fun NiaApp(windowSizeClass: SizeClass) { ) { padding -> Surface(Modifier.fillMaxSize().statusBarsPadding()) { Row { - if (windowSizeClass.width != WidthSizeClass.Compact) { + if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) { NiANavRail( navigationActions = navigationActions, currentDestination = currentDestination diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f6cab0c90..473161219 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,9 +4,8 @@ androidDesugarJdkLibs = "1.1.5" androidGradlePlugin = "7.1.2" androidxActivity = "1.4.0" androidxAppCompat = "1.3.0" -androidxCompose = "1.2.0-alpha07" -androidxMaterialWindow = "1.2.0-SNAPSHOT" -androidxComposeMaterial3 = "1.0.0-alpha07" +androidxCompose = "1.2.0-alpha08" +androidxComposeMaterial3 = "1.0.0-alpha10" androidxCore = "1.7.0" androidxDataStore = "1.0.0" androidxEspresso = "3.3.0" @@ -26,12 +25,12 @@ hilt = "2.41" hiltExt = "1.0.0" jacoco = "0.8.7" junit4 = "4.13" -kotlin = "1.6.10" +kotlin = "1.6.20" kotlinxCoroutines = "1.6.0" kotlinxCoroutinesTest = "1.6.0" kotlinxDatetime = "0.3.1" kotlinxSerializationJson = "1.3.1" -ksp = "1.6.10-1.0.2" +ksp = "1.6.20-1.0.5" ktlint = "0.43.0" material3 = "1.5.0-alpha05" mockk = "1.12.1" @@ -53,9 +52,9 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version androidx-benchmark-macro = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "androidxMacroBenchmark" } androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "androidxCompose" } androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version.ref = "androidxCompose" } -androidx-compose-material-window = {group = "androidx.compose.material", name = "material-window", version.ref="androidxMaterialWindow"} androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "androidxCompose" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" } +androidx-compose-material3-windowSizeClass = {group = "androidx.compose.material3", name = "material3-window-size-class", version.ref="androidxComposeMaterial3"} androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime", version.ref = "androidxCompose" } androidx-compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "androidxCompose" } androidx-compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "androidxCompose" } diff --git a/settings.gradle b/settings.gradle index 1b8c413ae..e851c524c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,7 +29,7 @@ dependencyResolutionManagement { // Register the AndroidX snapshot repository first so snapshots don't attempt (and fail) // to download from the non-snapshot repositories maven { - url 'https://androidx.dev/snapshots/builds/8414861/artifacts/repository' + url 'https://androidx.dev/snapshots/builds/8455591/artifacts/repository' content { // The AndroidX snapshot repository will only have androidx artifacts, don't // bother trying to find other ones