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

Commit f3ebdd48 authored by Brian Isganitis's avatar Brian Isganitis
Browse files

Start drag from current translation shift during animation.

Test: Manual
Fix: 291950331
Flag: No
Change-Id: I67fe6a474fc1b10d8e34fb047f98af2c1e6e085c
parent 210e0002
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>

    // range [0, 1], 0=> completely open, 1=> completely closed
    protected float mTranslationShift = TRANSLATION_SHIFT_CLOSED;
    /** {@link #mTranslationShift} at the invocation of {@link #onDragStart(boolean, float)}. */
    protected float mDragStartTranslationShift;

    protected boolean mNoIntercept;
    protected @Nullable OnCloseListener mOnCloseBeginListener;
@@ -285,18 +287,23 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
    /* SingleAxisSwipeDetector.Listener */

    @Override
    public void onDragStart(boolean start, float startDisplacement) { }
    public void onDragStart(boolean start, float startDisplacement) {
        mOpenCloseAnimator.cancel();
        mDragStartTranslationShift = mTranslationShift;
    }

    @Override
    public boolean onDrag(float displacement) {
        float range = getShiftRange();
        displacement = Utilities.boundToRange(displacement, 0, range);
        setTranslationShift(displacement / range);
        setTranslationShift(Utilities.boundToRange(
                mDragStartTranslationShift + displacement / getShiftRange(),
                TRANSLATION_SHIFT_OPENED,
                TRANSLATION_SHIFT_CLOSED));
        return true;
    }

    @Override
    public void onDragEnd(float velocity) {
        mDragStartTranslationShift = 0;
        float successfulShiftThreshold = mActivityContext.getDeviceProfile().isTablet
                ? TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS : SUCCESS_TRANSITION_PROGRESS;
        if ((mSwipeDetector.isFling(velocity) && velocity > 0)