diff options
| author | 2020-06-11 14:36:06 -0700 | |
|---|---|---|
| committer | 2020-06-12 15:42:04 -0700 | |
| commit | 79d10bfa49dee16af8aa83ae7c389e73f30f823c (patch) | |
| tree | afc729c1315b5f730bea3bba51e8a7ea73ad7f57 | |
| parent | 38694c298c94f8b5d1e9dbbea36371acfdaf28ea (diff) | |
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
5 files changed, 33 insertions, 41 deletions
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 4fc904b21741..40a4b5074413 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -203,8 +203,8 @@ <color name="global_screenshot_background_protection_start">#40000000</color> <!-- 25% black --> <!-- Bubbles --> - <color name="bubbles_pointer_light">#FFFFFF</color> - <color name="bubbles_pointer_dark">@color/GM2_grey_800</color> + <color name="bubbles_light">#FFFFFF</color> + <color name="bubbles_dark">@color/GM2_grey_800</color> <!-- GM2 colors --> <color name="GM2_grey_50">#F8F9FA</color> diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 6dcc9dcdc63c..ca359b8efa5d 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 0c62e9f9f548..dadcb3a3a7c4 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 b4672c14b49a..b644079be565 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"); - } + case Configuration.UI_MODE_NIGHT_YES: mEmptyStateImage.setImageDrawable( - getResources().getDrawable(R.drawable.ic_empty_bubble_overflow_light)); + 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_YES: - if (DEBUG_OVERFLOW) { - Log.d(TAG, "Set overflow UI to dark mode"); - } + + case Configuration.UI_MODE_NIGHT_NO: mEmptyStateImage.setImageDrawable( - getResources().getDrawable(R.drawable.ic_empty_bubble_overflow_dark)); + 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<Bubble> 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 dd999c22e1fe..7cec3d9015d9 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. |