Adjust interpolators when swiping from overview to all apps

- All apps content fades in quickly so that icons are opaque by the time
  they are on screen
- Recents fades out late so that we don't see it as translucent while
  the transition is continuing (the translucent icon top of tranclucent
  task view looks bad, for instance)
- Fix colored scrim that appears over recents - was using 0 to 1 instead
  of 255

Bug: 79867407
Change-Id: I4f50423157f7870c8d0708f586a72e3e5a7b6559
This commit is contained in:
Tony Wickham
2018-06-19 17:23:11 -07:00
parent 0eb466ea2f
commit 17be4e71b2
7 changed files with 84 additions and 26 deletions
@@ -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.OVERVIEW;
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_VERTICAL_PROGRESS;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
@@ -151,7 +152,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
@Override
public void setState(LauncherState state) {
setProgress(state.getVerticalProgress(mLauncher));
setAlphas(state, NO_ANIM_PROPERTY_SETTER);
setAlphas(state, null, new AnimatorSetBuilder());
onProgressAnimationEnd();
}
@@ -164,7 +165,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
AnimatorSetBuilder builder, AnimationConfig config) {
float targetProgress = toState.getVerticalProgress(mLauncher);
if (Float.compare(mProgress, targetProgress) == 0) {
setAlphas(toState, config.getPropertySetter(builder));
setAlphas(toState, config, builder);
// Fail fast
onProgressAnimationEnd();
return;
@@ -186,19 +187,24 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
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);
boolean hasHeader = (visibleElements & ALL_APPS_HEADER) != 0;
boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
boolean hasContent = (visibleElements & ALL_APPS_CONTENT) != 0;
setter.setViewAlpha(mAppsView.getSearchView(), hasHeader ? 1 : 0, LINEAR);
setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, LINEAR);
setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, LINEAR);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter);
Interpolator allAppsFade = builder.getInterpolator(ANIM_ALL_APPS_FADE, LINEAR);
setter.setViewAlpha(mAppsView.getSearchView(), hasHeader ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, allAppsFade);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter,
allAppsFade);
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
(visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR);
@@ -15,8 +15,6 @@
*/
package com.android.launcher3.allapps;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Point;
@@ -28,6 +26,7 @@ import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import com.android.launcher3.R;
@@ -227,8 +226,9 @@ public class FloatingHeaderView extends LinearLayout implements
p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
}
public void setContentVisibility(boolean hasHeader, boolean hasContent, PropertySetter setter) {
setter.setViewAlpha(this, hasContent ? 1 : 0, LINEAR);
public void setContentVisibility(boolean hasHeader, boolean hasContent, PropertySetter setter,
Interpolator fadeInterpolator) {
setter.setViewAlpha(this, hasContent ? 1 : 0, fadeInterpolator);
allowTouchForwarding(hasContent);
}
@@ -35,6 +35,7 @@ public class AnimatorSetBuilder {
public static final int ANIM_WORKSPACE_FADE = 2;
public static final int ANIM_OVERVIEW_SCALE = 3;
public static final int ANIM_OVERVIEW_FADE = 4;
public static final int ANIM_ALL_APPS_FADE = 5;
protected final ArrayList<Animator> mAnims = new ArrayList<>();
@@ -341,7 +341,7 @@ public abstract class AbstractStateChangeTouchController
private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState,
long duration) {
AnimatorSetBuilder builder = new AnimatorSetBuilder();
AnimatorSetBuilder builder = getAnimatorSetBuilderForStates(fromState, targetState);
mLauncher.getStateManager().prepareForAtomicAnimation(fromState, targetState, builder);
AnimationConfig config = new AnimationConfig();
config.animComponents = ATOMIC_COMPONENT;
@@ -352,6 +352,11 @@ public abstract class AbstractStateChangeTouchController
return builder.build();
}
protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState,
LauncherState toState) {
return new AnimatorSetBuilder();
}
@Override
public void onDragEnd(float velocity, boolean fling) {
final int logAction = fling ? Touch.FLING : Touch.SWIPE;