mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Merge "[Search][Motion] Separate AllApps scrim and content interpolation" into sc-dev
This commit is contained in:
@@ -1197,7 +1197,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
|
||||
// Setup the drag controller (drop targets have to be added in reverse order in priority)
|
||||
mDropTargetBar.setup(mDragController);
|
||||
mAllAppsController.setupViews(mAppsView);
|
||||
mAllAppsController.setupViews(mAppsView, mScrimView);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCA
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCRIM_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
|
||||
|
||||
@@ -165,10 +164,6 @@ public class WorkspaceStateTransitionAnimation {
|
||||
SysUiScrim sysUiScrim = mLauncher.getDragLayer().getSysUiScrim();
|
||||
propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
|
||||
state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
|
||||
|
||||
propertySetter.setViewAlpha(mLauncher.getScrimView(),
|
||||
state.getWorkspaceScrimAlpha(mLauncher),
|
||||
config.getInterpolator(ANIM_WORKSPACE_SCRIM_FADE, LINEAR));
|
||||
}
|
||||
|
||||
public void applyChildState(LauncherState state, CellLayout cl, int childIndex) {
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
/**
|
||||
* Handles AllApps view transition.
|
||||
@@ -70,10 +71,11 @@ public class AllAppsTransitionController
|
||||
controller.setProgress(progress);
|
||||
}
|
||||
};
|
||||
private final Launcher mLauncher;
|
||||
|
||||
private AllAppsContainerView mAppsView;
|
||||
private ScrimView mScrimView;
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private boolean mIsVerticalLayout;
|
||||
|
||||
// Animation in this class is controlled by a single variable {@link mProgress}.
|
||||
@@ -121,6 +123,8 @@ public class AllAppsTransitionController
|
||||
*/
|
||||
public void setProgress(float progress) {
|
||||
mProgress = progress;
|
||||
//Note: Take inverted progress so progress=0 maps to a transparent scrim
|
||||
mScrimView.setProgress(1 - progress);
|
||||
mAppsView.setTranslationY(mProgress * mShiftRange);
|
||||
}
|
||||
|
||||
@@ -185,8 +189,12 @@ public class AllAppsTransitionController
|
||||
return AnimationSuccessListener.forRunnable(this::onProgressAnimationEnd);
|
||||
}
|
||||
|
||||
public void setupViews(AllAppsContainerView appsView) {
|
||||
/**
|
||||
* Setup views
|
||||
*/
|
||||
public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) {
|
||||
mAppsView = appsView;
|
||||
mScrimView = scrimView;
|
||||
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && Utilities.ATLEAST_R) {
|
||||
mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS,
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
|
||||
@@ -15,18 +15,21 @@
|
||||
*/
|
||||
package com.android.launcher3.views;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||
import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.Themes;
|
||||
|
||||
@@ -36,9 +39,22 @@ import com.android.launcher3.util.Themes;
|
||||
public class ScrimView extends View implements Insettable {
|
||||
private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f;
|
||||
|
||||
|
||||
private static final float TINT_DECAY_MULTIPLIER = .5f;
|
||||
|
||||
//min progress for scrim to become visible
|
||||
private static final float SCRIM_VISIBLE_THRESHOLD = .1f;
|
||||
//max progress where scrim alpha animates.
|
||||
private static final float SCRIM_SOLID_THRESHOLD = .5f;
|
||||
private final Interpolator mScrimInterpolator = Interpolators.clampToProgress(ACCEL,
|
||||
SCRIM_VISIBLE_THRESHOLD,
|
||||
SCRIM_SOLID_THRESHOLD);
|
||||
|
||||
private final boolean mIsScrimDark;
|
||||
private SystemUiController mSystemUiController;
|
||||
|
||||
private float mProgress;
|
||||
|
||||
public ScrimView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mIsScrimDark = ColorUtils.calculateLuminance(
|
||||
@@ -47,17 +63,23 @@ public class ScrimView extends View implements Insettable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsets(Rect insets) { }
|
||||
public void setInsets(Rect insets) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetAlpha(int alpha) {
|
||||
updateSysUiColors();
|
||||
return super.onSetAlpha(alpha);
|
||||
/**
|
||||
* Set progress of scrim animation.
|
||||
* Note: progress should range from 0 for transparent to 1 for solid
|
||||
*/
|
||||
public void setProgress(float progress) {
|
||||
if (mProgress != progress) {
|
||||
mProgress = progress;
|
||||
setAlpha(mScrimInterpolator.getInterpolation(progress));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user