diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-05-07 11:09:13 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-05-08 14:57:36 -0700 |
commit | 9001b10771520a7eabe2b5e63509096f4bdc2aa0 (patch) | |
tree | d8bb4338028d3114d69cf7c187a0ee6d727a2b90 /src | |
parent | 729020d186406dffe3dc9300ee32a2ac974c4dff (diff) | |
download | android_packages_apps_Trebuchet-9001b10771520a7eabe2b5e63509096f4bdc2aa0.tar.gz android_packages_apps_Trebuchet-9001b10771520a7eabe2b5e63509096f4bdc2aa0.tar.bz2 android_packages_apps_Trebuchet-9001b10771520a7eabe2b5e63509096f4bdc2aa0.zip |
Consuming launcher instets in multi-window mode
Bug: 79267409
Change-Id: I283f9eeffaf322cee9289bf90528c8c51d083a50
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/LauncherRootView.java | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index ad1456a2d..ae0e7a718 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -21,12 +21,9 @@ public class LauncherRootView extends InsettableFrameLayout { private final Launcher mLauncher; private final Paint mOpaquePaint; + @ViewDebug.ExportedProperty(category = "launcher") - private boolean mDrawSideInsetBar; - @ViewDebug.ExportedProperty(category = "launcher") - private int mLeftInsetBarWidth; - @ViewDebug.ExportedProperty(category = "launcher") - private int mRightInsetBarWidth; + private final Rect mConsumedInsets = new Rect(); private View mAlignedView; private WindowStateListener mWindowStateListener; @@ -54,18 +51,26 @@ public class LauncherRootView extends InsettableFrameLayout { @TargetApi(23) @Override protected boolean fitSystemWindows(Rect insets) { - mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) && + mConsumedInsets.setEmpty(); + boolean drawInsetBar = false; + if (mLauncher.isInMultiWindowModeCompat() + && (insets.left > 0 || insets.right > 0 || insets.bottom > 0)) { + mConsumedInsets.left = insets.left; + mConsumedInsets.right = insets.right; + mConsumedInsets.bottom = insets.bottom; + insets = new Rect(0, insets.top, 0, 0); + drawInsetBar = true; + } else if ((insets.right > 0 || insets.left > 0) && (!Utilities.ATLEAST_MARSHMALLOW || - getContext().getSystemService(ActivityManager.class).isLowRamDevice()); - if (mDrawSideInsetBar) { - mLeftInsetBarWidth = insets.left; - mRightInsetBarWidth = insets.right; + getContext().getSystemService(ActivityManager.class).isLowRamDevice())) { + mConsumedInsets.left = insets.left; + mConsumedInsets.right = insets.right; insets = new Rect(0, insets.top, 0, insets.bottom); - } else { - mLeftInsetBarWidth = mRightInsetBarWidth = 0; + drawInsetBar = true; } + mLauncher.getSystemUiController().updateUiState( - UI_STATE_ROOT_VIEW, mDrawSideInsetBar ? FLAG_DARK_NAV : 0); + UI_STATE_ROOT_VIEW, drawInsetBar ? FLAG_DARK_NAV : 0); // Update device profile before notifying th children. mLauncher.getDeviceProfile().updateInsets(insets); @@ -73,11 +78,14 @@ public class LauncherRootView extends InsettableFrameLayout { setInsets(insets); if (mAlignedView != null) { - // Apply margins on aligned view to handle left/right insets. + // Apply margins on aligned view to handle consumed insets. MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams(); - if (lp.leftMargin != mLeftInsetBarWidth || lp.rightMargin != mRightInsetBarWidth) { - lp.leftMargin = mLeftInsetBarWidth; - lp.rightMargin = mRightInsetBarWidth; + if (lp.leftMargin != mConsumedInsets.left || lp.rightMargin != mConsumedInsets.right || + lp.bottomMargin != mConsumedInsets.bottom) { + lp.leftMargin = mConsumedInsets.left; + lp.rightMargin = mConsumedInsets.right; + lp.topMargin = mConsumedInsets.top; + lp.bottomMargin = mConsumedInsets.bottom; mAlignedView.setLayoutParams(lp); } } @@ -109,14 +117,16 @@ public class LauncherRootView extends InsettableFrameLayout { super.dispatchDraw(canvas); // If the right inset is opaque, draw a black rectangle to ensure that is stays opaque. - if (mDrawSideInsetBar) { - if (mRightInsetBarWidth > 0) { - int width = getWidth(); - canvas.drawRect(width - mRightInsetBarWidth, 0, width, getHeight(), mOpaquePaint); - } - if (mLeftInsetBarWidth > 0) { - canvas.drawRect(0, 0, mLeftInsetBarWidth, getHeight(), mOpaquePaint); - } + if (mConsumedInsets.right > 0) { + int width = getWidth(); + canvas.drawRect(width - mConsumedInsets.right, 0, width, getHeight(), mOpaquePaint); + } + if (mConsumedInsets.left > 0) { + canvas.drawRect(0, 0, mConsumedInsets.left, getHeight(), mOpaquePaint); + } + if (mConsumedInsets.bottom > 0) { + int height = getHeight(); + canvas.drawRect(0, height - mConsumedInsets.bottom, getWidth(), height, mOpaquePaint); } } |