Merge "Dark grey overflow in dark mode" into rvc-dev am: 77d0f42ff9 am: ef4b8c7dad

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11842538

Change-Id: Ia04a82ccdc6e41dd8567af243ce993f185f77f1d
This commit is contained in:
TreeHugger Robot
2020-06-13 02:21:13 +00:00
committed by Automerger Merge Worker
5 changed files with 34 additions and 42 deletions

View File

@@ -203,8 +203,8 @@
<color name="global_screenshot_background_protection_start">#40000000</color> <!-- 25% black --> <color name="global_screenshot_background_protection_start">#40000000</color> <!-- 25% black -->
<!-- Bubbles --> <!-- Bubbles -->
<color name="bubbles_pointer_light">#FFFFFF</color> <color name="bubbles_light">#FFFFFF</color>
<color name="bubbles_pointer_dark">@color/GM2_grey_800</color> <color name="bubbles_dark">@color/GM2_grey_800</color>
<!-- GM2 colors --> <!-- GM2 colors -->
<color name="GM2_grey_50">#F8F9FA</color> <color name="GM2_grey_50">#F8F9FA</color>

View File

@@ -437,10 +437,10 @@ public class BubbleExpandedView extends LinearLayout {
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (mode) { switch (mode) {
case Configuration.UI_MODE_NIGHT_NO: case Configuration.UI_MODE_NIGHT_NO:
mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_pointer_light)); mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_light));
break; break;
case Configuration.UI_MODE_NIGHT_YES: case Configuration.UI_MODE_NIGHT_YES:
mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_pointer_dark)); mPointerDrawable.setTint(getResources().getColor(R.color.bubbles_dark));
break; break;
} }
mPointerView.setBackground(mPointerDrawable); mPointerView.setBackground(mPointerDrawable);

View File

@@ -22,9 +22,9 @@ import static android.view.View.GONE;
import static com.android.systemui.bubbles.BadgedImageView.DEFAULT_PATH_SIZE; import static com.android.systemui.bubbles.BadgedImageView.DEFAULT_PATH_SIZE;
import android.content.Context; 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.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.AdaptiveIconDrawable;
@@ -88,19 +88,23 @@ public class BubbleOverflow implements BubbleViewProvider {
false /* attachToRoot */); false /* attachToRoot */);
mOverflowBtn.setContentDescription(mContext.getResources().getString( mOverflowBtn.setContentDescription(mContext.getResources().getString(
R.string.bubble_overflow_button_content_description)); R.string.bubble_overflow_button_content_description));
Resources res = mContext.getResources();
TypedArray ta = mContext.obtainStyledAttributes( // Set color for button icon and dot
new int[]{android.R.attr.colorBackgroundFloating});
int bgColor = ta.getColor(0, Color.WHITE /* default */);
ta.recycle();
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
mContext.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true); mContext.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
int colorAccent = mContext.getColor(typedValue.resourceId); int colorAccent = mContext.getColor(typedValue.resourceId);
mOverflowBtn.getDrawable().setTint(colorAccent); mOverflowBtn.getDrawable().setTint(colorAccent);
mDotColor = 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(), InsetDrawable fg = new InsetDrawable(mOverflowBtn.getDrawable(),
mBitmapSize - mIconBitmapSize /* inset */); mBitmapSize - mIconBitmapSize /* inset */);
AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(bg, fg); AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(bg, fg);
@@ -110,6 +114,7 @@ public class BubbleOverflow implements BubbleViewProvider {
null /* user */, null /* user */,
true /* shrinkNonAdaptiveIcons */).icon; true /* shrinkNonAdaptiveIcons */).icon;
// Get path with dot location
float scale = iconFactory.getNormalizer().getScale(mOverflowBtn.getDrawable(), float scale = iconFactory.getNormalizer().getScale(mOverflowBtn.getDrawable(),
null /* outBounds */, null /* path */, null /* outMaskShape */); null /* outBounds */, null /* path */, null /* outMaskShape */);
float radius = DEFAULT_PATH_SIZE / 2f; float radius = DEFAULT_PATH_SIZE / 2f;
@@ -120,14 +125,9 @@ public class BubbleOverflow implements BubbleViewProvider {
radius /* pivot y */); radius /* pivot y */);
mPath.transform(matrix); mPath.transform(matrix);
mOverflowBtn.setVisibility(GONE);
mOverflowBtn.setRenderedBubble(this); mOverflowBtn.setRenderedBubble(this);
} }
ImageView getBtn() {
return mOverflowBtn;
}
void setVisible(int visible) { void setVisible(int visible) {
mOverflowBtn.setVisibility(visible); mOverflowBtn.setVisibility(visible);
} }

View File

@@ -27,6 +27,7 @@ import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
@@ -100,7 +101,6 @@ public class BubbleOverflowActivity extends Activity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.bubble_overflow_activity); setContentView(R.layout.bubble_overflow_activity);
setBackgroundColor();
mEmptyState = findViewById(R.id.bubble_overflow_empty_state); mEmptyState = findViewById(R.id.bubble_overflow_empty_state);
mRecyclerView = findViewById(R.id.bubble_overflow_recycler); mRecyclerView = findViewById(R.id.bubble_overflow_recycler);
@@ -141,34 +141,25 @@ public class BubbleOverflowActivity extends Activity {
* Handle theme changes. * Handle theme changes.
*/ */
void updateTheme() { void updateTheme() {
final int mode = Resources res = getResources();
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; final int mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (mode) { 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: case Configuration.UI_MODE_NIGHT_YES:
if (DEBUG_OVERFLOW) {
Log.d(TAG, "Set overflow UI to dark mode");
}
mEmptyStateImage.setImageDrawable( 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; 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) { void onDataChanged(List<Bubble> bubbles) {
mOverflowBubbles.clear(); mOverflowBubbles.clear();
mOverflowBubbles.addAll(bubbles); mOverflowBubbles.addAll(bubbles);

View File

@@ -1100,16 +1100,17 @@ public class BubbleStackView extends FrameLayout
mBubbleOverflow = new BubbleOverflow(getContext()); mBubbleOverflow = new BubbleOverflow(getContext());
mBubbleOverflow.setUpOverflow(mBubbleContainer, this); mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
} else { } else {
mBubbleContainer.removeView(mBubbleOverflow.getBtn()); mBubbleContainer.removeView(mBubbleOverflow.getIconView());
mBubbleOverflow.setUpOverflow(mBubbleContainer, this); mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
overflowBtnIndex = mBubbleContainer.getChildCount(); overflowBtnIndex = mBubbleContainer.getChildCount();
} }
mBubbleContainer.addView(mBubbleOverflow.getBtn(), overflowBtnIndex, mBubbleContainer.addView(mBubbleOverflow.getIconView(), overflowBtnIndex,
new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
mBubbleOverflow.getBtn().setOnClickListener(v -> { mBubbleOverflow.getIconView().setOnClickListener(v -> {
setSelectedBubble(mBubbleOverflow); setSelectedBubble(mBubbleOverflow);
showManageMenu(false); showManageMenu(false);
}); });
updateOverflowVisibility();
} }
/** /**
* Handle theme changes. * Handle theme changes.