mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Changing the overviewState to show appsearch and floating header
Change-Id: I2cfd61cfc9978e4c8e4520f0f7217e49e7344c79
This commit is contained in:
@@ -18,6 +18,8 @@ package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.DRAWABLE_ALPHA;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.LauncherState.HOTSEAT;
|
||||
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
|
||||
|
||||
import android.animation.Animator;
|
||||
@@ -32,65 +34,14 @@ import com.android.launcher3.LauncherState.PageAlphaProvider;
|
||||
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.graphics.ViewScrim;
|
||||
|
||||
/**
|
||||
* A convenience class to update a view's visibility state after an alpha animation.
|
||||
*/
|
||||
class AlphaUpdateListener extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener {
|
||||
private static final float ALPHA_CUTOFF_THRESHOLD = 0.01f;
|
||||
|
||||
private View mView;
|
||||
private boolean mAccessibilityEnabled;
|
||||
private boolean mCanceled = false;
|
||||
|
||||
public AlphaUpdateListener(View v, boolean accessibilityEnabled) {
|
||||
mView = v;
|
||||
mAccessibilityEnabled = accessibilityEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator arg0) {
|
||||
updateVisibility(mView, mAccessibilityEnabled);
|
||||
}
|
||||
|
||||
public static void updateVisibility(View view, boolean accessibilityEnabled) {
|
||||
// We want to avoid the extra layout pass by setting the views to GONE unless
|
||||
// accessibility is on, in which case not setting them to GONE causes a glitch.
|
||||
int invisibleState = accessibilityEnabled ? View.GONE : View.INVISIBLE;
|
||||
if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != invisibleState) {
|
||||
view.setVisibility(invisibleState);
|
||||
} else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD
|
||||
&& view.getVisibility() != View.VISIBLE) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mCanceled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator arg0) {
|
||||
if (mCanceled) return;
|
||||
updateVisibility(mView, mAccessibilityEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator arg0) {
|
||||
// We want the views to be visible for animation, so fade-in/out is visible
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages the animations between each of the workspace states.
|
||||
*/
|
||||
public class WorkspaceStateTransitionAnimation {
|
||||
|
||||
public static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final Workspace mWorkspace;
|
||||
|
||||
@@ -107,9 +58,7 @@ public class WorkspaceStateTransitionAnimation {
|
||||
|
||||
public void setStateWithAnimation(LauncherState toState, AnimatorSetBuilder builder,
|
||||
AnimationConfig config) {
|
||||
AnimatedPropertySetter propertySetter =
|
||||
new AnimatedPropertySetter(config.duration, builder);
|
||||
setWorkspaceProperty(toState, propertySetter);
|
||||
setWorkspaceProperty(toState, config.getProperSetter(builder));
|
||||
}
|
||||
|
||||
public float getFinalScale() {
|
||||
@@ -135,10 +84,12 @@ public class WorkspaceStateTransitionAnimation {
|
||||
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
|
||||
scaleAndTranslation[2], Interpolators.ZOOM_IN);
|
||||
|
||||
propertySetter.setViewAlpha(mLauncher.getHotseat(), state.getHoseatAlpha(mLauncher),
|
||||
int elements = state.getVisibleElements(mLauncher);
|
||||
float hotseatAlpha = (elements & HOTSEAT) != 0 ? 1 : 0;
|
||||
propertySetter.setViewAlpha(mLauncher.getHotseat(), hotseatAlpha,
|
||||
pageAlphaProvider.interpolator);
|
||||
propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(),
|
||||
state.getHoseatAlpha(mLauncher), pageAlphaProvider.interpolator);
|
||||
hotseatAlpha, pageAlphaProvider.interpolator);
|
||||
|
||||
// Set scrim
|
||||
propertySetter.setFloat(ViewScrim.get(mWorkspace), ViewScrim.PROGRESS,
|
||||
@@ -162,71 +113,4 @@ public class WorkspaceStateTransitionAnimation {
|
||||
propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
|
||||
pageAlpha, pageAlphaProvider.interpolator);
|
||||
}
|
||||
|
||||
public static class PropertySetter {
|
||||
|
||||
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
|
||||
view.setAlpha(alpha);
|
||||
AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
|
||||
}
|
||||
|
||||
public <T> void setFloat(T target, Property<T, Float> property, float value,
|
||||
TimeInterpolator interpolator) {
|
||||
property.set(target, value);
|
||||
}
|
||||
|
||||
public <T> void setInt(T target, Property<T, Integer> property, int value,
|
||||
TimeInterpolator interpolator) {
|
||||
property.set(target, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnimatedPropertySetter extends PropertySetter {
|
||||
|
||||
private final long mDuration;
|
||||
private final AnimatorSetBuilder mStateAnimator;
|
||||
|
||||
public AnimatedPropertySetter(long duration, AnimatorSetBuilder builder) {
|
||||
mDuration = duration;
|
||||
mStateAnimator = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
|
||||
if (view.getAlpha() == alpha) {
|
||||
return;
|
||||
}
|
||||
ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
|
||||
anim.addListener(new AlphaUpdateListener(
|
||||
view, isAccessibilityEnabled(view.getContext())));
|
||||
anim.setDuration(mDuration).setInterpolator(interpolator);
|
||||
mStateAnimator.play(anim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setFloat(T target, Property<T, Float> property, float value,
|
||||
TimeInterpolator interpolator) {
|
||||
if (property.get(target) == value) {
|
||||
return;
|
||||
}
|
||||
Animator anim = ObjectAnimator.ofFloat(target, property, value);
|
||||
anim.setDuration(mDuration).setInterpolator(interpolator);
|
||||
mStateAnimator.play(anim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setInt(T target, Property<T, Integer> property, int value,
|
||||
TimeInterpolator interpolator) {
|
||||
if (property.get(target) == value) {
|
||||
return;
|
||||
}
|
||||
Animator anim = ObjectAnimator.ofInt(target, property, value);
|
||||
anim.setDuration(mDuration).setInterpolator(interpolator);
|
||||
mStateAnimator.play(anim);
|
||||
}
|
||||
|
||||
private TimeInterpolator getFadeInterpolator(float finalAlpha) {
|
||||
return finalAlpha == 0 ? Interpolators.DEACCEL_2 : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user