summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mykola Podolian <mpodolian@google.com> 2025-02-28 18:02:49 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-02-28 18:02:49 -0800
commit9ffda8ac4e1843df664ff4f35f7d093fb063cee5 (patch)
tree6d96a10c68c4070538a03ddba784d5383b2513af
parentdd3a085bf1346f2db4c1403638c6a8f03f09fe1f (diff)
parent9d2ca4cb649e2e2ba5e62dcdcad912e8e1fbc241 (diff)
Merge "Extract foldable device detection" into main
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DeviceConfig.kt20
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DeviceConfig.kt b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DeviceConfig.kt
index f479da051e06..1b7c9c282304 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DeviceConfig.kt
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DeviceConfig.kt
@@ -49,19 +49,29 @@ data class DeviceConfig(
or WindowInsets.Type.displayCutout())
val windowBounds = windowMetrics.bounds
val config: Configuration = context.resources.configuration
- val isLargeScreen = config.smallestScreenWidthDp >= LARGE_SCREEN_MIN_EDGE_DP
- val largestEdgeDp = max(config.screenWidthDp, config.screenHeightDp)
- val isSmallTablet = isLargeScreen && largestEdgeDp < SMALL_TABLET_MAX_EDGE_DP
val isLandscape = context.resources.configuration.orientation == ORIENTATION_LANDSCAPE
val isRtl = context.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL
return DeviceConfig(
- isLargeScreen = isLargeScreen,
- isSmallTablet = isSmallTablet,
+ isLargeScreen = isLargeScreen(config),
+ isSmallTablet = isSmallTablet(context),
isLandscape = isLandscape,
isRtl = isRtl,
windowBounds = windowBounds,
insets = insets
)
}
+
+ @JvmStatic
+ fun isSmallTablet(context: Context): Boolean {
+ val config: Configuration = context.resources.configuration
+ if (!isLargeScreen(config)) {
+ return false
+ }
+ val largestEdgeDp = max(config.screenWidthDp, config.screenHeightDp)
+ return largestEdgeDp < SMALL_TABLET_MAX_EDGE_DP
+ }
+
+ private fun isLargeScreen(config: Configuration) =
+ config.smallestScreenWidthDp >= LARGE_SCREEN_MIN_EDGE_DP
}
}