diff --git a/.github/pics/foldable.png b/.github/pics/foldable.png index 9b7d4806..f6e1b6e7 100644 Binary files a/.github/pics/foldable.png and b/.github/pics/foldable.png differ diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 82cda340..f820274d 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -57,6 +57,7 @@ dependencies { api(libs.androidx.lifecycle.viewmodel.compose) api(libs.androidx.navigation.compose) api(libs.androidx.paging.compose) + api(libs.androidx.window) api(libs.koin.androidx.compose) api(libs.ktor.client.okhttp) api(libs.ktor.serialization.kotlinx.json) diff --git a/core/src/main/kotlin/org/michaelbel/core/ktx/ConfigurationKtx.kt b/core/src/main/kotlin/org/michaelbel/core/ktx/ConfigurationKtx.kt index 9392e8e9..dd673d5a 100644 --- a/core/src/main/kotlin/org/michaelbel/core/ktx/ConfigurationKtx.kt +++ b/core/src/main/kotlin/org/michaelbel/core/ktx/ConfigurationKtx.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "ObsoleteSdkInt") +@file:Suppress("unused", "ObsoleteSdkInt", "RestrictedApi") package org.michaelbel.core.ktx @@ -13,10 +13,16 @@ import android.view.WindowInsets import android.view.WindowManager import android.view.WindowMetrics import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.core.content.ContextCompat +import androidx.window.layout.FoldingFeature +import androidx.window.layout.WindowInfoTracker +import androidx.window.layout.WindowLayoutInfo inline val Context.deviceWidth: Int get() { @@ -111,7 +117,15 @@ inline val isLandscape: Boolean @Composable get() = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE inline val isTabletPortrait: Boolean - @Composable get() = isPortrait && screenWidth >= 600 + @Composable get() = !isFoldable() && isPortrait && screenWidth >= 600 inline val isTabletLandscape: Boolean - @Composable get() = isLandscape && screenWidth >= 1200 \ No newline at end of file + @Composable get() = !isFoldable() && isLandscape && screenWidth >= 1200 + +@Composable +fun isFoldable(): Boolean { + val context = LocalContext.current + val windowLayoutInfo = remember { WindowInfoTracker.getOrCreate(context).windowLayoutInfo(context) } + val foldableState = windowLayoutInfo.collectAsState(initial = WindowLayoutInfo(emptyList())) + return foldableState.value.displayFeatures.any { it is FoldingFeature } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 34798362..e08baeed 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -131,7 +131,7 @@ google-gms-play-services-wallet = "19.4.0" google-gms-play-services-wearable = "19.0.0" google-play-app-update = "2.1.0" -google-play-asset-delivery = "2.2.2" +google-play-asset-delivery = "2.3.0" google-play-feature-delivery = "2.1.0" google-play-review = "2.0.2" diff --git a/mobile/src/main/kotlin/org/michaelbel/template/ui/list/ListScreen.kt b/mobile/src/main/kotlin/org/michaelbel/template/ui/list/ListScreen.kt index 1a825693..595d1b94 100644 --- a/mobile/src/main/kotlin/org/michaelbel/template/ui/list/ListScreen.kt +++ b/mobile/src/main/kotlin/org/michaelbel/template/ui/list/ListScreen.kt @@ -55,7 +55,7 @@ fun ListScreen( TopAppBar( title = { Text( - text = "Phone Template" + text = "Foldable Template" ) } )