app: use non-deprecated window size class API

WindowWidthSizeClass is deprecated in window-core 1.5. Check the
width breakpoints with WindowSizeClass.isWidthAtLeastBreakpoint()
instead. The adaptive library only buckets widths at 600 and 840dp,
so the expanded and compact checks behave exactly as before.

The API is only available since window-core 1.4, while adaptive
1.1.0 puts 1.3.0 on the compile classpath. Depend on window-core
1.5.0 explicitly, the version already resolved at runtime, so the
packaged dependencies do not change.

Assisted-by: Claude Opus 5.5
This commit is contained in:
topjohnwu
2026-10-08 10:35:49 -07:00
committed by John Wu
parent 42b203679a
commit 2140801eb4
4 changed files with 8 additions and 6 deletions
+1
View File
@@ -50,6 +50,7 @@ dependencies {
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.compose.material3)
implementation(libs.compose.material3.adaptive.navigation.suite)
implementation(libs.window.core)
implementation(libs.material)
// Navigation3
@@ -13,7 +13,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.window.core.layout.WindowWidthSizeClass
import androidx.window.core.layout.WindowSizeClass
/**
* Shows [first] and [second] side by side as two equal columns, centered and capped in width,
@@ -26,8 +26,8 @@ fun AdaptiveColumns(
first: @Composable ColumnScope.() -> Unit,
second: @Composable ColumnScope.() -> Unit,
) {
val twoColumns =
currentWindowAdaptiveInfo().windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.EXPANDED
val twoColumns = currentWindowAdaptiveInfo().windowSizeClass
.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND)
val arrangement = Arrangement.spacedBy(spacing)
if (twoColumns) {
Row(
@@ -58,7 +58,7 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.core.net.toUri
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.window.core.layout.WindowWidthSizeClass
import androidx.window.core.layout.WindowSizeClass
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.repository.FirmwareCrawler
@@ -125,8 +125,8 @@ fun InstallDialog(
}
// Full screen dialogs are only for compact windows; read this outside of the Dialog window
val fullScreen =
currentWindowAdaptiveInfo().windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.COMPACT
val fullScreen = !currentWindowAdaptiveInfo().windowSizeClass
.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
if (show) {
Dialog(
+1
View File
@@ -59,6 +59,7 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref =
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-ui" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-m3" }
compose-material3-adaptive-navigation-suite = { module = "androidx.compose.material3:material3-adaptive-navigation-suite", version.ref = "compose-m3" }
window-core = { module = "androidx.window:window-core", version = "1.5.0" }
compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version = "1.7.8" }
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" }