From 7a2f2a3a1ecb9d5019fea956a0cd3f8574a6b1f0 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 15 May 2023 14:38:46 -0700 Subject: [PATCH] Fix themes of the bubble manage button Still not entirely sure why this is needed. Both of these views get reinflated on theme change, and some of their colors are updated correctly (e.g. font color) but the background color of the drawable is not. Pulling the color from the theme attributes and applying it directly to the background resolves the issue. Bug: 281748524 Test: manual - have a bubble, change the theme, open the bubble, check that the manage menu (and contents of menu) render in the correct theme. Change-Id: I339886d1f1a0ff5b817c106f707518263c67ab07 --- .../com/android/wm/shell/bubbles/BubbleExpandedView.java | 8 +++++++- .../src/com/android/wm/shell/bubbles/BubbleStackView.java | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index adc0c9c4322ae..9fcd207dc3700 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -46,6 +46,7 @@ import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Picture; import android.graphics.PointF; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.ShapeDrawable; import android.os.RemoteException; @@ -479,13 +480,18 @@ public class BubbleExpandedView extends LinearLayout { void applyThemeAttrs() { final TypedArray ta = mContext.obtainStyledAttributes(new int[]{ android.R.attr.dialogCornerRadius, - com.android.internal.R.attr.materialColorSurfaceBright}); + com.android.internal.R.attr.materialColorSurfaceBright, + com.android.internal.R.attr.materialColorSurfaceContainerHigh}); boolean supportsRoundedCorners = ScreenDecorationsUtils.supportsRoundedCornersOnWindows( mContext.getResources()); mCornerRadius = supportsRoundedCorners ? ta.getDimensionPixelSize(0, 0) : 0; mBackgroundColorFloating = ta.getColor(1, Color.WHITE); mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating); + final int manageMenuBg = ta.getColor(2, Color.WHITE); ta.recycle(); + if (mManageButton != null) { + mManageButton.getBackground().setColorFilter(manageMenuBg, PorterDuff.Mode.SRC_IN); + } if (mTaskView != null) { mTaskView.setCornerRadius(mCornerRadius); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 8e9fc1131e4aa..a48be5ed5ad5d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -38,8 +38,10 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.Outline; import android.graphics.PointF; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; @@ -1203,6 +1205,12 @@ public class BubbleStackView extends FrameLayout R.layout.bubble_manage_menu, this, false); mManageMenu.setVisibility(View.INVISIBLE); + final TypedArray ta = mContext.obtainStyledAttributes(new int[]{ + com.android.internal.R.attr.materialColorSurfaceBright}); + final int menuBackgroundColor = ta.getColor(0, Color.WHITE); + ta.recycle(); + mManageMenu.getBackground().setColorFilter(menuBackgroundColor, PorterDuff.Mode.SRC_IN); + PhysicsAnimator.getInstance(mManageMenu).setDefaultSpringConfig(mManageSpringConfig); mManageMenu.setOutlineProvider(new ViewOutlineProvider() {