Remove nonOverlappingTaskarInsets

- Override our insets in LauncherRootView to explicitly only care about nav bar size, ignoring any insets due to taskbar.
- Previously we used nonOverlappingTaskbarInsets to belatedly subtract from measurements in e.g. DeviceProfile, but now we can revert most of those calculations since we effectively subtract taskbar insets at the root.

Test: visual in different orientations and navigation modes, and testPressHomeOnAllAppsContextMenu to ensure REQUEST_WINDOW_INSETS still works for automated tests
Fixes: 200607741
Change-Id: I8de5a268c686a1354b4beaa30e101bab6bed5af9
This commit is contained in:
Tony Wickham
2021-09-15 15:44:05 -07:00
parent 7eb5b53865
commit 21970ccd29
6 changed files with 13 additions and 46 deletions

View File

@@ -47,15 +47,8 @@ public class LauncherRootView extends InsettableFrameLayout {
}
private void handleSystemWindowInsets(Rect insets) {
DeviceProfile dp = mActivity.getDeviceProfile();
// Taskbar provides insets, but we don't want that for most Launcher elements so remove it.
mTempRect.set(insets);
insets = mTempRect;
insets.bottom = Math.max(0, insets.bottom - dp.nonOverlappingTaskbarInset);
// Update device profile before notifying the children.
dp.updateInsets(insets);
mActivity.getDeviceProfile().updateInsets(insets);
boolean resetState = !insets.equals(mInsets);
setInsets(insets);
@@ -86,10 +79,6 @@ public class LauncherRootView extends InsettableFrameLayout {
* get its insets, we calculate them ourselves so they are stable regardless of whether taskbar
* is currently attached.
*
* TODO(b/198798034): Currently we always calculate nav insets as taskbarSize, but then we
* subtract nonOverlappingTaskbarInset in handleSystemWindowInsets(). Instead, we should just
* calculate the normal nav bar height here, and remove nonOverlappingTaskbarInset altogether.
*
* @param oldInsets The system-provided insets, which we are modifying.
* @return The updated insets.
*/
@@ -108,10 +97,8 @@ public class LauncherRootView extends InsettableFrameLayout {
Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars());
Rect newNavInsets = new Rect(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right,
oldNavInsets.bottom);
if (dp.isTaskbarPresent) {
// TODO (see javadoc): Remove this block and fall into the next one instead.
newNavInsets.bottom = dp.taskbarSize;
} else if (dp.isLandscape) {
if (dp.isLandscape) {
if (dp.isTablet) {
newNavInsets.bottom = ResourceUtils.getNavbarSize(
"navigation_bar_height_landscape", resources);