Merge "Switch ScrimView to use view alpha" into udc-qpr-dev am: 544dff52af

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

Change-Id: I65088abc845003a3afa65efa1478bc88a7871146
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vadim Tryshev
2023-06-07 22:25:36 +00:00
committed by Automerger Merge Worker
7 changed files with 27 additions and 29 deletions
@@ -16,7 +16,6 @@
package com.android.launcher3.uioverrides.touchcontrollers;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static com.android.app.animation.Interpolators.ACCELERATE_0_75;
import static com.android.app.animation.Interpolators.DECELERATE_3;
@@ -262,7 +261,7 @@ 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(),
xAnim.setScrimViewBackgroundColor(mLauncher.getScrimView(),
QUICK_SWITCH_FROM_HOME.getWorkspaceScrimColor(mLauncher), LINEAR);
if (mRecentsView.getTaskViewCount() == 0) {
xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
@@ -114,7 +114,7 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
state.showTaskThumbnailSplash() ? 1f : 0f, INSTANT);
setter.setViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
setter.setScrimViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));
RecentsState currentState = mActivity.getStateManager().getState();
@@ -30,6 +30,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.android.launcher3.util.MultiScalePropertyFactory;
import com.android.launcher3.views.ScrimView;
public class LauncherAnimUtils {
/**
@@ -194,6 +195,10 @@ public class LauncherAnimUtils {
@Override
public Integer get(View view) {
if (view instanceof ScrimView) {
return ((ScrimView) view).getBackgroundColor();
}
if (!(view.getBackground() instanceof ColorDrawable)) {
return Color.TRANSPARENT;
}
@@ -199,7 +199,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.setScrimViewBackgroundColor(mLauncher.getScrimView(),
state.getWorkspaceScrimColor(mLauncher),
config.getInterpolator(ANIM_SCRIM_FADE, ACCELERATE_2));
}
@@ -24,13 +24,14 @@ 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.ScrimView;
import java.util.function.Consumer;
/**
@@ -62,9 +63,9 @@ 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 setScrimViewBackgroundColor(ScrimView view, int color,
TimeInterpolator interpolator) {
if (view == null || view.getBackgroundColor() == color) {
return NO_OP;
}
ObjectAnimator anim = ObjectAnimator.ofArgb(view, VIEW_BACKGROUND_COLOR, color);
@@ -25,6 +25,8 @@ import android.view.View;
import androidx.annotation.NonNull;
import com.android.launcher3.views.ScrimView;
import java.util.function.Consumer;
/**
@@ -62,7 +64,8 @@ public abstract class PropertySetter {
* Sets the background color of the provided view using the provided interpolator.
*/
@NonNull
public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
public Animator setScrimViewBackgroundColor(ScrimView view, int color,
TimeInterpolator interpolator) {
if (view != null) {
view.setBackgroundColor(color);
}
+10 -20
View File
@@ -21,7 +21,6 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.View;
@@ -62,19 +61,17 @@ public class ScrimView extends View implements Insettable {
return false;
}
@Override
protected boolean onSetAlpha(int alpha) {
updateSysUiColors();
dispatchVisibilityListenersIfNeeded();
return super.onSetAlpha(alpha);
}
@Override
public void setBackgroundColor(int color) {
mBackgroundColor = color;
updateSysUiColors();
dispatchVisibilityListenersIfNeeded();
super.setBackgroundColor(color);
if (Color.alpha(color) == 0) {
setAlpha(0);
} else {
setAlpha(1);
super.setBackgroundColor(color);
}
updateSysUiColors();
}
public int getBackgroundColor() {
@@ -89,7 +86,7 @@ public class ScrimView extends View implements Insettable {
}
public boolean isFullyOpaque() {
return mIsVisible && getAlpha() == 1 && Color.alpha(mBackgroundColor) == 255;
return mIsVisible && getAlpha() == 1;
}
@Override
@@ -120,8 +117,7 @@ public class ScrimView extends View implements Insettable {
// status bar.
final float threshold = STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD;
boolean forceChange = getVisibility() == VISIBLE
&& getAlpha() > threshold
&& (Color.alpha(mBackgroundColor) / 255f) > threshold;
&& getAlpha() > threshold;
if (forceChange) {
getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !isScrimDark());
} else {
@@ -148,13 +144,7 @@ public class ScrimView extends View implements Insettable {
}
private boolean isScrimDark() {
if (!(getBackground() instanceof ColorDrawable)) {
throw new IllegalStateException(
"ScrimView must have a ColorDrawable background, this one has: "
+ getBackground());
}
return ColorUtils.calculateLuminance(
((ColorDrawable) getBackground()).getColor()) < 0.5f;
return ColorUtils.calculateLuminance(mBackgroundColor) < 0.5f;
}
/**