From dfc8ddff8796f2def85ee8f15cd165e9a0866fca Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 25 Jan 2022 11:26:25 +0000 Subject: [PATCH] Manually apply nav bar insets in DeviceProfile for tablets - With flexible inset changes in T, taskbar is no longer inseted in getCurrentSizeRange, i.e. DeviceProfile.availableHeight no longer inset nav bar size - In order for home screen sizes to be calcualted correctly, inset nav bar manually in DeviceProfile Bug: 215528237 Test: maual in tablet gesture nav and 3 buttons Change-Id: Ia7d518613eb843f4c45ed77cefc906d7124cb367 --- src/com/android/launcher3/DeviceProfile.java | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index bb03b914f7..d3486027dd 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -238,27 +238,35 @@ public class DeviceProfile { isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode; - // Determine sizes. - widthPx = windowBounds.bounds.width(); - heightPx = windowBounds.bounds.height(); - availableWidthPx = windowBounds.availableSize.x; - availableHeightPx = windowBounds.availableSize.y; - + // Determine device posture. mInfo = info; isTablet = info.isTablet(windowBounds); isPhone = !isTablet; isTwoPanels = isTablet && useTwoPanels; + isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS + && FeatureFlags.ENABLE_TASKBAR.get(); - - aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx); - boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0; - mQsbCenterFactor = context.getResources().getFloat(R.dimen.qsb_center_factor); - // Some more constants + // Some more constants. context = getContext(context, info, isVerticalBarLayout() ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT); - mMetrics = context.getResources().getDisplayMetrics(); final Resources res = context.getResources(); + mMetrics = res.getDisplayMetrics(); + + // Determine sizes. + widthPx = windowBounds.bounds.width(); + heightPx = windowBounds.bounds.height(); + availableWidthPx = windowBounds.availableSize.x; + int taskbarInset = isTaskbarPresent + ? ResourceUtils.getNavbarSize( + isLandscape ? "navigation_bar_height_landscape" : "navigation_bar_height", + res) + : 0; + availableHeightPx = windowBounds.availableSize.y - taskbarInset; + + aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx); + boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0; + mQsbCenterFactor = res.getFloat(R.dimen.qsb_center_factor); if (isTwoPanels) { if (isLandscape) { @@ -274,8 +282,6 @@ public class DeviceProfile { } } - isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS - && FeatureFlags.ENABLE_TASKBAR.get(); if (isTaskbarPresent) { taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size); }