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

View File

@@ -18,7 +18,11 @@ package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
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.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.animation.TimeInterpolator;
@@ -50,6 +54,16 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
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();
// If true, we will finish the current animation instantly on second touch.
@@ -114,7 +128,38 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
AnimatorSetBuilder builder = new AnimatorSetBuilder();
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;
}
@@ -128,13 +173,8 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
float totalShift = endVerticalShift - startVerticalShift;
final AnimatorSetBuilder builder;
if (mFromState == NORMAL && mToState == OVERVIEW && totalShift != 0) {
builder = getNormalToOverviewAnimation();
} else {
builder = new AnimatorSetBuilder();
}
final AnimatorSetBuilder builder = totalShift == 0 ? new AnimatorSetBuilder()
: getAnimatorSetBuilderForStates(mFromState, mToState);
cancelPendingAnim();

View File

@@ -25,10 +25,13 @@ import android.animation.ValueAnimator;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
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.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -67,8 +70,10 @@ public class LongSwipeHelper {
AllAppsTransitionController controller = mLauncher.getAllAppsController();
// TODO: Scale it down so that we can reach all-apps in screen space
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();
}

View File

@@ -16,7 +16,6 @@
package com.android.quickstep.views;
import static android.support.v4.graphics.ColorUtils.setAlphaComponent;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.ACCEL;
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.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
@@ -55,7 +55,7 @@ public class ShelfScrimView extends ScrimView {
// For shelf mode
private final int mEndAlpha;
private final float mRadius;
private final float mMaxScrimAlpha;
private final int mMaxScrimAlpha;
private final Paint mPaint;
// Mid point where the alpha changes
@@ -78,7 +78,7 @@ public class ShelfScrimView extends ScrimView {
public ShelfScrimView(Context context, AttributeSet attrs) {
super(context, attrs);
mMaxScrimAlpha = OVERVIEW.getWorkspaceScrimAlpha(mLauncher);
mMaxScrimAlpha = Math.round(OVERVIEW.getWorkspaceScrimAlpha(mLauncher) * 255);
mEndAlpha = Color.alpha(mEndScrim);
mRadius = mLauncher.getResources().getDimension(R.dimen.shelf_surface_radius);
@@ -144,9 +144,10 @@ public class ShelfScrimView extends ScrimView {
} else {
mDragHandleOffset += mShiftRange * (mMidProgress - mProgress);
// Note that these ranges and interpolators are inverted because progress goes 1 to 0.
int alpha = Math.round(
Utilities.mapToRange(mProgress, (float) 0, mMidProgress, (float) mEndAlpha,
(float) mMidAlpha, LINEAR));
(float) mMidAlpha, Interpolators.clampToProgress(ACCEL, 0.5f, 1f)));
mShelfColor = setAlphaComponent(mEndScrim, alpha);
int remainingScrimAlpha = Math.round(