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

Commit b23bcda6 authored by Miranda Kephart's avatar Miranda Kephart Committed by Automerger Merge Worker
Browse files

Merge "Limit maximum dismiss distance for screenshot/clipboard UI" into...

Merge "Limit maximum dismiss distance for screenshot/clipboard UI" into tm-qpr-dev am: 0f7e276a am: 2279baa4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21755479



Change-Id: Ib995aca55935ea28eb8c206bbf5ac0b0b074b61b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4adc9cca 2279baa4
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class DraggableConstraintLayout extends ConstraintLayout
        implements ViewTreeObserver.OnComputeInternalInsetsListener {

    private static final float VELOCITY_DP_PER_MS = 1;
    private static final int MAXIMUM_DISMISS_DISTANCE_DP = 400;

    private final SwipeDismissHandler mSwipeDismissHandler;
    private final GestureDetector mSwipeDetector;
@@ -347,14 +348,18 @@ public class DraggableConstraintLayout extends ConstraintLayout
            } else {
                finalX = -1 * getBackgroundRight();
            }
            float distance = Math.abs(finalX - startX);
            float distance = Math.min(Math.abs(finalX - startX),
                    FloatingWindowUtil.dpToPx(mDisplayMetrics, MAXIMUM_DISMISS_DISTANCE_DP));
            // ensure that view dismisses in the right direction (right in LTR, left in RTL)
            float distanceVector = Math.copySign(distance, finalX - startX);

            anim.addUpdateListener(animation -> {
                float translation = MathUtils.lerp(startX, finalX, animation.getAnimatedFraction());
                float translation = MathUtils.lerp(
                        startX, startX + distanceVector, animation.getAnimatedFraction());
                mView.setTranslationX(translation);
                mView.setAlpha(1 - animation.getAnimatedFraction());
            });
            anim.setDuration((long) (distance / Math.abs(velocity)));
            anim.setDuration((long) (Math.abs(distance / velocity)));
            return anim;
        }