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
This commit is contained in:
Mady Mellor
2023-05-15 14:38:46 -07:00
parent 6e5749c35f
commit 7a2f2a3a1e
2 changed files with 15 additions and 1 deletions

View File

@@ -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);

View File

@@ -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() {