Add translationX to overview state

States return ScaleAndTranslation instead of float[].

Also separate overview translate interpolator from overview scale interpolator.

Change-Id: I5e65dde3f436055ff5e7f5736f1a4b712377b9cb
This commit is contained in:
Tony
2019-03-19 13:30:25 -05:00
parent 9244f518f2
commit bc23440d73
11 changed files with 80 additions and 64 deletions
@@ -19,6 +19,7 @@ package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE;
import static com.android.launcher3.anim.AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -29,6 +30,7 @@ import android.view.animation.Interpolator;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.anim.AnimatorSetBuilder;
@@ -54,9 +56,15 @@ public abstract class BaseRecentsViewStateController<T extends View>
@Override
public void setState(@NonNull LauncherState state) {
float[] scaleTranslationY = state.getOverviewScaleAndTranslationY(mLauncher);
SCALE_PROPERTY.set(mRecentsView, scaleTranslationY[0]);
mRecentsView.setTranslationY(scaleTranslationY[1]);
ScaleAndTranslation scaleAndTranslation = state
.getOverviewScaleAndTranslation(mLauncher);
SCALE_PROPERTY.set(mRecentsView, scaleAndTranslation.scale);
float translationX = scaleAndTranslation.translationX;
if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
translationX = -translationX;
}
mRecentsView.setTranslationX(translationX);
mRecentsView.setTranslationY(scaleAndTranslation.translationY);
getContentAlphaProperty().set(mRecentsView, state.overviewUi ? 1f : 0);
}
@@ -83,28 +91,22 @@ public abstract class BaseRecentsViewStateController<T extends View>
void setStateWithAnimationInternal(@NonNull final LauncherState toState,
@NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) {
PropertySetter setter = config.getPropertySetter(builder);
float[] scaleTranslationY = toState.getOverviewScaleAndTranslationY(mLauncher);
Interpolator scaleAndTransYInterpolator = getScaleAndTransYInterpolator(toState, builder);
setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleTranslationY[0],
scaleAndTransYInterpolator);
setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleTranslationY[1],
scaleAndTransYInterpolator);
ScaleAndTranslation scaleAndTranslation = toState.getOverviewScaleAndTranslation(mLauncher);
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR);
setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, scaleInterpolator);
Interpolator translateInterpolator = builder.getInterpolator(
ANIM_OVERVIEW_TRANSLATE, LINEAR);
float translationX = scaleAndTranslation.translationX;
if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
translationX = -translationX;
}
setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateInterpolator);
setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleAndTranslation.translationY,
translateInterpolator);
setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
}
/**
* Get the interpolator to use for the scale and translation Y animation for the view.
*
* @param toState state to animate to
* @param builder animator set builder
* @return interpolator for scale and trans Y recents view animation
*/
Interpolator getScaleAndTransYInterpolator(@NonNull final LauncherState toState,
@NonNull AnimatorSetBuilder builder) {
return builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR);
}
/**
* Get property for content alpha for the recents view.
*