Merge "Adjust interpolators when swiping from overview to all apps" into ub-launcher3-edmonton-polish
This commit is contained in:
commit
48010091f4
|
@ -18,7 +18,11 @@ package com.android.launcher3.uioverrides;
|
||||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||||
import static com.android.launcher3.LauncherState.NORMAL;
|
import static com.android.launcher3.LauncherState.NORMAL;
|
||||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||||
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE;
|
||||||
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
|
||||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS;
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS;
|
||||||
|
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||||
|
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||||
|
|
||||||
import android.animation.TimeInterpolator;
|
import android.animation.TimeInterpolator;
|
||||||
|
@ -51,6 +55,16 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
|
||||||
|
|
||||||
private static final String TAG = "PortraitStatesTouchCtrl";
|
private static final String TAG = "PortraitStatesTouchCtrl";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The progress at which all apps content will be fully visible when swiping up from overview.
|
||||||
|
*/
|
||||||
|
private static final float ALL_APPS_CONTENT_FADE_THRESHOLD = 0.08f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The progress at which recents will begin fading out when swiping up from overview.
|
||||||
|
*/
|
||||||
|
private static final float RECENTS_FADE_THRESHOLD = 0.88f;
|
||||||
|
|
||||||
private InterpolatorWrapper mAllAppsInterpolatorWrapper = new InterpolatorWrapper();
|
private InterpolatorWrapper mAllAppsInterpolatorWrapper = new InterpolatorWrapper();
|
||||||
|
|
||||||
// If true, we will finish the current animation instantly on second touch.
|
// If true, we will finish the current animation instantly on second touch.
|
||||||
|
@ -125,7 +139,38 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
|
||||||
|
|
||||||
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||||
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, mAllAppsInterpolatorWrapper);
|
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, mAllAppsInterpolatorWrapper);
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AnimatorSetBuilder getOverviewToAllAppsAnimation() {
|
||||||
|
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||||
|
builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL,
|
||||||
|
0, ALL_APPS_CONTENT_FADE_THRESHOLD));
|
||||||
|
builder.setInterpolator(ANIM_OVERVIEW_FADE, Interpolators.clampToProgress(DEACCEL,
|
||||||
|
RECENTS_FADE_THRESHOLD, 1));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AnimatorSetBuilder getAllAppsToOverviewAnimation() {
|
||||||
|
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||||
|
builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL,
|
||||||
|
1 - ALL_APPS_CONTENT_FADE_THRESHOLD, 1));
|
||||||
|
builder.setInterpolator(ANIM_OVERVIEW_FADE, Interpolators.clampToProgress(ACCEL,
|
||||||
|
0f, 1 - RECENTS_FADE_THRESHOLD));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState,
|
||||||
|
LauncherState toState) {
|
||||||
|
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||||
|
if (fromState == NORMAL && toState == OVERVIEW) {
|
||||||
|
builder = getNormalToOverviewAnimation();
|
||||||
|
} else if (fromState == OVERVIEW && toState == ALL_APPS) {
|
||||||
|
builder = getOverviewToAllAppsAnimation();
|
||||||
|
} else if (fromState == ALL_APPS && toState == OVERVIEW) {
|
||||||
|
builder = getAllAppsToOverviewAnimation();
|
||||||
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +184,8 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
|
||||||
|
|
||||||
float totalShift = endVerticalShift - startVerticalShift;
|
float totalShift = endVerticalShift - startVerticalShift;
|
||||||
|
|
||||||
final AnimatorSetBuilder builder;
|
final AnimatorSetBuilder builder = totalShift == 0 ? new AnimatorSetBuilder()
|
||||||
|
: getAnimatorSetBuilderForStates(mFromState, mToState);
|
||||||
if (mFromState == NORMAL && mToState == OVERVIEW && totalShift != 0) {
|
|
||||||
builder = getNormalToOverviewAnimation();
|
|
||||||
} else {
|
|
||||||
builder = new AnimatorSetBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelPendingAnim();
|
cancelPendingAnim();
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,13 @@ import android.animation.ValueAnimator;
|
||||||
|
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherAnimUtils;
|
import com.android.launcher3.LauncherAnimUtils;
|
||||||
|
import com.android.launcher3.LauncherStateManager;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||||
import com.android.launcher3.allapps.DiscoveryBounce;
|
import com.android.launcher3.allapps.DiscoveryBounce;
|
||||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||||
|
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||||
|
import com.android.launcher3.uioverrides.PortraitStatesTouchController;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||||
|
@ -67,8 +70,10 @@ public class LongSwipeHelper {
|
||||||
AllAppsTransitionController controller = mLauncher.getAllAppsController();
|
AllAppsTransitionController controller = mLauncher.getAllAppsController();
|
||||||
// TODO: Scale it down so that we can reach all-apps in screen space
|
// TODO: Scale it down so that we can reach all-apps in screen space
|
||||||
mMaxSwipeDistance = Math.max(1, controller.getProgress() * controller.getShiftRange());
|
mMaxSwipeDistance = Math.max(1, controller.getProgress() * controller.getShiftRange());
|
||||||
mAnimator = mLauncher.getStateManager()
|
|
||||||
.createAnimationToNewWorkspace(ALL_APPS, Math.round(2 * mMaxSwipeDistance));
|
AnimatorSetBuilder builder = PortraitStatesTouchController.getOverviewToAllAppsAnimation();
|
||||||
|
mAnimator = mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, builder,
|
||||||
|
Math.round(2 * mMaxSwipeDistance), null, LauncherStateManager.ANIM_ALL);
|
||||||
mAnimator.dispatchOnStart();
|
mAnimator.dispatchOnStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
package com.android.quickstep.views;
|
package com.android.quickstep.views;
|
||||||
|
|
||||||
import static android.support.v4.graphics.ColorUtils.setAlphaComponent;
|
import static android.support.v4.graphics.ColorUtils.setAlphaComponent;
|
||||||
|
|
||||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||||
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||||
|
@ -33,6 +32,7 @@ import android.util.AttributeSet;
|
||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
|
import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.launcher3.util.Themes;
|
import com.android.launcher3.util.Themes;
|
||||||
import com.android.launcher3.views.ScrimView;
|
import com.android.launcher3.views.ScrimView;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class ShelfScrimView extends ScrimView {
|
||||||
// For shelf mode
|
// For shelf mode
|
||||||
private final int mEndAlpha;
|
private final int mEndAlpha;
|
||||||
private final float mRadius;
|
private final float mRadius;
|
||||||
private final float mMaxScrimAlpha;
|
private final int mMaxScrimAlpha;
|
||||||
private final Paint mPaint;
|
private final Paint mPaint;
|
||||||
|
|
||||||
// Mid point where the alpha changes
|
// Mid point where the alpha changes
|
||||||
|
@ -78,7 +78,7 @@ public class ShelfScrimView extends ScrimView {
|
||||||
|
|
||||||
public ShelfScrimView(Context context, AttributeSet attrs) {
|
public ShelfScrimView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mMaxScrimAlpha = OVERVIEW.getWorkspaceScrimAlpha(mLauncher);
|
mMaxScrimAlpha = Math.round(OVERVIEW.getWorkspaceScrimAlpha(mLauncher) * 255);
|
||||||
|
|
||||||
mEndAlpha = Color.alpha(mEndScrim);
|
mEndAlpha = Color.alpha(mEndScrim);
|
||||||
mRadius = mLauncher.getResources().getDimension(R.dimen.shelf_surface_radius);
|
mRadius = mLauncher.getResources().getDimension(R.dimen.shelf_surface_radius);
|
||||||
|
@ -144,9 +144,10 @@ public class ShelfScrimView extends ScrimView {
|
||||||
} else {
|
} else {
|
||||||
mDragHandleOffset += mShiftRange * (mMidProgress - mProgress);
|
mDragHandleOffset += mShiftRange * (mMidProgress - mProgress);
|
||||||
|
|
||||||
|
// Note that these ranges and interpolators are inverted because progress goes 1 to 0.
|
||||||
int alpha = Math.round(
|
int alpha = Math.round(
|
||||||
Utilities.mapToRange(mProgress, (float) 0, mMidProgress, (float) mEndAlpha,
|
Utilities.mapToRange(mProgress, (float) 0, mMidProgress, (float) mEndAlpha,
|
||||||
(float) mMidAlpha, LINEAR));
|
(float) mMidAlpha, Interpolators.clampToProgress(ACCEL, 0.5f, 1f)));
|
||||||
mShelfColor = setAlphaComponent(mEndScrim, alpha);
|
mShelfColor = setAlphaComponent(mEndScrim, alpha);
|
||||||
|
|
||||||
int remainingScrimAlpha = Math.round(
|
int remainingScrimAlpha = Math.round(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS_HEADER;
|
||||||
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
|
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
|
||||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||||
import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR;
|
import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR;
|
||||||
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE;
|
||||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
|
||||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS;
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS;
|
||||||
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
|
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
|
||||||
|
@ -151,7 +152,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
||||||
@Override
|
@Override
|
||||||
public void setState(LauncherState state) {
|
public void setState(LauncherState state) {
|
||||||
setProgress(state.getVerticalProgress(mLauncher));
|
setProgress(state.getVerticalProgress(mLauncher));
|
||||||
setAlphas(state, NO_ANIM_PROPERTY_SETTER);
|
setAlphas(state, null, new AnimatorSetBuilder());
|
||||||
onProgressAnimationEnd();
|
onProgressAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
||||||
AnimatorSetBuilder builder, AnimationConfig config) {
|
AnimatorSetBuilder builder, AnimationConfig config) {
|
||||||
float targetProgress = toState.getVerticalProgress(mLauncher);
|
float targetProgress = toState.getVerticalProgress(mLauncher);
|
||||||
if (Float.compare(mProgress, targetProgress) == 0) {
|
if (Float.compare(mProgress, targetProgress) == 0) {
|
||||||
setAlphas(toState, config.getPropertySetter(builder));
|
setAlphas(toState, config, builder);
|
||||||
// Fail fast
|
// Fail fast
|
||||||
onProgressAnimationEnd();
|
onProgressAnimationEnd();
|
||||||
return;
|
return;
|
||||||
|
@ -186,19 +187,24 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
||||||
|
|
||||||
builder.play(anim);
|
builder.play(anim);
|
||||||
|
|
||||||
setAlphas(toState, config.getPropertySetter(builder));
|
setAlphas(toState, config, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAlphas(LauncherState toState, PropertySetter setter) {
|
private void setAlphas(LauncherState toState, AnimationConfig config,
|
||||||
|
AnimatorSetBuilder builder) {
|
||||||
|
PropertySetter setter = config == null ? NO_ANIM_PROPERTY_SETTER
|
||||||
|
: config.getPropertySetter(builder);
|
||||||
int visibleElements = toState.getVisibleElements(mLauncher);
|
int visibleElements = toState.getVisibleElements(mLauncher);
|
||||||
boolean hasHeader = (visibleElements & ALL_APPS_HEADER) != 0;
|
boolean hasHeader = (visibleElements & ALL_APPS_HEADER) != 0;
|
||||||
boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
|
boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
|
||||||
boolean hasContent = (visibleElements & ALL_APPS_CONTENT) != 0;
|
boolean hasContent = (visibleElements & ALL_APPS_CONTENT) != 0;
|
||||||
|
|
||||||
setter.setViewAlpha(mAppsView.getSearchView(), hasHeader ? 1 : 0, LINEAR);
|
Interpolator allAppsFade = builder.getInterpolator(ANIM_ALL_APPS_FADE, LINEAR);
|
||||||
setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, LINEAR);
|
setter.setViewAlpha(mAppsView.getSearchView(), hasHeader ? 1 : 0, allAppsFade);
|
||||||
setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, LINEAR);
|
setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, allAppsFade);
|
||||||
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter);
|
setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, allAppsFade);
|
||||||
|
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter,
|
||||||
|
allAppsFade);
|
||||||
|
|
||||||
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
|
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
|
||||||
(visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR);
|
(visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR);
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.android.launcher3.allapps;
|
package com.android.launcher3.allapps;
|
||||||
|
|
||||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
|
||||||
|
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
|
@ -28,6 +26,7 @@ import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.animation.Interpolator;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
|
@ -227,8 +226,9 @@ public class FloatingHeaderView extends LinearLayout implements
|
||||||
p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
|
p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContentVisibility(boolean hasHeader, boolean hasContent, PropertySetter setter) {
|
public void setContentVisibility(boolean hasHeader, boolean hasContent, PropertySetter setter,
|
||||||
setter.setViewAlpha(this, hasContent ? 1 : 0, LINEAR);
|
Interpolator fadeInterpolator) {
|
||||||
|
setter.setViewAlpha(this, hasContent ? 1 : 0, fadeInterpolator);
|
||||||
allowTouchForwarding(hasContent);
|
allowTouchForwarding(hasContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class AnimatorSetBuilder {
|
||||||
public static final int ANIM_WORKSPACE_FADE = 2;
|
public static final int ANIM_WORKSPACE_FADE = 2;
|
||||||
public static final int ANIM_OVERVIEW_SCALE = 3;
|
public static final int ANIM_OVERVIEW_SCALE = 3;
|
||||||
public static final int ANIM_OVERVIEW_FADE = 4;
|
public static final int ANIM_OVERVIEW_FADE = 4;
|
||||||
|
public static final int ANIM_ALL_APPS_FADE = 5;
|
||||||
|
|
||||||
protected final ArrayList<Animator> mAnims = new ArrayList<>();
|
protected final ArrayList<Animator> mAnims = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ public abstract class AbstractStateChangeTouchController
|
||||||
|
|
||||||
private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState,
|
private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState,
|
||||||
long duration) {
|
long duration) {
|
||||||
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
AnimatorSetBuilder builder = getAnimatorSetBuilderForStates(fromState, targetState);
|
||||||
mLauncher.getStateManager().prepareForAtomicAnimation(fromState, targetState, builder);
|
mLauncher.getStateManager().prepareForAtomicAnimation(fromState, targetState, builder);
|
||||||
AnimationConfig config = new AnimationConfig();
|
AnimationConfig config = new AnimationConfig();
|
||||||
config.animComponents = ATOMIC_COMPONENT;
|
config.animComponents = ATOMIC_COMPONENT;
|
||||||
|
@ -352,6 +352,11 @@ public abstract class AbstractStateChangeTouchController
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState,
|
||||||
|
LauncherState toState) {
|
||||||
|
return new AnimatorSetBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDragEnd(float velocity, boolean fling) {
|
public void onDragEnd(float velocity, boolean fling) {
|
||||||
final int logAction = fling ? Touch.FLING : Touch.SWIPE;
|
final int logAction = fling ? Touch.FLING : Touch.SWIPE;
|
||||||
|
|
Loading…
Reference in New Issue