From 79d10bfa49dee16af8aa83ae7c389e73f30f823c Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Thu, 11 Jun 2020 14:36:06 -0700 Subject: [PATCH] Dark grey overflow in dark mode Update overflow visibility after setup Remove BubbleOverflow#getBtn (same as getIconView) Bug: 158482996 Test: manual => Turn on dark mode => Pointer & overflow button/activity use same grey Change-Id: I0f9c7d8e6dc1ac77e8601f42527f75b1b4e9ef1d --- packages/SystemUI/res/values/colors.xml | 4 +-- .../systemui/bubbles/BubbleExpandedView.java | 4 +-- .../systemui/bubbles/BubbleOverflow.java | 26 +++++++------- .../bubbles/BubbleOverflowActivity.java | 35 +++++++------------ .../systemui/bubbles/BubbleStackView.java | 7 ++-- 5 files changed, 34 insertions(+), 42 deletions(-) diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 4fc904b21741e..40a4b50744130 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -203,8 +203,8 @@ #40000000 - #FFFFFF - @color/GM2_grey_800 + #FFFFFF + @color/GM2_grey_800 #F8F9FA diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 6dcc9dcdc63ce..ca359b8efa5d6 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -437,10 +437,10 @@ public class BubbleExpandedView extends LinearLayout { getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; switch (mode) { case Configuration.UI_MODE_NIGHT_NO: - mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_pointer_light)); + mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_light)); break; case Configuration.UI_MODE_NIGHT_YES: - mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_pointer_dark)); + mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_dark)); break; } mPointerView.setBackground(mPointerDrawable); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java index 0c62e9f9f5482..dadcb3a3a7c41 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java @@ -22,9 +22,9 @@ import static android.view.View.GONE; import static com.android.systemui.bubbles.BadgedImageView.DEFAULT_PATH_SIZE; import android.content.Context; -import android.content.res.TypedArray; +import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Bitmap; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Path; import android.graphics.drawable.AdaptiveIconDrawable; @@ -88,19 +88,23 @@ public class BubbleOverflow implements BubbleViewProvider { false /* attachToRoot */); mOverflowBtn.setContentDescription(mContext.getResources().getString( R.string.bubble_overflow_button_content_description)); + Resources res = mContext.getResources(); - TypedArray ta = mContext.obtainStyledAttributes( - new int[]{android.R.attr.colorBackgroundFloating}); - int bgColor = ta.getColor(0, Color.WHITE /* default */); - ta.recycle(); - + // Set color for button icon and dot TypedValue typedValue = new TypedValue(); mContext.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); int colorAccent = mContext.getColor(typedValue.resourceId); mOverflowBtn.getDrawable().setTint(colorAccent); mDotColor = colorAccent; - ColorDrawable bg = new ColorDrawable(bgColor); + // Set color for button and activity background + ColorDrawable bg = new ColorDrawable(res.getColor(R.color.bubbles_light)); + final int mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + if (mode == Configuration.UI_MODE_NIGHT_YES) { + bg = new ColorDrawable(res.getColor(R.color.bubbles_dark)); + } + + // Apply icon inset InsetDrawable fg = new InsetDrawable(mOverflowBtn.getDrawable(), mBitmapSize - mIconBitmapSize /* inset */); AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(bg, fg); @@ -110,6 +114,7 @@ public class BubbleOverflow implements BubbleViewProvider { null /* user */, true /* shrinkNonAdaptiveIcons */).icon; + // Get path with dot location float scale = iconFactory.getNormalizer().getScale(mOverflowBtn.getDrawable(), null /* outBounds */, null /* path */, null /* outMaskShape */); float radius = DEFAULT_PATH_SIZE / 2f; @@ -120,14 +125,9 @@ public class BubbleOverflow implements BubbleViewProvider { radius /* pivot y */); mPath.transform(matrix); - mOverflowBtn.setVisibility(GONE); mOverflowBtn.setRenderedBubble(this); } - ImageView getBtn() { - return mOverflowBtn; - } - void setVisible(int visible) { mOverflowBtn.setVisibility(visible); } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java index b4672c14b49a3..b644079be5657 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java @@ -27,6 +27,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.DisplayMetrics; import android.util.Log; @@ -100,7 +101,6 @@ public class BubbleOverflowActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bubble_overflow_activity); - setBackgroundColor(); mEmptyState = findViewById(R.id.bubble_overflow_empty_state); mRecyclerView = findViewById(R.id.bubble_overflow_recycler); @@ -141,34 +141,25 @@ public class BubbleOverflowActivity extends Activity { * Handle theme changes. */ void updateTheme() { - final int mode = - getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + Resources res = getResources(); + final int mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; switch (mode) { - case Configuration.UI_MODE_NIGHT_NO: - if (DEBUG_OVERFLOW) { - Log.d(TAG, "Set overflow UI to light mode"); - } - mEmptyStateImage.setImageDrawable( - getResources().getDrawable(R.drawable.ic_empty_bubble_overflow_light)); - break; case Configuration.UI_MODE_NIGHT_YES: - if (DEBUG_OVERFLOW) { - Log.d(TAG, "Set overflow UI to dark mode"); - } mEmptyStateImage.setImageDrawable( - getResources().getDrawable(R.drawable.ic_empty_bubble_overflow_dark)); + res.getDrawable(R.drawable.ic_empty_bubble_overflow_dark)); + findViewById(android.R.id.content) + .setBackgroundColor(res.getColor(R.color.bubbles_dark)); + break; + + case Configuration.UI_MODE_NIGHT_NO: + mEmptyStateImage.setImageDrawable( + res.getDrawable(R.drawable.ic_empty_bubble_overflow_light)); + findViewById(android.R.id.content) + .setBackgroundColor(res.getColor(R.color.bubbles_light)); break; } } - void setBackgroundColor() { - final TypedArray ta = getApplicationContext().obtainStyledAttributes( - new int[]{android.R.attr.colorBackgroundFloating}); - int bgColor = ta.getColor(0, Color.WHITE); - ta.recycle(); - findViewById(android.R.id.content).setBackgroundColor(bgColor); - } - void onDataChanged(List bubbles) { mOverflowBubbles.clear(); mOverflowBubbles.addAll(bubbles); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index dd999c22e1fe3..7cec3d9015d91 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -1100,16 +1100,17 @@ public class BubbleStackView extends FrameLayout mBubbleOverflow = new BubbleOverflow(getContext()); mBubbleOverflow.setUpOverflow(mBubbleContainer, this); } else { - mBubbleContainer.removeView(mBubbleOverflow.getBtn()); + mBubbleContainer.removeView(mBubbleOverflow.getIconView()); mBubbleOverflow.setUpOverflow(mBubbleContainer, this); overflowBtnIndex = mBubbleContainer.getChildCount(); } - mBubbleContainer.addView(mBubbleOverflow.getBtn(), overflowBtnIndex, + mBubbleContainer.addView(mBubbleOverflow.getIconView(), overflowBtnIndex, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); - mBubbleOverflow.getBtn().setOnClickListener(v -> { + mBubbleOverflow.getIconView().setOnClickListener(v -> { setSelectedBubble(mBubbleOverflow); showManageMenu(false); }); + updateOverflowVisibility(); } /** * Handle theme changes.