From dc681e83e71b99b7bc348b33d125dc60e629fef6 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Mon, 19 May 2025 19:20:34 -0700 Subject: [PATCH] Only update All Apps scrim (panel) when blur state changes. Previously we updated many other things, such as the buttons and RV decorators, but the latest UX guidance is to use the same colors when blurs are enabled or disabled, other than the panel color. Note: When Overview blur is enabled, the activity is recreated and this change is redundant. So this is only done if that flag is off. Demo with home and taskbar all apps (toggling blur with adb): https://drive.google.com/file/d/1HzveExKpAERxMVdu7JXQSYeGRwaBNR4_/view?usp=sharing&resourcekey=0-l-dGWOS6aCQjj2KStvwySA Fix: 413229346 Flag: com.android.launcher3.all_apps_blur Test: Manual with battery saver and `adb shell wm disable-blur 1` / 0 Change-Id: I55c9b46f0999c574c29a6ac7ae557b1e30d91d15 --- .../appprediction/AppsDividerView.java | 18 ++---------------- .../uioverrides/QuickstepLauncher.java | 11 ++++------- .../allapps/ActivityAllAppsContainerView.java | 12 ------------ .../launcher3/allapps/FloatingHeaderRow.java | 4 ---- .../launcher3/allapps/FloatingHeaderView.java | 9 --------- .../launcher3/allapps/SearchUiManager.java | 3 --- .../PersonalWorkSlidingTabStrip.java | 9 --------- 7 files changed, 6 insertions(+), 60 deletions(-) diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java index 1f914bfd30..ea5d5a40b6 100644 --- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java +++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java @@ -27,7 +27,6 @@ import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.View; import android.view.accessibility.AccessibilityManager; @@ -56,8 +55,8 @@ public class AppsDividerView extends View implements FloatingHeaderRow { private final TextPaint mPaint = new TextPaint(); private DividerType mDividerType = DividerType.NONE; - private @ColorInt int mStrokeColor; - private @ColorInt int mAllAppsLabelTextColor; + private final @ColorInt int mStrokeColor; + private final @ColorInt int mAllAppsLabelTextColor; private final AccessibilityManager mAccessibilityManager; private Layout mAllAppsLabelLayout; @@ -103,19 +102,6 @@ public class AppsDividerView extends View implements FloatingHeaderRow { updateDividerType(); } - @Override - public void updateTheme(ContextThemeWrapper contextThemeWrapper) { - mStrokeColor = Themes.getAttrColor(contextThemeWrapper, R.attr.bottomSheetDragHandleColor); - mAllAppsLabelTextColor = - contextThemeWrapper.getColor(R.color.materialColorOnSurfaceVariant); - if (mDividerType == DividerType.LINE) { - mPaint.setColor(mStrokeColor); - } else if (mDividerType == DividerType.ALL_APPS_LABEL) { - mPaint.setColor(mAllAppsLabelTextColor); - } - invalidate(); - } - /** {@code true} if all apps label should be shown in place of divider. */ public void setShowAllAppsLabel(boolean showAllAppsLabel) { if (mAccessibilityManager.isEnabled() && !Utilities.isRunningInTestHarness()) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 86113841c3..13d6dc43fe 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -88,7 +88,6 @@ import android.os.Trace; import android.os.UserHandle; import android.text.TextUtils; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.Display; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; @@ -471,16 +470,14 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, /** Apply the blur or blur fallback style to the current theme. */ public void updateBlurStyle() { - if (Flags.allAppsBlur()) { - int allAppsBlurStyleResId = getAllAppsBlurStyleResId(); - getTheme().applyStyle(allAppsBlurStyleResId, true); - getAppsView().onThemeChanged( - new ContextThemeWrapper(getApplicationContext(), allAppsBlurStyleResId)); - } if (enableOverviewBackgroundWallpaperBlur()) { if (isOverviewBackgroundBlurEnabled() != mOverviewBlurEnabled) { mWallpaperThemeManager.recreateToUpdateTheme(); } + } else if (Flags.allAppsBlur()) { + // For all apps, we only need to update the scrim, which draws the panel. But if the + // activity was recreated above, this is unnecessary. + getAppsView().invalidateHeader(); } } diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 1e9ab0b2a2..e79dd2e60a 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -50,7 +50,6 @@ import android.os.UserManager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; -import android.view.ContextThemeWrapper; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -857,17 +856,6 @@ public class ActivityAllAppsContainerView return Flags.allAppsBlur() && mActivityContext.isAllAppsBackgroundBlurEnabled(); } - /** Refresh the UI according to the current theme. */ - public void onThemeChanged(ContextThemeWrapper contextThemeWrapper) { - updateHeaderScroll(getActiveRecyclerView().computeVerticalScrollOffset()); - invalidateHeader(); - forAllRecyclerViews(RecyclerView::invalidateItemDecorations); - getSearchUiManager().onThemeChanged(); - getFloatingHeaderView().updateTheme(contextThemeWrapper); - mBottomSheetHandle.setBackground(contextThemeWrapper.getDrawable( - R.drawable.bg_rounded_corner_bottom_sheet_handle)); - } - /** * @return true if the search bar is floating above this container (at the bottom of the screen) */ diff --git a/src/com/android/launcher3/allapps/FloatingHeaderRow.java b/src/com/android/launcher3/allapps/FloatingHeaderRow.java index c64e720c75..75e527aaa8 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderRow.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderRow.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; -import android.view.ContextThemeWrapper; import android.view.View; /** @@ -61,7 +60,4 @@ public interface FloatingHeaderRow { default boolean isVisible() { return shouldDraw(); } - - /** Update colors using the provided theme wrapper. */ - default void updateTheme(ContextThemeWrapper contextThemeWrapper) {} } diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java index 040d6cf33d..896a4e1073 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -23,7 +23,6 @@ import android.graphics.Point; import android.graphics.Rect; import android.util.ArrayMap; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -276,14 +275,6 @@ public class FloatingHeaderView extends LinearLayout implements mTabLayout.setVisibility(mTabsHidden ? GONE : visibility); } - /** Update colors using the provided theme wrapper. */ - void updateTheme(ContextThemeWrapper contextThemeWrapper) { - getTabLayout().updateTheme(contextThemeWrapper); - for (FloatingHeaderRow row : mAllRows) { - row.updateTheme(contextThemeWrapper); - } - } - /** Returns whether search bar has multi-line support, and is currently in multi-line state. */ private boolean isSearchBarMultiline() { return Flags.multilineSearchBar() && mSearchBarOffset > 0; diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java index 1f7532c3e4..bfd89678df 100644 --- a/src/com/android/launcher3/allapps/SearchUiManager.java +++ b/src/com/android/launcher3/allapps/SearchUiManager.java @@ -48,9 +48,6 @@ public interface SearchUiManager { @Nullable ExtendedEditText getEditText(); - /** Indicates the UI should refresh according to the current theme. */ - default void onThemeChanged() {} - /** * Hint to the edit text that it is about to be focused or unfocused. This can be used to start * animating the edit box accordingly, e.g. after a gesture completes. diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java index f95ac7ce1a..5fce8bfba3 100644 --- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java +++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java @@ -18,7 +18,6 @@ package com.android.launcher3.workprofile; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.widget.Button; import android.widget.LinearLayout; @@ -47,14 +46,6 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd typedArray.recycle(); } - /** Update the buttons background to match the theme. */ - public void updateTheme(ContextThemeWrapper contextThemeWrapper) { - for (int i = 0; i < getChildCount(); i++) { - Button tab = (Button) getChildAt(i); - tab.setBackground(contextThemeWrapper.getDrawable(R.drawable.all_apps_tabs_background)); - } - } - /** * Highlights tab with index pos */