Merge "Implement light mode for persistent Taskbar." into udc-dev am: 977a62fa41

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21617425

Change-Id: I6c5c35637b9b96a15eb6a906469977218e198d38
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Brian Isganitis
2023-03-03 01:32:02 +00:00
committed by Automerger Merge Worker
12 changed files with 66 additions and 89 deletions
@@ -24,7 +24,6 @@ import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITION
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.annotation.ColorInt;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import android.view.TaskTransitionSpec; import android.view.TaskTransitionSpec;
@@ -231,16 +230,9 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
WindowManagerGlobal.getWindowManagerService().clearTaskTransitionSpec(); WindowManagerGlobal.getWindowManagerService().clearTaskTransitionSpec();
} else { } else {
// Adjust task transition spec to account for taskbar being visible // Adjust task transition spec to account for taskbar being visible
@ColorInt int taskAnimationBackgroundColor = WindowManagerGlobal.getWindowManagerService().setTaskTransitionSpec(
DisplayController.isTransientTaskbar(mLauncher) new TaskTransitionSpec(
? mLauncher.getColor(R.color.transient_taskbar_background) mLauncher.getColor(R.color.taskbar_background)));
: mLauncher.getColor(R.color.taskbar_background);
TaskTransitionSpec customTaskAnimationSpec = new TaskTransitionSpec(
taskAnimationBackgroundColor
);
WindowManagerGlobal.getWindowManagerService()
.setTaskTransitionSpec(customTaskAnimationSpec);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
// This shouldn't happen but if it does task animations won't look good until the // This shouldn't happen but if it does task animations won't look good until the
@@ -125,8 +125,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
private static final int FLAG_SMALL_SCREEN = 1 << 13; private static final int FLAG_SMALL_SCREEN = 1 << 13;
private static final int FLAG_SLIDE_IN_VIEW_VISIBLE = 1 << 14; private static final int FLAG_SLIDE_IN_VIEW_VISIBLE = 1 << 14;
/** Flags where a UI could be over a slide in view, so the color override should be disabled. */ /**
private static final int FLAGS_SLIDE_IN_VIEW_ICON_COLOR_OVERRIDE_DISABLED = * Flags where a UI could be over Taskbar surfaces, so the color override should be disabled.
*/
private static final int FLAGS_ON_BACKGROUND_COLOR_OVERRIDE_DISABLED =
FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_VOICE_INTERACTION_WINDOW_SHOWING; FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_VOICE_INTERACTION_WINDOW_SHOWING;
private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons"; private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons";
@@ -148,8 +150,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
private final ViewGroup mStartContextualContainer; private final ViewGroup mStartContextualContainer;
private final int mLightIconColor; private final int mLightIconColor;
private final int mDarkIconColor; private final int mDarkIconColor;
/** Color to use for navigation bar buttons, if a slide in view is visible. */ /** Color to use for navigation bar buttons, if they are on on a Taskbar surface background. */
private final int mSlideInViewIconColor; private final int mOnBackgroundIconColor;
private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat( private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
this::updateNavButtonTranslationY); this::updateNavButtonTranslationY);
@@ -160,13 +162,18 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
// Used for System UI state updates that should translate the nav button for in-app display. // Used for System UI state updates that should translate the nav button for in-app display.
private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat( private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat(
this::updateNavButtonInAppDisplayProgressForSysui); this::updateNavButtonInAppDisplayProgressForSysui);
/** Expected nav button dark intensity communicated via the framework. */
private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat( private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat(
this::updateNavButtonDarkIntensity); this::updateNavButtonColor);
private final AnimatedFloat mNavButtonDarkIntensityMultiplier = new AnimatedFloat( /** {@code 1} if the Taskbar background color is fully opaque. */
this::updateNavButtonDarkIntensity); private final AnimatedFloat mOnTaskbarBackgroundNavButtonColorOverride = new AnimatedFloat(
/** Overrides the navigation button color to {@code mSlideInViewIconColor} when {@code 1}. */ this::updateNavButtonColor);
private final AnimatedFloat mSlideInViewNavButtonColorOverride = new AnimatedFloat( /** {@code 1} if a Taskbar slide in overlay is visible over Taskbar. */
this::updateNavButtonDarkIntensity); private final AnimatedFloat mSlideInViewVisibleNavButtonColorOverride = new AnimatedFloat(
this::updateNavButtonColor);
/** Disables the {@link #mOnBackgroundIconColor} override if {@code 0}. */
private final AnimatedFloat mOnBackgroundNavButtonColorOverrideMultiplier = new AnimatedFloat(
this::updateNavButtonColor);
private final RotationButtonListener mRotationButtonListener = new RotationButtonListener(); private final RotationButtonListener mRotationButtonListener = new RotationButtonListener();
private final Rect mFloatingRotationButtonBounds = new Rect(); private final Rect mFloatingRotationButtonBounds = new Rect();
@@ -199,8 +206,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
mLightIconColor = context.getColor(R.color.taskbar_nav_icon_light_color); mLightIconColor = context.getColor(R.color.taskbar_nav_icon_light_color);
mDarkIconColor = context.getColor(R.color.taskbar_nav_icon_dark_color); mDarkIconColor = context.getColor(R.color.taskbar_nav_icon_dark_color);
// Can precompute color since dark theme change recreates taskbar. mOnBackgroundIconColor = Utilities.isDarkTheme(context) ? mLightIconColor : mDarkIconColor;
mSlideInViewIconColor = Utilities.isDarkTheme(context) ? mLightIconColor : mDarkIconColor;
} }
/** /**
@@ -266,10 +272,15 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
flags -> (flags & FLAG_IME_VISIBLE) != 0 && !isInKidsMode, AnimatedFloat.VALUE, flags -> (flags & FLAG_IME_VISIBLE) != 0 && !isInKidsMode, AnimatedFloat.VALUE,
transForIme, defaultButtonTransY)); transForIme, defaultButtonTransY));
// Start at 1 because relevant flags are unset at init.
mOnBackgroundNavButtonColorOverrideMultiplier.value = 1;
mPropertyHolders.add(new StatePropertyHolder( mPropertyHolders.add(new StatePropertyHolder(
mSlideInViewNavButtonColorOverride, mOnBackgroundNavButtonColorOverrideMultiplier,
flags -> ((flags & FLAG_SLIDE_IN_VIEW_VISIBLE) != 0) flags -> (flags & FLAGS_ON_BACKGROUND_COLOR_OVERRIDE_DISABLED) == 0));
&& ((flags & FLAGS_SLIDE_IN_VIEW_ICON_COLOR_OVERRIDE_DISABLED) == 0)));
mPropertyHolders.add(new StatePropertyHolder(
mSlideInViewVisibleNavButtonColorOverride,
flags -> (flags & FLAG_SLIDE_IN_VIEW_VISIBLE) != 0));
if (alwaysShowButtons) { if (alwaysShowButtons) {
initButtons(mNavButtonContainer, mEndContextualContainer, initButtons(mNavButtonContainer, mEndContextualContainer,
@@ -569,9 +580,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
return mTaskbarNavButtonDarkIntensity; return mTaskbarNavButtonDarkIntensity;
} }
/** Use to determine whether to use the dark intensity requested by the underlying app */ /** Use to override the nav button color with {@link #mOnBackgroundIconColor}. */
public AnimatedFloat getNavButtonDarkIntensityMultiplier() { public AnimatedFloat getOnTaskbarBackgroundNavButtonColorOverride() {
return mNavButtonDarkIntensityMultiplier; return mOnTaskbarBackgroundNavButtonColorOverride;
} }
/** /**
@@ -617,14 +628,20 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
+ inAppDisplayAdjustmentTranslationY); + inAppDisplayAdjustmentTranslationY);
} }
private void updateNavButtonDarkIntensity() { private void updateNavButtonColor() {
float darkIntensity = mTaskbarNavButtonDarkIntensity.value final ArgbEvaluator argbEvaluator = ArgbEvaluator.getInstance();
* mNavButtonDarkIntensityMultiplier.value; final int sysUiNavButtonIconColor = (int) argbEvaluator.evaluate(
ArgbEvaluator argbEvaluator = ArgbEvaluator.getInstance(); mTaskbarNavButtonDarkIntensity.value,
int iconColor = (int) argbEvaluator.evaluate( mLightIconColor,
darkIntensity, mLightIconColor, mDarkIconColor); mDarkIconColor);
iconColor = (int) argbEvaluator.evaluate( // Override the color from framework if nav buttons are over an opaque Taskbar surface.
mSlideInViewNavButtonColorOverride.value, iconColor, mSlideInViewIconColor); final int iconColor = (int) argbEvaluator.evaluate(
mOnBackgroundNavButtonColorOverrideMultiplier.value
* Math.max(
mOnTaskbarBackgroundNavButtonColorOverride.value,
mSlideInViewVisibleNavButtonColorOverride.value),
sysUiNavButtonIconColor,
mOnBackgroundIconColor);
for (ImageView button : mAllButtons) { for (ImageView button : mAllButtons) {
button.setImageTintList(ColorStateList.valueOf(iconColor)); button.setImageTintList(ColorStateList.valueOf(iconColor));
} }
@@ -66,8 +66,6 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
paint.style = Paint.Style.FILL paint.style = Paint.Style.FILL
if (isTransientTaskbar) { if (isTransientTaskbar) {
paint.color = context.getColor(R.color.transient_taskbar_background)
val res = context.resources val res = context.resources
bottomMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_margin) bottomMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_margin)
shadowBlur = res.getDimension(R.dimen.transient_taskbar_shadow_blur) shadowBlur = res.getDimension(R.dimen.transient_taskbar_shadow_blur)
@@ -59,10 +59,9 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
// Initialized in init. // Initialized in init.
private TaskbarControllers mControllers; private TaskbarControllers mControllers;
private AnimatedFloat mNavButtonDarkIntensityMultiplier; private AnimatedFloat mOnBackgroundNavButtonColorIntensity;
private float mLastSetBackgroundAlpha; private float mLastSetBackgroundAlpha;
private boolean mIsBackgroundDrawnElsewhere;
public TaskbarDragLayerController(TaskbarActivityContext activity, public TaskbarDragLayerController(TaskbarActivityContext activity,
TaskbarDragLayer taskbarDragLayer) { TaskbarDragLayer taskbarDragLayer) {
@@ -77,8 +76,8 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
mControllers = controllers; mControllers = controllers;
mTaskbarDragLayer.init(new TaskbarDragLayerCallbacks()); mTaskbarDragLayer.init(new TaskbarDragLayerCallbacks());
mNavButtonDarkIntensityMultiplier = mControllers.navbarButtonsViewController mOnBackgroundNavButtonColorIntensity = mControllers.navbarButtonsViewController
.getNavButtonDarkIntensityMultiplier(); .getOnTaskbarBackgroundNavButtonColorOverride();
mBgTaskbar.value = 1; mBgTaskbar.value = 1;
mKeyguardBgTaskbar.value = 1; mKeyguardBgTaskbar.value = 1;
@@ -152,7 +151,7 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar); mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar);
mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha); mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha);
updateNavBarDarkIntensityMultiplier(); updateOnBackgroundNavButtonColorIntensity();
} }
/** /**
@@ -165,7 +164,7 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
private void updateBackgroundOffset() { private void updateBackgroundOffset() {
mTaskbarDragLayer.setTaskbarBackgroundOffset(mBgOffset.value); mTaskbarDragLayer.setTaskbarBackgroundOffset(mBgOffset.value);
updateNavBarDarkIntensityMultiplier(); updateOnBackgroundNavButtonColorIntensity();
} }
@Override @Override
@@ -174,23 +173,16 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
} }
/** /**
* Set if another controller is temporarily handling background drawing. In this case we: * Set if another controller is temporarily handling background drawing. In this case we
* - Override our background alpha to be 0. * override our background alpha to be {@code 0}.
* - Keep the nav bar dark intensity assuming taskbar background is at full alpha.
*/ */
public void setIsBackgroundDrawnElsewhere(boolean isBackgroundDrawnElsewhere) { public void setIsBackgroundDrawnElsewhere(boolean isBackgroundDrawnElsewhere) {
mIsBackgroundDrawnElsewhere = isBackgroundDrawnElsewhere; mBgOverride.updateValue(isBackgroundDrawnElsewhere ? 0 : 1);
mBgOverride.updateValue(mIsBackgroundDrawnElsewhere ? 0 : 1);
updateNavBarDarkIntensityMultiplier();
} }
private void updateNavBarDarkIntensityMultiplier() { private void updateOnBackgroundNavButtonColorIntensity() {
// Zero out the app-requested dark intensity when we're drawing our own background. mOnBackgroundNavButtonColorIntensity.updateValue(
float effectiveBgAlpha = mLastSetBackgroundAlpha * (1 - mBgOffset.value); mLastSetBackgroundAlpha * (1 - mBgOffset.value));
if (mIsBackgroundDrawnElsewhere) {
effectiveBgAlpha = 1;
}
mNavButtonDarkIntensityMultiplier.updateValue(1 - effectiveBgAlpha);
} }
@Override @Override
@@ -142,9 +142,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
: R.drawable.ic_taskbar_all_apps_button)); : R.drawable.ic_taskbar_all_apps_button));
mAllAppsButton.setScaleX(mIsRtl ? -1 : 1); mAllAppsButton.setScaleX(mIsRtl ? -1 : 1);
mAllAppsButton.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding); mAllAppsButton.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
mAllAppsButton.setForegroundTint(mActivityContext.getColor(isTransientTaskbar mAllAppsButton.setForegroundTint(
? R.color.all_apps_button_color mActivityContext.getColor(R.color.all_apps_button_color));
: R.color.all_apps_button_color_dark));
if (FeatureFlags.ENABLE_TASKBAR_PINNING.get()) { if (FeatureFlags.ENABLE_TASKBAR_PINNING.get()) {
mTaskbarDivider = LayoutInflater.from(context).inflate(R.layout.taskbar_divider, mTaskbarDivider = LayoutInflater.from(context).inflate(R.layout.taskbar_divider,
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project <!-- Copyright (C) 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -16,4 +16,3 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_500" android:lStar="15" /> <item android:color="@android:color/system_neutral1_500" android:lStar="15" />
</selector> </selector>
+1 -1
View File
@@ -14,5 +14,5 @@
limitations under the License. limitations under the License.
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_500" android:lStar="15" /> <item android:color="@android:color/system_neutral1_500" android:lStar="95" />
</selector> </selector>
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_500" android:lStar="95" />
</selector>
+2
View File
@@ -24,4 +24,6 @@
<color name="home_settings_thumb_off_color">@android:color/system_neutral2_300</color> <color name="home_settings_thumb_off_color">@android:color/system_neutral2_300</color>
<color name="home_settings_track_on_color">@android:color/system_accent2_700</color> <color name="home_settings_track_on_color">@android:color/system_accent2_700</color>
<color name="home_settings_track_off_color">@android:color/system_neutral1_700</color> <color name="home_settings_track_off_color">@android:color/system_neutral1_700</color>
<color name="all_apps_button_color">@android:color/system_neutral2_200</color>
</resources> </resources>
+1 -1
View File
@@ -17,5 +17,5 @@
--> -->
<resources> <resources>
<color name="all_apps_button_color">@color/all_apps_button_color_dark</color> <color name="all_apps_button_color">#BFC8CC</color>
</resources> </resources>
+1 -2
View File
@@ -62,8 +62,7 @@
<color name="preload_icon_accent_color_dark">@android:color/system_accent1_300</color> <color name="preload_icon_accent_color_dark">@android:color/system_accent1_300</color>
<color name="preload_icon_background_color_dark">@android:color/system_neutral2_700</color> <color name="preload_icon_background_color_dark">@android:color/system_neutral2_700</color>
<color name="all_apps_button_color_light">@android:color/system_neutral2_700</color> <color name="all_apps_button_color">@android:color/system_neutral2_700</color>
<color name="all_apps_button_color_dark">@android:color/system_neutral2_200</color>
<color name="widget_picker_background_selected">@android:color/system_accent2_100</color> <color name="widget_picker_background_selected">@android:color/system_accent2_100</color>
</resources> </resources>
+1 -3
View File
@@ -80,9 +80,7 @@
<color name="workspace_accent_color_light">#ff8df5e3</color> <color name="workspace_accent_color_light">#ff8df5e3</color>
<color name="workspace_accent_color_dark">#ff3d665f</color> <color name="workspace_accent_color_dark">#ff3d665f</color>
<color name="all_apps_button_color">@color/all_apps_button_color_light</color> <color name="all_apps_button_color">#40484B</color>
<color name="all_apps_button_color_light">#40484B</color>
<color name="all_apps_button_color_dark">#BFC8CC</color>
<color name="preload_icon_accent_color_light">#00668B</color> <color name="preload_icon_accent_color_light">#00668B</color>
<color name="preload_icon_background_color_light">#B5CAD7</color> <color name="preload_icon_background_color_light">#B5CAD7</color>