From a841ff861b1a03c01024012a403e6807ed20a4f3 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Tue, 25 Apr 2023 15:02:40 -0400 Subject: [PATCH] Updates to color tokens for Bubbles according to new spec. Test: Verified changes by testing on a physical device. Fixes: 275090254 Change-Id: I500ebe22d090080f4ca3e26e5f25f6ef9843f86b --- .../res/drawable/bubble_manage_btn_bg.xml | 3 +- .../res/drawable/bubble_manage_menu_bg.xml | 2 +- .../Shell/res/layout/bubble_flyout.xml | 5 +- .../Shell/res/layout/bubble_manage_button.xml | 3 +- .../Shell/res/layout/bubble_manage_menu.xml | 4 + .../wm/shell/bubbles/BubbleFlyoutView.java | 2 +- .../wm/shell/bubbles/BubbleOverflow.kt | 102 +++++++++++------- .../bubbles/BubbleOverflowContainerView.java | 4 +- 8 files changed, 81 insertions(+), 44 deletions(-) diff --git a/libs/WindowManager/Shell/res/drawable/bubble_manage_btn_bg.xml b/libs/WindowManager/Shell/res/drawable/bubble_manage_btn_bg.xml index 96d2d7c954d83..d2360e9b1ae04 100644 --- a/libs/WindowManager/Shell/res/drawable/bubble_manage_btn_bg.xml +++ b/libs/WindowManager/Shell/res/drawable/bubble_manage_btn_bg.xml @@ -16,9 +16,10 @@ --> diff --git a/libs/WindowManager/Shell/res/drawable/bubble_manage_menu_bg.xml b/libs/WindowManager/Shell/res/drawable/bubble_manage_menu_bg.xml index 4bd2f134d0275..8fd2e68f64519 100644 --- a/libs/WindowManager/Shell/res/drawable/bubble_manage_menu_bg.xml +++ b/libs/WindowManager/Shell/res/drawable/bubble_manage_menu_bg.xml @@ -17,7 +17,7 @@ - + - + diff --git a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml index 0cf6d73162d24..f88d63d796ea2 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml @@ -16,6 +16,7 @@ --> \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/bubble_manage_menu.xml b/libs/WindowManager/Shell/res/layout/bubble_manage_menu.xml index 298ad3025b00d..10c9562cf6515 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_manage_menu.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_manage_menu.xml @@ -15,6 +15,7 @@ ~ limitations under the License --> @@ -66,6 +68,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" + android:textColor="?androidprv:attr/materialColorOnSurface" android:textAppearance="@*android:style/TextAppearance.DeviceDefault" android:text="@string/bubbles_dont_bubble_conversation" /> @@ -92,6 +95,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" + android:textColor="?androidprv:attr/materialColorOnSurface" android:textAppearance="@*android:style/TextAppearance.DeviceDefault" /> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java index f878a46d26f24..6a5f785504c0b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java @@ -177,7 +177,7 @@ public class BubbleFlyoutView extends FrameLayout { final TypedArray ta = mContext.obtainStyledAttributes( new int[] { - com.android.internal.R.attr.colorSurface, + com.android.internal.R.attr.materialColorSurfaceContainer, android.R.attr.dialogCornerRadius}); mFloatingBackgroundColor = ta.getColor(0, Color.WHITE); mCornerRadius = ta.getDimensionPixelSize(1, 0); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt index c49451df31b45..df7f5b4f01501 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt @@ -19,23 +19,21 @@ package com.android.wm.shell.bubbles import android.app.ActivityTaskManager.INVALID_TASK_ID import android.content.Context import android.graphics.Bitmap +import android.graphics.Color import android.graphics.Matrix import android.graphics.Path import android.graphics.drawable.AdaptiveIconDrawable import android.graphics.drawable.ColorDrawable import android.graphics.drawable.InsetDrawable import android.util.PathParser -import android.util.TypedValue import android.view.LayoutInflater import android.widget.FrameLayout import com.android.launcher3.icons.BubbleIconFactory import com.android.wm.shell.R import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView -class BubbleOverflow( - private val context: Context, - private val positioner: BubblePositioner -) : BubbleViewProvider { +class BubbleOverflow(private val context: Context, private val positioner: BubblePositioner) : + BubbleViewProvider { private lateinit var bitmap: Bitmap private lateinit var dotPath: Path @@ -54,7 +52,7 @@ class BubbleOverflow( overflowBtn = null } - /** Call before use and again if cleanUpExpandedState was called. */ + /** Call before use and again if cleanUpExpandedState was called. */ fun initialize(controller: BubbleController) { createExpandedView() getExpandedView()?.initialize(controller, controller.stackView, true /* isOverflow */) @@ -74,10 +72,10 @@ class BubbleOverflow( } fun updateResources() { - overflowIconInset = context.resources.getDimensionPixelSize( - R.dimen.bubble_overflow_icon_inset) - overflowBtn?.layoutParams = FrameLayout.LayoutParams(positioner.bubbleSize, - positioner.bubbleSize) + overflowIconInset = + context.resources.getDimensionPixelSize(R.dimen.bubble_overflow_icon_inset) + overflowBtn?.layoutParams = + FrameLayout.LayoutParams(positioner.bubbleSize, positioner.bubbleSize) expandedView?.updateDimensions() } @@ -85,36 +83,58 @@ class BubbleOverflow( val res = context.resources // Set overflow button accent color, dot color - val typedValue = TypedValue() - context.theme.resolveAttribute(com.android.internal.R.attr.colorAccentPrimary, - typedValue, true) - val colorAccent = res.getColor(typedValue.resourceId, null) - dotColor = colorAccent - val shapeColor = res.getColor(android.R.color.system_accent1_1000) + val typedArray = + context.obtainStyledAttributes( + intArrayOf( + com.android.internal.R.attr.materialColorPrimaryFixed, + com.android.internal.R.attr.materialColorOnPrimaryFixed + ) + ) + + val colorAccent = typedArray.getColor(0, Color.WHITE) + val shapeColor = typedArray.getColor(1, Color.BLACK) + typedArray.recycle() + + dotColor = colorAccent overflowBtn?.iconDrawable?.setTint(shapeColor) - val iconFactory = BubbleIconFactory(context, - context.getResources().getDimensionPixelSize(R.dimen.bubble_size), - context.getResources().getDimensionPixelSize(R.dimen.bubble_badge_size), - context.getResources().getColor(R.color.important_conversation), - context.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.importance_ring_stroke_width)) + val iconFactory = + BubbleIconFactory( + context, + res.getDimensionPixelSize(R.dimen.bubble_size), + res.getDimensionPixelSize(R.dimen.bubble_badge_size), + res.getColor(R.color.important_conversation), + res.getDimensionPixelSize(com.android.internal.R.dimen.importance_ring_stroke_width) + ) // Update bitmap val fg = InsetDrawable(overflowBtn?.iconDrawable, overflowIconInset) - bitmap = iconFactory.createBadgedIconBitmap( - AdaptiveIconDrawable(ColorDrawable(colorAccent), fg)).icon + bitmap = + iconFactory + .createBadgedIconBitmap(AdaptiveIconDrawable(ColorDrawable(colorAccent), fg)) + .icon // Update dot path - dotPath = PathParser.createPathFromPathData( - res.getString(com.android.internal.R.string.config_icon_mask)) - val scale = iconFactory.normalizer.getScale(iconView!!.iconDrawable, - null /* outBounds */, null /* path */, null /* outMaskShape */) + dotPath = + PathParser.createPathFromPathData( + res.getString(com.android.internal.R.string.config_icon_mask) + ) + val scale = + iconFactory.normalizer.getScale( + iconView!!.iconDrawable, + null /* outBounds */, + null /* path */, + null /* outMaskShape */ + ) val radius = BadgedImageView.DEFAULT_PATH_SIZE / 2f val matrix = Matrix() - matrix.setScale(scale /* x scale */, scale /* y scale */, radius /* pivot x */, - radius /* pivot y */) + matrix.setScale( + scale /* x scale */, + scale /* y scale */, + radius /* pivot x */, + radius /* pivot y */ + ) dotPath.transform(matrix) // Attach BubbleOverflow to BadgedImageView @@ -132,8 +152,12 @@ class BubbleOverflow( } fun createExpandedView(): BubbleExpandedView? { - expandedView = inflater.inflate(R.layout.bubble_expanded_view, - null /* root */, false /* attachToRoot */) as BubbleExpandedView + expandedView = + inflater.inflate( + R.layout.bubble_expanded_view, + null /* root */, + false /* attachToRoot */ + ) as BubbleExpandedView expandedView?.applyThemeAttrs() updateResources() return expandedView @@ -177,11 +201,15 @@ class BubbleOverflow( override fun getIconView(): BadgedImageView? { if (overflowBtn == null) { - overflowBtn = inflater.inflate(R.layout.bubble_overflow_button, - null /* root */, false /* attachToRoot */) as BadgedImageView + overflowBtn = + inflater.inflate( + R.layout.bubble_overflow_button, + null /* root */, + false /* attachToRoot */ + ) as BadgedImageView overflowBtn?.initialize(positioner) - overflowBtn?.contentDescription = context.resources.getString( - R.string.bubble_overflow_button_content_description) + overflowBtn?.contentDescription = + context.resources.getString(R.string.bubble_overflow_button_content_description) val bubbleSize = positioner.bubbleSize overflowBtn?.layoutParams = FrameLayout.LayoutParams(bubbleSize, bubbleSize) updateBtnTheme() @@ -200,4 +228,4 @@ class BubbleOverflow( companion object { const val KEY = "Overflow" } -} \ No newline at end of file +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java index 9aa285fff19ce..9655470ce9149 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java @@ -220,8 +220,8 @@ public class BubbleOverflowContainerView extends LinearLayout { : res.getColor(R.color.bubbles_light)); final TypedArray typedArray = getContext().obtainStyledAttributes(new int[] { - android.R.attr.colorBackgroundFloating, - android.R.attr.textColorSecondary}); + com.android.internal.R.attr.materialColorSurfaceBright, + com.android.internal.R.attr.materialColorOnSurface}); 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);