From c79bd214719f73c55da5e3ecc744f58dd97f5156 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 17 May 2019 16:12:37 -0700 Subject: [PATCH] Fixing inset map in case of display cutouts Change-Id: Ia2969688d9ae4c89a2da45eb6361f4476e1877ec --- .../launcher3/uioverrides/RecentsUiFactory.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index ebae1cd968..336cdc93fe 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -76,8 +76,13 @@ public abstract class RecentsUiFactory { @Override public void mapInsets(Context context, Rect insets, Rect out) { + // If there is a display cutout, the top insets in portrait would also include the + // cutout, which we will get as the left inset in landscape. Using the max of left and + // top allows us to cover both cases (with or without cutout). if (SysUINavigationMode.getMode(context) == NO_BUTTON) { - out.set(insets); + out.top = Math.max(insets.top, insets.left); + out.bottom = Math.max(insets.right, insets.bottom); + out.left = out.right = 0; } else { out.top = Math.max(insets.top, insets.left); out.bottom = insets.right; @@ -99,7 +104,9 @@ public abstract class RecentsUiFactory { @Override public void mapInsets(Context context, Rect insets, Rect out) { if (SysUINavigationMode.getMode(context) == NO_BUTTON) { - out.set(insets); + out.top = Math.max(insets.top, insets.right); + out.bottom = Math.max(insets.left, insets.bottom); + out.left = out.right = 0; } else { out.top = Math.max(insets.top, insets.right); out.bottom = insets.left;