Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef44cf8f authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing pullback factor not initialized after launcher process death

Instead of storing it on first swipe-up, computing it when required

Change-Id: I4b37002a016328e3b2d1c8535198ec8a6b56faf3
parent ae5afa74
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -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,20 +346,23 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten

        mTransitionDragLength = mActivityInterface.getSwipeUpDestinationAndLength(
                dp, mContext, TEMP_RECT);
        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;
            Pair<Float, Float> dragFactorStartAndMaxProgress =
                    mActivityInterface.getSwipeUpPullbackStartAndMaxProgress();
            mDragLengthFactorStartPullback = dragFactorStartAndMaxProgress.first;
            mDragLengthFactorMaxPullback = dragFactorStartAndMaxProgress.second;
        }

        mTaskViewSimulator.setDp(dp);
        mTaskViewSimulator.setLayoutRotation(
                mDeviceState.getCurrentActiveRotation(),
                mDeviceState.getDisplayRotation());
            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);
+0 −15
Original line number Diff line number Diff line
@@ -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
+0 −10
Original line number Diff line number Diff line
@@ -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() { }