diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java index e1e3eec790..1f914bfd30 100644 --- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java +++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java @@ -27,16 +27,19 @@ 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; import androidx.annotation.ColorInt; import androidx.annotation.VisibleForTesting; +import com.android.launcher3.Flags; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.FloatingHeaderRow; import com.android.launcher3.allapps.FloatingHeaderView; +import com.android.launcher3.util.Themes; /** * A view which shows a horizontal divider @@ -53,8 +56,8 @@ public class AppsDividerView extends View implements FloatingHeaderRow { private final TextPaint mPaint = new TextPaint(); private DividerType mDividerType = DividerType.NONE; - private final @ColorInt int mStrokeColor; - private final @ColorInt int mAllAppsLabelTextColor; + private @ColorInt int mStrokeColor; + private @ColorInt int mAllAppsLabelTextColor; private final AccessibilityManager mAccessibilityManager; private Layout mAllAppsLabelLayout; @@ -84,8 +87,9 @@ public class AppsDividerView extends View implements FloatingHeaderRow { getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height) }; - mStrokeColor = context.getColor(R.color.materialColorOutlineVariant); - + mStrokeColor = Flags.allAppsBlur() + ? Themes.getAttrColor(context, R.attr.bottomSheetDragHandleColor) + : context.getColor(R.color.materialColorOutlineVariant); mAllAppsLabelTextColor = context.getColor(R.color.materialColorOnSurfaceVariant); mAccessibilityManager = AccessibilityManager.getInstance(context); @@ -99,6 +103,19 @@ 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 fe1de21e84..1c4ea12b59 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -88,6 +88,7 @@ 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; @@ -463,10 +464,11 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, if (!Flags.allAppsBlur() && !enableOverviewBackgroundWallpaperBlur()) { return; } - getTheme().applyStyle(getBlurStyleResId(), true); + int blurStyleResId = getBlurStyleResId(); + getTheme().applyStyle(blurStyleResId, true); if (Flags.allAppsBlur()) { - getAppsView().getContext().getTheme().applyStyle(getBlurStyleResId(), true); - getAppsView().onThemeChanged(); + getAppsView().onThemeChanged( + new ContextThemeWrapper(getApplicationContext(), blurStyleResId)); } if (enableOverviewBackgroundWallpaperBlur()) { getScrimView().setBackgroundColor( diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index c408a3021f..75757a4e95 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -50,6 +50,7 @@ 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,13 +858,13 @@ public class ActivityAllAppsContainerView } /** Refresh the UI according to the current theme. */ - public void onThemeChanged() { + public void onThemeChanged(ContextThemeWrapper contextThemeWrapper) { updateHeaderScroll(getActiveRecyclerView().computeVerticalScrollOffset()); invalidateHeader(); forAllRecyclerViews(RecyclerView::invalidateItemDecorations); getSearchUiManager().onThemeChanged(); - getFloatingHeaderView().getTabLayout().updateTheme(); - mBottomSheetHandle.setBackground(getContext().getDrawable( + getFloatingHeaderView().updateTheme(contextThemeWrapper); + mBottomSheetHandle.setBackground(contextThemeWrapper.getDrawable( R.drawable.bg_rounded_corner_bottom_sheet_handle)); } diff --git a/src/com/android/launcher3/allapps/FloatingHeaderRow.java b/src/com/android/launcher3/allapps/FloatingHeaderRow.java index 75e527aaa8..c64e720c75 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderRow.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderRow.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.allapps; +import android.view.ContextThemeWrapper; import android.view.View; /** @@ -60,4 +61,7 @@ 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 896a4e1073..040d6cf33d 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -23,6 +23,7 @@ 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; @@ -275,6 +276,14 @@ 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/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java index 0d30d5f2e3..f95ac7ce1a 100644 --- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java +++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java @@ -18,6 +18,7 @@ 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,10 +48,10 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd } /** Update the buttons background to match the theme. */ - public void updateTheme() { + public void updateTheme(ContextThemeWrapper contextThemeWrapper) { for (int i = 0; i < getChildCount(); i++) { Button tab = (Button) getChildAt(i); - tab.setBackground(getContext().getDrawable(R.drawable.all_apps_tabs_background)); + tab.setBackground(contextThemeWrapper.getDrawable(R.drawable.all_apps_tabs_background)); } }