Merge "Update Scrim values for blur" into main

This commit is contained in:
Treehugger Robot authored and Android (Google) Code Review committed 2025-05-30 13:55:44 -07:00
commit e0a2abda93
29 files changed
+305 -54

No files matched your search

@@ -20,6 +20,7 @@ import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;
import android.content.Context;
import android.graphics.Color;
import com.android.internal.jank.Cuj;
import com.android.launcher3.DeviceProfile;
@@ -29,6 +30,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.util.BaseDepthController;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
@@ -203,14 +205,17 @@ public class AllAppsState extends LauncherState {
}
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
int backgroundColor;
if (!launcher.getDeviceProfile().shouldShowAllAppsOnSheet()) {
// Always use an opaque scrim if there's no sheet.
return launcher.getResources().getColor(R.color.materialColorSurfaceDim);
backgroundColor = launcher.getResources().getColor(R.color.materialColorSurfaceDim);
} else if (!Flags.allAppsBlur()) {
// If there's a sheet but no blur, use the old scrim color.
return launcher.getResources().getColor(R.color.widgets_picker_scrim);
backgroundColor = launcher.getResources().getColor(R.color.widgets_picker_scrim);
} else {
backgroundColor = Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
}
return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
return new ScrimColors(backgroundColor, /* foregroundColor */ Color.TRANSPARENT);
}
}
@@ -24,6 +24,7 @@ import android.graphics.Color;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.util.BaseDepthController;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -108,8 +109,10 @@ public class BackgroundAppState extends OverviewState {
}
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
return Color.TRANSPARENT;
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
return new ScrimColors(
/* backgroundColor= */ Color.TRANSPARENT,
/* foregroundColor= */ Color.TRANSPARENT);
}
@Override
@@ -26,6 +26,7 @@ import androidx.core.graphics.ColorUtils;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ScrimColors;
/**
* Scale down workspace/hotseat to hint at going to either overview (on pause) or first home screen.
@@ -60,10 +61,14 @@ public class HintState extends LauncherState {
}
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
int overviewStateColor = OVERVIEW.getWorkspaceScrimColor(launcher);
return ColorUtils.setAlphaComponent(overviewStateColor,
Math.round(Color.valueOf(overviewStateColor).alpha() * 100));
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
ScrimColors overviewStateColor = OVERVIEW.getWorkspaceScrimColor(launcher);
return new ScrimColors(
/* backgroundColor */
ColorUtils.setAlphaComponent(overviewStateColor.getBackgroundColor(),
Math.round(Color.valueOf(overviewStateColor.getBackgroundColor()).alpha()
* 100)),
/* foregroundColor */ Color.TRANSPARENT);
}
@Override
@@ -24,6 +24,8 @@ import android.content.Context;
import android.graphics.Rect;
import android.os.SystemProperties;
import androidx.core.graphics.ColorUtils;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
@@ -31,6 +33,7 @@ import com.android.launcher3.R;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.util.BaseDepthController;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -157,8 +160,12 @@ public class OverviewState extends LauncherState {
}
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
return new ScrimColors(
/* backgroundColor */ Themes.getAttrColor(launcher, R.attr.overviewScrimColor),
/* foregroundColor */ ColorUtils.compositeColors(
Themes.getAttrColor(launcher, R.attr.overviewScrimForegroundPrimary),
Themes.getAttrColor(launcher, R.attr.overviewScrimForegroundSecondary)));
}
@Override
@@ -17,7 +17,7 @@
package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE;
import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
import static com.android.launcher3.LauncherAnimUtils.SCRIM_COLORS;
import static com.android.launcher3.LauncherAnimUtils.newSingleUseCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.HINT_STATE;
@@ -47,6 +47,7 @@ import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.views.ScrimColorsEvaluator;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.MotionPauseDetector;
@@ -86,7 +87,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
private AnimatorPlaybackController mOverviewResistYAnim;
// Normal to Hint animation has flag SKIP_OVERVIEW, so we update this scrim with this animator.
private ObjectAnimator mNormalToHintOverviewScrimAnimator;
private ValueAnimator mNormalToHintOverviewScrimAnimator;
private final QuickstepLauncher mLauncher;
private boolean mIsTrackpadSwipe;
@@ -163,9 +164,10 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
}
if (mFromState == NORMAL && mToState == HINT_STATE) {
mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofArgb(
mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofObject(
mLauncher.getScrimView(),
VIEW_BACKGROUND_COLOR,
SCRIM_COLORS,
ScrimColorsEvaluator.INSTANCE,
mFromState.getWorkspaceScrimColor(mLauncher),
mToState.getWorkspaceScrimColor(mLauncher));
}
@@ -278,8 +278,9 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
// Use QuickSwitchState instead of OverviewState to determine scrim color,
// since we need to take potential taskbar into account.
xAnim.setViewBackgroundColor(mLauncher.getScrimView(),
QUICK_SWITCH_FROM_HOME.getWorkspaceScrimColor(mLauncher), LINEAR);
xAnim.setScrimColors(mLauncher.getScrimView(),
QUICK_SWITCH_FROM_HOME.getWorkspaceScrimColor(mLauncher),
LINEAR);
if (!mRecentsView.hasTaskViews()) {
xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
}
@@ -17,7 +17,7 @@ package com.android.quickstep;
import static com.android.app.animation.Interpolators.INSTANT;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
import static com.android.launcher3.LauncherAnimUtils.SCRIM_COLORS;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
import static com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview;
import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK;
@@ -47,7 +47,9 @@ import com.android.launcher3.statemanager.StatefulContainer;
import com.android.launcher3.taskbar.TaskbarUIController;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.views.ScrimColors;
import com.android.launcher3.views.ScrimView;
import com.android.launcher3.views.ScrimColorsEvaluator;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.ContextInitListener;
@@ -108,7 +110,7 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
* Returns the color of the scrim behind overview when at rest in this state.
* Return {@link Color#TRANSPARENT} for no scrim.
*/
protected abstract int getOverviewScrimColorForState(CONTAINER_TYPE container,
protected abstract ScrimColors getOverviewScrimColorForState(CONTAINER_TYPE container,
STATE_TYPE state);
public abstract int getSwipeUpDestinationAndLength(
@@ -214,12 +216,14 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
RecentsView recentsView = container.getOverviewPanel();
STATE_TYPE state = stateFromGestureEndTarget(endTarget);
ScrimView scrimView = container.getScrimView();
ObjectAnimator anim = ObjectAnimator.ofArgb(scrimView, VIEW_BACKGROUND_COLOR,
getOverviewScrimColorForState(container, state));
anim.setDuration(duration);
anim.setInterpolator(recentsView == null || !recentsView.isKeyboardTaskFocusPending()
? LINEAR : INSTANT);
return anim;
ObjectAnimator animScrim = ObjectAnimator.ofObject(scrimView, SCRIM_COLORS,
ScrimColorsEvaluator.INSTANCE, getOverviewScrimColorForState(container, state));
animScrim.setDuration(duration);
animScrim.setInterpolator(
recentsView == null || !recentsView.isKeyboardTaskFocusPending()
? LINEAR : INSTANT);
return animScrim;
}
return null;
}
@@ -34,6 +34,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.taskbar.FallbackTaskbarUIController;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.GestureState.GestureEndTarget;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
@@ -227,7 +228,8 @@ public final class FallbackActivityInterface extends
}
@Override
protected int getOverviewScrimColorForState(RecentsActivity activity, RecentsState state) {
protected ScrimColors getOverviewScrimColorForState(RecentsActivity activity,
RecentsState state) {
return state.getScrimColor(activity);
}
}
@@ -34,6 +34,7 @@ import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.taskbar.TaskbarUIController;
import com.android.launcher3.util.DaggerSingletonObject;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.GestureState.GestureEndTarget;
import com.android.quickstep.dagger.QuickstepBaseAppComponent;
import com.android.quickstep.fallback.RecentsState;
@@ -48,6 +49,7 @@ import dagger.assisted.AssistedInject;
import java.util.function.Consumer;
import java.util.function.Predicate;
/**
* {@link BaseWindowInterface} for recents when the default launcher is different than the
* currently running one and apps should interact with the {@link RecentsWindowManager} as opposed
@@ -143,7 +145,7 @@ public final class FallbackWindowInterface extends BaseWindowInterface {
}
@Override
protected int getOverviewScrimColorForState(RecentsWindowManager container,
protected ScrimColors getOverviewScrimColorForState(RecentsWindowManager container,
RecentsState state) {
return state.getScrimColor(container.asContext());
}
@@ -44,6 +44,7 @@ import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.GestureState.GestureEndTarget;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.util.AnimatorControllerWithResistance;
@@ -326,7 +327,8 @@ public final class LauncherActivityInterface extends
}
@Override
protected int getOverviewScrimColorForState(QuickstepLauncher activity, LauncherState state) {
protected ScrimColors getOverviewScrimColorForState(QuickstepLauncher activity,
LauncherState state) {
return state.getWorkspaceScrimColor(activity);
}
@@ -140,7 +140,7 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
getOverviewInterpolator(state));
}
setter.setViewBackgroundColor(mRecentsViewContainer.getScrimView(),
setter.setScrimColors(mRecentsViewContainer.getScrimView(),
state.getScrimColor(mRecentsViewContainer.asContext()),
config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));
if (isSplitSelectionState(state)) {
@@ -16,10 +16,10 @@
package com.android.quickstep.fallback;
import static com.android.launcher3.Flags.enableDesktopExplodedView;
import static com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview;
import static com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS;
import static com.android.launcher3.uioverrides.states.BackgroundAppState.getOverviewScaleAndOffsetForBackgroundState;
import static com.android.launcher3.uioverrides.states.OverviewModalTaskState.getOverviewScaleAndOffsetForModalState;
import static com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview;
import android.content.Context;
import android.graphics.Color;
@@ -29,6 +29,7 @@ import com.android.launcher3.R;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ScrimColors;
import com.android.quickstep.views.RecentsViewContainer;
/**
@@ -164,10 +165,12 @@ public class RecentsState implements BaseState<RecentsState> {
/**
* For this state, what color scrim should be drawn behind overview.
*/
public int getScrimColor(Context context) {
return hasFlag(FLAG_SCRIM)
public ScrimColors getScrimColor(Context context) {
return new ScrimColors(
/* backgroundColor */ hasFlag(FLAG_SCRIM)
? Themes.getAttrColor(context, R.attr.overviewScrimColor)
: Color.TRANSPARENT;
: Color.TRANSPARENT,
/* foregroundColor */ Color.TRANSPARENT);
}
public float[] getOverviewScaleAndOffset(RecentsViewContainer container) {