Merge "Update Scrim values for blur" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
e0a2abda93
@@ -389,12 +389,17 @@
|
||||
<item name="overviewScrimColor">?attr/overviewScrimColorBlur</item>
|
||||
<item name="overviewActionsContainerStyle">@style/OverviewActionsContainerBlur</item>
|
||||
<item name="overviewActionButtonStyle">@style/OverviewActionButton.Blur</item>
|
||||
<item name="overviewScrimForegroundPrimary">?attr/overviewScrimForegroundPrimaryBlur</item>
|
||||
<item name="overviewScrimForegroundSecondary">?attr/overviewScrimForegroundSecondaryBlur
|
||||
</item>
|
||||
</style>
|
||||
|
||||
<style name="OverviewBlurFallbackStyle">
|
||||
<item name="overviewScrimColor">?attr/overviewScrimColorFallback</item>
|
||||
<item name="overviewActionsContainerStyle">@style/OverviewActionsContainer</item>
|
||||
<item name="overviewActionButtonStyle">@style/OverviewActionButton</item>
|
||||
<item name="overviewScrimForegroundPrimary">@android:color/transparent</item>
|
||||
<item name="overviewScrimForegroundSecondary">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -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
|
||||
|
||||
+6
-4
@@ -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));
|
||||
}
|
||||
|
||||
+3
-2
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2025 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:alpha="0.10" android:color="@android:color/system_accent1_100"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2025 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:alpha="0.32" android:color="@android:color/system_accent1_800" />
|
||||
</selector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2025 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:alpha="0.20" android:color="@android:color/system_neutral1_500" android:lStar="98" />
|
||||
</selector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2025 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:alpha="0.32" android:color="@android:color/system_neutral1_500" android:lStar="98" />
|
||||
</selector>
|
||||
@@ -48,6 +48,10 @@
|
||||
<attr name="overviewScrimColor" format="color" />
|
||||
<attr name="overviewScrimColorFallback" format="color" />
|
||||
<attr name="overviewScrimColorBlur" format="color" />
|
||||
<attr name="overviewScrimForegroundPrimaryBlur" format="color" />
|
||||
<attr name="overviewScrimForegroundPrimary" format="color" />
|
||||
<attr name="overviewScrimForegroundSecondaryBlur" format="color" />
|
||||
<attr name="overviewScrimForegroundSecondary" format="color" />
|
||||
<attr name="overviewActionsContainerStyle" format="reference" />
|
||||
<attr name="overviewActionButtonStyle" format="reference" />
|
||||
<attr name="popupNotificationDotColor" format="color" />
|
||||
|
||||
@@ -84,6 +84,8 @@
|
||||
<item name="dropTargetHoverTextColor">@color/drop_target_hover_text_color_light</item>
|
||||
<item name="dropTargetHoverButtonColor">@color/drop_target_hover_button_color_light</item>
|
||||
<item name="overviewScrimColorFallback">@color/overview_scrim</item>
|
||||
<item name="overviewScrimForegroundPrimaryBlur">@color/overview_scrim_foreground_primary</item>
|
||||
<item name="overviewScrimForegroundSecondaryBlur">@color/overview_scrim_foreground_secondary</item>
|
||||
<item name="overviewScrimColorBlur">#80FFFFFF</item>
|
||||
<item name="preloadIconAccentColor">@color/preload_icon_accent_color_light</item>
|
||||
<item name="preloadIconBackgroundColor">@color/preload_icon_background_color_light</item>
|
||||
@@ -149,6 +151,8 @@
|
||||
<item name="iconOnlyShortcutColor">#B3FFFFFF</item>
|
||||
<item name="eduHalfSheetBGColor">#DD000000</item>
|
||||
<item name="overviewScrimColorFallback">@color/overview_scrim_dark</item>
|
||||
<item name="overviewScrimForegroundPrimaryBlur">@color/overview_scrim_foreground_primary_dark</item>
|
||||
<item name="overviewScrimForegroundSecondaryBlur">@color/overview_scrim_foreground_secondary_dark</item>
|
||||
<item name="overviewScrimColorBlur">#80000000</item>
|
||||
<item name="preloadIconAccentColor">@color/preload_icon_accent_color_dark</item>
|
||||
<item name="preloadIconBackgroundColor">@color/preload_icon_background_color_dark</item>
|
||||
|
||||
@@ -24,12 +24,15 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.IntProperty;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.util.MultiScalePropertyFactory;
|
||||
import com.android.launcher3.views.ScrimColors;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
public class LauncherAnimUtils {
|
||||
/**
|
||||
@@ -201,6 +204,19 @@ public class LauncherAnimUtils {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Property<ScrimView, ScrimColors> SCRIM_COLORS =
|
||||
new Property<ScrimView, ScrimColors>(ScrimColors.class, "scrimColors") {
|
||||
@Override
|
||||
public void set(ScrimView scrimView, ScrimColors scrimColors) {
|
||||
scrimView.setScrimColors(scrimColors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrimColors get(ScrimView scrimView) {
|
||||
return scrimView.getScrimColors();
|
||||
}
|
||||
};
|
||||
|
||||
public static final FloatProperty<ImageView> ROTATION_DRAWABLE_PERCENT =
|
||||
new FloatProperty<ImageView>("drawableRotationPercent") {
|
||||
// RotateDrawable linearly interpolates the rotation degrees between fromDegrees
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.android.launcher3.uioverrides.states.AllAppsState;
|
||||
import com.android.launcher3.uioverrides.states.HintState;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.ScrimColors;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -317,8 +318,9 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
* What color should the workspace scrim be in when at rest in this state.
|
||||
* Return {@link Color#TRANSPARENT} for no scrim.
|
||||
*/
|
||||
public int getWorkspaceScrimColor(Launcher launcher) {
|
||||
return Color.TRANSPARENT;
|
||||
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
|
||||
return new ScrimColors(/* backgroundColor */ Color.TRANSPARENT,
|
||||
/* foregroundColor */ Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -207,7 +207,7 @@ public class WorkspaceStateTransitionAnimation {
|
||||
propertySetter.setFloat(sysUiScrim.getSysUIProgress(), AnimatedFloat.VALUE,
|
||||
state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
|
||||
|
||||
propertySetter.setViewBackgroundColor(mLauncher.getScrimView(),
|
||||
propertySetter.setScrimColors(mLauncher.getScrimView(),
|
||||
state.getWorkspaceScrimColor(mLauncher),
|
||||
config.getInterpolator(ANIM_SCRIM_FADE, ACCELERATE_2));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.launcher3.anim;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCRIM_COLORS;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.Animator.AnimatorListener;
|
||||
@@ -25,13 +25,16 @@ import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.IntProperty;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.views.ScrimColors;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.launcher3.views.ScrimColorsEvaluator;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -63,15 +66,16 @@ public class AnimatedPropertySetter extends PropertySetter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
|
||||
if (view == null || (view.getBackground() instanceof ColorDrawable
|
||||
&& ((ColorDrawable) view.getBackground()).getColor() == color)) {
|
||||
public Animator setScrimColors(ScrimView view, ScrimColors scrimColors,
|
||||
TimeInterpolator interpolator) {
|
||||
if (view == null || view.getScrimColors().equals(scrimColors)) {
|
||||
return NO_OP;
|
||||
}
|
||||
ObjectAnimator anim = ObjectAnimator.ofArgb(view, VIEW_BACKGROUND_COLOR, color);
|
||||
anim.setInterpolator(interpolator);
|
||||
add(anim);
|
||||
return anim;
|
||||
ObjectAnimator animator = ObjectAnimator.ofObject(view, SCRIM_COLORS,
|
||||
ScrimColorsEvaluator.INSTANCE, scrimColors);
|
||||
animator.setInterpolator(interpolator);
|
||||
add(animator);
|
||||
return animator;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,16 @@ package com.android.launcher3.anim;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.IntProperty;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.views.ScrimColors;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -59,12 +63,14 @@ public abstract class PropertySetter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color of the provided view using the provided interpolator.
|
||||
* Sets the background and foreground color of the provided view using the provided
|
||||
* interpolator.
|
||||
*/
|
||||
@NonNull
|
||||
public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
|
||||
public Animator setScrimColors(ScrimView view, ScrimColors scrimColors,
|
||||
TimeInterpolator interpolator) {
|
||||
if (view != null) {
|
||||
view.setBackgroundColor(color);
|
||||
view.setScrimColors(scrimColors);
|
||||
}
|
||||
return NO_OP;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.views
|
||||
|
||||
data class ScrimColors(val backgroundColor: Int, val foregroundColor: Int)
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.views
|
||||
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.TypeEvaluator
|
||||
|
||||
/** TypeEvaluator that interpolates between [ScrimColors]. */
|
||||
object ScrimColorsEvaluator : TypeEvaluator<ScrimColors> {
|
||||
|
||||
private val argbEvaluator = ArgbEvaluator()
|
||||
|
||||
override fun evaluate(
|
||||
fraction: Float,
|
||||
startValue: ScrimColors,
|
||||
endValue: ScrimColors,
|
||||
): ScrimColors =
|
||||
ScrimColors(
|
||||
backgroundColor =
|
||||
argbEvaluator.evaluate(
|
||||
fraction,
|
||||
startValue.backgroundColor,
|
||||
endValue.backgroundColor,
|
||||
) as Int,
|
||||
foregroundColor =
|
||||
argbEvaluator.evaluate(
|
||||
fraction,
|
||||
startValue.foregroundColor,
|
||||
endValue.foregroundColor,
|
||||
) as Int,
|
||||
)
|
||||
}
|
||||
@@ -183,6 +183,35 @@ public class ScrimView extends View implements Insettable {
|
||||
mOpaquenessListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set foreground and background color to this ScrimView
|
||||
*/
|
||||
public void setScrimColors(ScrimColors scrimColors) {
|
||||
this.setBackgroundColor(scrimColors.getBackgroundColor());
|
||||
setForeground(new ColorDrawable(scrimColors.getForegroundColor()));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns foreground and background color of this ScrimView
|
||||
*/
|
||||
public ScrimColors getScrimColors() {
|
||||
int backgroundColor;
|
||||
if (getBackground() instanceof ColorDrawable colorDrawable) {
|
||||
backgroundColor = colorDrawable.getColor();
|
||||
} else {
|
||||
backgroundColor = Color.TRANSPARENT;
|
||||
}
|
||||
|
||||
int foregroundColor;
|
||||
if (getForeground() instanceof ColorDrawable colorDrawable) {
|
||||
foregroundColor = colorDrawable.getColor();
|
||||
} else {
|
||||
foregroundColor = Color.TRANSPARENT;
|
||||
}
|
||||
|
||||
return new ScrimColors(backgroundColor, foregroundColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Utility interface allowing for other surfaces to draw on ScrimView
|
||||
*/
|
||||
|
||||
@@ -18,11 +18,13 @@ package com.android.launcher3.uioverrides.states;
|
||||
import static com.android.app.animation.Interpolators.DECELERATE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;
|
||||
|
||||
import android.graphics.Color;
|
||||
import com.android.launcher3.Launcher;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Definition for AllApps state
|
||||
@@ -96,9 +98,11 @@ public class AllAppsState extends LauncherState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWorkspaceScrimColor(Launcher launcher) {
|
||||
return launcher.getDeviceProfile().getDeviceProperties().isTablet()
|
||||
public ScrimColors getWorkspaceScrimColor(Launcher launcher) {
|
||||
return new ScrimColors(
|
||||
/* backgroundColor */ launcher.getDeviceProfile().getDeviceProperties().isTablet()
|
||||
? launcher.getResources().getColor(R.color.widgets_picker_scrim)
|
||||
: Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
|
||||
: Themes.getAttrColor(launcher, R.attr.allAppsScrimColor),
|
||||
/* foregroundColor */ Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@ package com.android.launcher3.uioverrides.states;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
|
||||
|
||||
import android.graphics.Color;
|
||||
import com.android.launcher3.Launcher;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Definition for overview state
|
||||
@@ -60,7 +62,9 @@ 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 */ Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user