From 4e2c25a788f1b0eae6a472c6749fdadfcf046b84 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 3 Feb 2021 16:20:04 +0000 Subject: [PATCH] Ensure isTablet is only enable when simulated landscape is disabled - Tablet UI (e.g. grid overview and two panel workspace) is built with assumption that simulated landscape is disabled, make sure this is the case in DeviceProfile - This is usually true as swDPs is generally smaller than sw used to determine xml files Bug: 174464656 Test: Try different combination of smallest width and Display Size, isTablet is only set when allow_rotation is true Change-Id: I3ee1c76909f29b6f14c4032be812bb8c9ea7e827 --- src/com/android/launcher3/DeviceProfile.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index f681d75eef..4d5bd5d95f 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -168,8 +168,10 @@ public class DeviceProfile { // Constants from resources float swDPs = Utilities.dpiFromPx( Math.min(info.smallestSize.x, info.smallestSize.y), info.metrics); - isTablet = swDPs >= TABLET_MIN_DPS; - isLargeTablet = swDPs >= LARGE_TABLET_MIN_DPS; + boolean allowRotation = context.getResources().getBoolean(R.bool.allow_rotation); + // Tablet UI is built with assumption that simulated landscape is disabled. + isTablet = allowRotation && swDPs >= TABLET_MIN_DPS; + isLargeTablet = isTablet && swDPs >= LARGE_TABLET_MIN_DPS; isPhone = !isTablet && !isLargeTablet; aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx); boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;