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
This commit is contained in:
Alex Chau
2021-02-03 16:20:04 +00:00
parent d10b587003
commit 4e2c25a788

View File

@@ -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;