Bubbles styling: Update colors to use new theme things

- Bubble expanded view arrow is now based on backgroundColorFloating
- Bubble overflow expanded view also uses backgroundColorFloating
- Bubble overflow button uses colorAccentPrimary for the circle
  & a dark accent color for the '+' shape
- Manage menu uses colorSurface, had to rename the file bc sysui
  has a file with same name but different colour which was clobbering
  ours

Test: make a bubble & observe UI in light and dark mode, check
      the arrow in the expanded view, the overflow button & expanded
      state, and tapping on the manage menu
Bug: 183658029
Bug: 183658858
Change-Id: Iab5e5536036a8eaecd1c547e5dcfc9d4e77fe5d4
This commit is contained in:
Mady Mellor
2021-05-11 16:07:18 -07:00
parent 56b1e99d02
commit 367d8ea45f
5 changed files with 26 additions and 30 deletions

View File

@@ -15,8 +15,9 @@
~ limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<solid android:color="?android:attr/colorBackgroundFloating" />
<solid android:color="?androidprv:attr/colorSurface" />
<corners
android:bottomLeftRadius="?android:attr/dialogCornerRadius"
android:topLeftRadius="?android:attr/dialogCornerRadius"

View File

@@ -17,7 +17,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg_full"
android:background="@drawable/bubble_manage_menu_bg"
android:elevation="@dimen/bubble_manage_menu_elevation"
android:orientation="vertical">

View File

@@ -111,6 +111,7 @@ public class BubbleExpandedView extends LinearLayout {
private ShapeDrawable mRightPointer;
private int mExpandedViewPadding;
private float mCornerRadius = 0f;
private int mBackgroundColorFloating;
@Nullable private Bubble mBubble;
private PendingIntent mPendingIntent;
@@ -384,7 +385,11 @@ public class BubbleExpandedView extends LinearLayout {
android.R.attr.dialogCornerRadius,
android.R.attr.colorBackgroundFloating});
mCornerRadius = ta.getDimensionPixelSize(0, 0);
mExpandedViewContainer.setBackgroundColor(ta.getColor(1, Color.WHITE));
final int mode =
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
final boolean isNightMode = (mode == Configuration.UI_MODE_NIGHT_YES);
mBackgroundColorFloating = ta.getColor(1, isNightMode ? Color.BLACK : Color.WHITE);
mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating);
ta.recycle();
if (mTaskView != null && ScreenDecorationsUtils.supportsRoundedCornersOnWindows(
@@ -395,16 +400,6 @@ public class BubbleExpandedView extends LinearLayout {
}
private void updatePointerView() {
final int mode =
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (mode) {
case Configuration.UI_MODE_NIGHT_NO:
mCurrentPointer.setTint(getResources().getColor(R.color.bubbles_light));
break;
case Configuration.UI_MODE_NIGHT_YES:
mCurrentPointer.setTint(getResources().getColor(R.color.bubbles_dark));
break;
}
LayoutParams lp = (LayoutParams) mPointerView.getLayoutParams();
if (mCurrentPointer == mLeftPointer || mCurrentPointer == mRightPointer) {
lp.width = mPointerHeight;
@@ -414,6 +409,7 @@ public class BubbleExpandedView extends LinearLayout {
lp.height = mPointerHeight;
}
mPointerView.setLayoutParams(lp);
mCurrentPointer.setTint(mBackgroundColorFloating);
mPointerView.setBackground(mCurrentPointer);
}

View File

@@ -18,7 +18,6 @@ package com.android.wm.shell.bubbles
import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.content.Context
import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.Matrix
import android.graphics.Path
@@ -93,22 +92,21 @@ class BubbleOverflow(
// Set overflow button accent color, dot color
val typedValue = TypedValue()
context.theme.resolveAttribute(android.R.attr.colorAccent, typedValue, true)
context.theme.resolveAttribute(com.android.internal.R.attr.colorAccentPrimary,
typedValue, true)
val colorAccent = res.getColor(typedValue.resourceId, null)
overflowBtn?.drawable?.setTint(colorAccent)
dotColor = colorAccent
val shapeColor = res.getColor(android.R.color.system_accent1_1000)
overflowBtn?.drawable?.setTint(shapeColor)
val iconFactory = BubbleIconFactory(context)
// Update bitmap
val nightMode = (res.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
== Configuration.UI_MODE_NIGHT_YES)
val bg = ColorDrawable(res.getColor(
if (nightMode) R.color.bubbles_dark else R.color.bubbles_light, null))
val fg = InsetDrawable(overflowBtn?.drawable,
bitmapSize - iconBitmapSize /* inset */)
bitmap = iconFactory.createBadgedIconBitmap(AdaptiveIconDrawable(bg, fg),
bitmap = iconFactory.createBadgedIconBitmap(AdaptiveIconDrawable(
ColorDrawable(colorAccent), fg),
null /* user */, true /* shrinkNonAdaptiveIcons */).icon
// Update dot path

View File

@@ -89,15 +89,16 @@ public class BubbleOverflowContainerView extends LinearLayout {
}
public BubbleOverflowContainerView(Context context) {
super(context);
this(context, null);
}
public BubbleOverflowContainerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this(context, attrs, 0);
}
public BubbleOverflowContainerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
public BubbleOverflowContainerView(Context context, @Nullable AttributeSet attrs,
int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public BubbleOverflowContainerView(Context context, AttributeSet attrs, int defStyleAttr,
@@ -170,14 +171,14 @@ public class BubbleOverflowContainerView extends LinearLayout {
? res.getColor(R.color.bubbles_dark)
: res.getColor(R.color.bubbles_light));
final TypedArray typedArray = getContext().obtainStyledAttributes(
new int[]{android.R.attr.colorBackgroundFloating,
android.R.attr.textColorSecondary});
final TypedArray typedArray = getContext().obtainStyledAttributes(new int[] {
android.R.attr.colorBackgroundFloating,
android.R.attr.textColorSecondary});
int bgColor = typedArray.getColor(0, isNightMode ? Color.BLACK : Color.WHITE);
int textColor = typedArray.getColor(1, isNightMode ? Color.WHITE : Color.BLACK);
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, isNightMode);
typedArray.recycle();
setBackgroundColor(bgColor);
mEmptyStateTitle.setTextColor(textColor);
mEmptyStateSubtitle.setTextColor(textColor);
}