mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Merge "Revert "Switch ScrimView to use view alpha"" into udc-qpr-dev
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
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;
|
||||
@@ -261,7 +262,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.setScrimViewBackgroundColor(mLauncher.getScrimView(),
|
||||
xAnim.setViewBackgroundColor(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.setScrimViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
|
||||
setter.setViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
|
||||
config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));
|
||||
|
||||
RecentsState currentState = mActivity.getStateManager().getState();
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.util.MultiScalePropertyFactory;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
public class LauncherAnimUtils {
|
||||
/**
|
||||
@@ -195,10 +194,6 @@ 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.setScrimViewBackgroundColor(mLauncher.getScrimView(),
|
||||
propertySetter.setViewBackgroundColor(mLauncher.getScrimView(),
|
||||
state.getWorkspaceScrimColor(mLauncher),
|
||||
config.getInterpolator(ANIM_SCRIM_FADE, ACCELERATE_2));
|
||||
}
|
||||
|
||||
@@ -24,14 +24,13 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -63,9 +62,9 @@ public class AnimatedPropertySetter extends PropertySetter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator setScrimViewBackgroundColor(ScrimView view, int color,
|
||||
TimeInterpolator interpolator) {
|
||||
if (view == null || view.getBackgroundColor() == color) {
|
||||
public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
|
||||
if (view == null || (view.getBackground() instanceof ColorDrawable
|
||||
&& ((ColorDrawable) view.getBackground()).getColor() == color)) {
|
||||
return NO_OP;
|
||||
}
|
||||
ObjectAnimator anim = ObjectAnimator.ofArgb(view, VIEW_BACKGROUND_COLOR, color);
|
||||
|
||||
@@ -25,8 +25,6 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -64,8 +62,7 @@ public abstract class PropertySetter {
|
||||
* Sets the background color of the provided view using the provided interpolator.
|
||||
*/
|
||||
@NonNull
|
||||
public Animator setScrimViewBackgroundColor(ScrimView view, int color,
|
||||
TimeInterpolator interpolator) {
|
||||
public Animator setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
|
||||
if (view != null) {
|
||||
view.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ 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;
|
||||
|
||||
@@ -61,17 +62,19 @@ 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;
|
||||
dispatchVisibilityListenersIfNeeded();
|
||||
if (Color.alpha(color) == 0) {
|
||||
setAlpha(0);
|
||||
} else {
|
||||
setAlpha(1);
|
||||
super.setBackgroundColor(color);
|
||||
}
|
||||
updateSysUiColors();
|
||||
dispatchVisibilityListenersIfNeeded();
|
||||
super.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
@@ -86,7 +89,7 @@ public class ScrimView extends View implements Insettable {
|
||||
}
|
||||
|
||||
public boolean isFullyOpaque() {
|
||||
return mIsVisible && getAlpha() == 1;
|
||||
return mIsVisible && getAlpha() == 1 && Color.alpha(mBackgroundColor) == 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,7 +120,8 @@ public class ScrimView extends View implements Insettable {
|
||||
// status bar.
|
||||
final float threshold = STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD;
|
||||
boolean forceChange = getVisibility() == VISIBLE
|
||||
&& getAlpha() > threshold;
|
||||
&& getAlpha() > threshold
|
||||
&& (Color.alpha(mBackgroundColor) / 255f) > threshold;
|
||||
if (forceChange) {
|
||||
getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !isScrimDark());
|
||||
} else {
|
||||
@@ -144,7 +148,13 @@ public class ScrimView extends View implements Insettable {
|
||||
}
|
||||
|
||||
private boolean isScrimDark() {
|
||||
return ColorUtils.calculateLuminance(mBackgroundColor) < 0.5f;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user