Adding support for non-zero left insets
Bug: 29613069
Change-Id: Ifdf9bcce7ecdedc510f3be8a4dc10eb8da7c4bf1
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 104af52..7bcf5d0 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -15,7 +15,9 @@
private final Paint mOpaquePaint;
@ViewDebug.ExportedProperty(category = "launcher")
- private boolean mDrawRightInsetBar;
+ private boolean mDrawSideInsetBar;
+ @ViewDebug.ExportedProperty(category = "launcher")
+ private int mLeftInsetBarWidth;
@ViewDebug.ExportedProperty(category = "launcher")
private int mRightInsetBarWidth;
@@ -42,13 +44,14 @@
@TargetApi(23)
@Override
protected boolean fitSystemWindows(Rect insets) {
- mDrawRightInsetBar = insets.right > 0 &&
+ mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) &&
(!Utilities.ATLEAST_MARSHMALLOW ||
getContext().getSystemService(ActivityManager.class).isLowRamDevice());
mRightInsetBarWidth = insets.right;
- setInsets(mDrawRightInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
+ mLeftInsetBarWidth = insets.left;
+ setInsets(mDrawSideInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
- if (mAlignedView != null && mDrawRightInsetBar) {
+ if (mAlignedView != null && mDrawSideInsetBar) {
// Apply margins on aligned view to handle left/right insets.
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) {
@@ -66,9 +69,14 @@
super.dispatchDraw(canvas);
// If the right inset is opaque, draw a black rectangle to ensure that is stays opaque.
- if (mDrawRightInsetBar) {
- int width = getWidth();
- canvas.drawRect(width - mRightInsetBarWidth, 0, width, getHeight(), mOpaquePaint);
+ 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);
+ }
}
}
}
\ No newline at end of file