From 8b29a8407e55163bbdc9e25e0326e8ae4f8259ee Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Thu, 31 May 2018 14:14:13 +0200 Subject: [PATCH] Cutout Overlay: Flip color in inverted color mode Flips the color when the screen is inverted such that it will end up black again after composition. Change-Id: I8800c666b60061a58f1345a2609a088a02e82f48 Fixes: 80102202 Test: Enable cutout overlay, enable color inversion, verify overlay is black. --- .../android/systemui/ScreenDecorations.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index e347a144dc9c6..efaf557660d23 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -135,12 +135,14 @@ public class ScreenDecorations extends SystemUI implements Tunable { private void setupDecorations() { mOverlay = LayoutInflater.from(mContext) .inflate(R.layout.rounded_corners, null); - ((ViewGroup)mOverlay).addView(new DisplayCutoutView(mContext, true, - this::updateWindowVisibilities)); + DisplayCutoutView cutoutTop = new DisplayCutoutView(mContext, true, + this::updateWindowVisibilities); + ((ViewGroup)mOverlay).addView(cutoutTop); mBottomOverlay = LayoutInflater.from(mContext) .inflate(R.layout.rounded_corners, null); - ((ViewGroup)mBottomOverlay).addView(new DisplayCutoutView(mContext, false, - this::updateWindowVisibilities)); + DisplayCutoutView cutoutBottom = new DisplayCutoutView(mContext, false, + this::updateWindowVisibilities); + ((ViewGroup)mBottomOverlay).addView(cutoutBottom); mOverlay.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE); mOverlay.setAlpha(0); @@ -170,6 +172,8 @@ public class ScreenDecorations extends SystemUI implements Tunable { ((ImageView) mOverlay.findViewById(R.id.right)).setImageTintList(tintList); ((ImageView) mBottomOverlay.findViewById(R.id.left)).setImageTintList(tintList); ((ImageView) mBottomOverlay.findViewById(R.id.right)).setImageTintList(tintList); + cutoutTop.setColor(tint); + cutoutBottom.setColor(tint); } }; setting.setListening(true); @@ -414,6 +418,7 @@ public class ScreenDecorations extends SystemUI implements Tunable { private final int[] mLocation = new int[2]; private final boolean mStart; private final Runnable mVisibilityChangedListener; + private int mColor = Color.BLACK; public DisplayCutoutView(Context context, boolean start, Runnable visibilityChangedListener) { @@ -423,6 +428,11 @@ public class ScreenDecorations extends SystemUI implements Tunable { setId(R.id.display_cutout); } + public void setColor(int color) { + mColor = color; + invalidate(); + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); @@ -443,7 +453,7 @@ public class ScreenDecorations extends SystemUI implements Tunable { getLocationOnScreen(mLocation); canvas.translate(-mLocation[0], -mLocation[1]); if (!mBoundingPath.isEmpty()) { - mPaint.setColor(Color.BLACK); + mPaint.setColor(mColor); mPaint.setStyle(Paint.Style.FILL); mPaint.setAntiAlias(true); canvas.drawPath(mBoundingPath, mPaint);