Fixing pullback factor not initialized after launcher process death
Instead of storing it on first swipe-up, computing it when required Change-Id: I4b37002a016328e3b2d1c8535198ec8a6b56faf3
This commit is contained in:
parent
ae5afa74cd
commit
ef44cf8f45
|
@ -36,7 +36,6 @@ import android.graphics.PointF;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
@ -347,21 +346,24 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
|
|||
|
||||
mTransitionDragLength = mActivityInterface.getSwipeUpDestinationAndLength(
|
||||
dp, mContext, TEMP_RECT);
|
||||
|
||||
if (mDeviceState.isFullyGesturalNavMode()) {
|
||||
// We can drag all the way to the top of the screen.
|
||||
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
|
||||
Pair<Float, Float> dragFactorStartAndMaxProgress =
|
||||
mActivityInterface.getSwipeUpPullbackStartAndMaxProgress();
|
||||
mDragLengthFactorStartPullback = dragFactorStartAndMaxProgress.first;
|
||||
mDragLengthFactorMaxPullback = dragFactorStartAndMaxProgress.second;
|
||||
}
|
||||
|
||||
mTaskViewSimulator.setDp(dp);
|
||||
mTaskViewSimulator.setLayoutRotation(
|
||||
mDeviceState.getCurrentActiveRotation(),
|
||||
mDeviceState.getDisplayRotation());
|
||||
|
||||
if (mDeviceState.isFullyGesturalNavMode()) {
|
||||
// We can drag all the way to the top of the screen.
|
||||
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
|
||||
|
||||
float startScale = mTaskViewSimulator.getFullScreenScale();
|
||||
// Start pulling back when RecentsView scale is 0.75f, and let it go down to 0.5f.
|
||||
mDragLengthFactorStartPullback = (0.75f - startScale) / (1 - startScale);
|
||||
mDragLengthFactorMaxPullback = (0.5f - startScale) / (1 - startScale);
|
||||
} else {
|
||||
mDragLengthFactor = 1;
|
||||
mDragLengthFactorStartPullback = mDragLengthFactorMaxPullback = 1;
|
||||
}
|
||||
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.setDuration(mTransitionDragLength * 2);
|
||||
anim.setInterpolator(t -> t * mDragLengthFactor);
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.animation.ObjectAnimator;
|
|||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
|
@ -72,9 +71,6 @@ import java.util.function.Predicate;
|
|||
*/
|
||||
public final class LauncherActivityInterface implements BaseActivityInterface<Launcher> {
|
||||
|
||||
private Pair<Float, Float> mSwipeUpPullbackStartAndMaxProgress =
|
||||
BaseActivityInterface.super.getSwipeUpPullbackStartAndMaxProgress();
|
||||
|
||||
@Override
|
||||
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) {
|
||||
LAUNCHER_ACTIVITY_SIZE_STRATEGY.calculateTaskSize(context, dp, outRect);
|
||||
|
@ -87,11 +83,6 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Float, Float> getSwipeUpPullbackStartAndMaxProgress() {
|
||||
return mSwipeUpPullbackStartAndMaxProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionCancelled(boolean activityVisible) {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
|
@ -282,12 +273,6 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
Animator applyFullscreenProgress = ObjectAnimator.ofFloat(recentsView,
|
||||
RecentsView.FULLSCREEN_PROGRESS, fromFullscreenProgress, endFullscreenProgress);
|
||||
anim.playTogether(scale, applyFullscreenProgress);
|
||||
|
||||
// Start pulling back when RecentsView scale is 0.75f, and let it go down to 0.5f.
|
||||
float pullbackStartProgress = (0.75f - fromScale) / (endScale - fromScale);
|
||||
float pullbackMaxProgress = (0.5f - fromScale) / (endScale - fromScale);
|
||||
mSwipeUpPullbackStartAndMaxProgress = new Pair<>(
|
||||
pullbackStartProgress, pullbackMaxProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.annotation.TargetApi;
|
|||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
@ -49,15 +48,6 @@ public interface BaseActivityInterface<T extends BaseDraggingActivity> {
|
|||
|
||||
int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect);
|
||||
|
||||
/**
|
||||
* @return The progress of the swipe where we start resisting the user, where 0 is fullscreen
|
||||
* and 1 is recents. These values should probably be greater than 1 to let the user swipe past
|
||||
* recents before we start resisting them.
|
||||
*/
|
||||
default Pair<Float, Float> getSwipeUpPullbackStartAndMaxProgress() {
|
||||
return new Pair<>(1.4f, 1.8f);
|
||||
}
|
||||
|
||||
void onSwipeUpToRecentsComplete();
|
||||
|
||||
default void onSwipeUpToHomeComplete() { }
|
||||
|
|
Loading…
Reference in New Issue