summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-06-12 08:44:09 -0700
committerSunny Goyal <sunnygoyal@google.com>2019-06-12 12:15:16 -0700
commit022b18263468282979e84fd8864bee4f67919f2d (patch)
tree3095063bf2e1729027e60417d7b47833cc08df9e /src
parentc9e6f23658863ae9521a366b2bdd9f11316bf2c7 (diff)
downloadandroid_packages_apps_Trebuchet-022b18263468282979e84fd8864bee4f67919f2d.tar.gz
android_packages_apps_Trebuchet-022b18263468282979e84fd8864bee4f67919f2d.tar.bz2
android_packages_apps_Trebuchet-022b18263468282979e84fd8864bee4f67919f2d.zip
Updating consumed insets when dispatching to child views
Bug: 134963243 Change-Id: I4fa072128398cfd22b906037c6c444495781c9d0
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/LauncherRootView.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 49b380b41..f964b8d9e 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -8,18 +8,22 @@ import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewDebug;
+import android.view.WindowInsets;
import java.util.Collections;
import java.util.List;
public class LauncherRootView extends InsettableFrameLayout {
+ private final Rect mTempRect = new Rect();
+
private final Launcher mLauncher;
private final Paint mOpaquePaint;
@@ -56,9 +60,7 @@ public class LauncherRootView extends InsettableFrameLayout {
super.onFinishInflate();
}
- @TargetApi(23)
- @Override
- protected boolean fitSystemWindows(Rect insets) {
+ private void handleSystemWindowInsets(Rect insets) {
mConsumedInsets.setEmpty();
boolean drawInsetBar = false;
if (mLauncher.isInMultiWindowMode()
@@ -66,13 +68,13 @@ public class LauncherRootView extends InsettableFrameLayout {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
mConsumedInsets.bottom = insets.bottom;
- insets = new Rect(0, insets.top, 0, 0);
+ insets.set(0, insets.top, 0, 0);
drawInsetBar = true;
} else if ((insets.right > 0 || insets.left > 0) &&
getContext().getSystemService(ActivityManager.class).isLowRamDevice()) {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
- insets = new Rect(0, insets.top, 0, insets.bottom);
+ insets.set(0, insets.top, 0, insets.bottom);
drawInsetBar = true;
}
@@ -99,8 +101,19 @@ public class LauncherRootView extends InsettableFrameLayout {
if (resetState) {
mLauncher.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
}
+ }
- return false; // Let children get the full insets
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ mTempRect.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
+ insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
+ handleSystemWindowInsets(mTempRect);
+ if (Utilities.ATLEAST_Q) {
+ return insets.inset(mConsumedInsets.left, mConsumedInsets.top,
+ mConsumedInsets.right, mConsumedInsets.bottom);
+ } else {
+ return insets.replaceSystemWindowInsets(mTempRect);
+ }
}
@Override