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

Commit 5386fb33 authored by Selim Cinek's avatar Selim Cinek Committed by Dan Sandler
Browse files

Tuned anti-falsing thresholds on the lockscreen

Also added logic to provide nicer animations when falsing.
In addition adapted the clock scale slightly if dragging
in the void.

Bug: 15433087
Change-Id: I4d8eb26cc81d22647ef4d2eca1e69b4994a7f1e2
parent cab4a60c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -286,13 +286,13 @@
    <dimen name="speed_bump_height">16dp</dimen>

    <!-- Lockscreen unlocking falsing threshold. -->
    <dimen name="unlock_falsing_threshold">100dp</dimen>
    <dimen name="unlock_falsing_threshold">80dp</dimen>

    <!-- Lockscreen falsing threshold for quick settings. -->
    <dimen name="qs_falsing_threshold">60dp</dimen>
    <dimen name="qs_falsing_threshold">80dp</dimen>

    <!-- Falsing threshold used when dismissing notifications from the lockscreen. -->
    <dimen name="swipe_helper_falsing_threshold">100dp</dimen>
    <dimen name="swipe_helper_falsing_threshold">70dp</dimen>

    <dimen name="notifications_top_padding">8dp</dimen>
    
@@ -312,7 +312,7 @@
    <dimen name="heads_up_window_height">250dp</dimen>

    <!-- The minimum amount the user needs to swipe to go to the camera / phone. -->
    <dimen name="keyguard_min_swipe_amount">85dp</dimen>
    <dimen name="keyguard_min_swipe_amount">90dp</dimen>

    <!-- The minimum background radius when swiping to a side for the camera / phone affordances. -->
    <dimen name="keyguard_affordance_min_background_radius">30dp</dimen>
+14 −7
Original line number Diff line number Diff line
@@ -251,15 +251,19 @@ public class KeyguardAffordanceView extends ImageView {
    }

    public void setCircleRadius(float circleRadius) {
        setCircleRadius(circleRadius, false);
        setCircleRadius(circleRadius, false, false);
    }

    public void setCircleRadius(float circleRadius, boolean slowAnimation) {
        setCircleRadius(circleRadius, slowAnimation, false);
    }

    public void setCircleRadiusWithoutAnimation(float circleRadius) {
        cancelAnimator(mCircleAnimator);
        setCircleRadius(circleRadius, true);
        setCircleRadius(circleRadius, false ,true);
    }

    private void setCircleRadius(float circleRadius, boolean noAnimation) {
    private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {

        // Check if we need a new animation
        boolean radiusHidden = (mCircleAnimator != null && mCircleWillBeHidden)
@@ -292,10 +296,13 @@ public class KeyguardAffordanceView extends ImageView {
                    ? mDisappearInterpolator
                    : mAppearInterpolator;
            animator.setInterpolator(interpolator);
            long duration = 250;
            if (!slowAnimation) {
                float durationFactor = Math.abs(mCircleRadius - circleRadius)
                        / (float) mMinBackgroundRadius;
            long duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
                duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
                duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
            }
            animator.setDuration(duration);
            animator.start();
            if (mPreviewView != null && mPreviewView.getVisibility() == View.VISIBLE) {
+18 −15
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -85,9 +83,9 @@ public class KeyguardAffordanceHelper {
        mContext = context;
        mCallback = callback;
        initIcons();
        updateIcon(mLeftIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
        updateIcon(mCenterIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
        updateIcon(mRightIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
        updateIcon(mLeftIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false, false);
        updateIcon(mCenterIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false, false);
        updateIcon(mRightIcon, 0.0f, SWIPE_RESTING_ALPHA_AMOUNT, false, false);
        initDimens();
    }

@@ -295,8 +293,7 @@ public class KeyguardAffordanceHelper {
        float vel = getCurrentVelocity();

        // We snap back if the current translation is not far enough
        boolean snapBack = Math.abs(mTranslation) < Math.abs(mTranslationOnDown)
                + mMinTranslationAmount;
        boolean snapBack = isBelowFalsingThreshold();

        // or if the velocity is in the opposite direction.
        boolean velIsInWrongDirection = vel * mTranslation < 0;
@@ -305,6 +302,11 @@ public class KeyguardAffordanceHelper {
        fling(vel, snapBack || forceSnapBack);
    }

    private boolean isBelowFalsingThreshold() {
        return Math.abs(mTranslation) < Math.abs(mTranslationOnDown)
                + mMinTranslationAmount;
    }

    private void fling(float vel, final boolean snapBack) {
        float target = mTranslation < 0 ? -mCallback.getPageWidth() : mCallback.getPageWidth();
        target = snapBack ? 0 : target;
@@ -355,13 +357,14 @@ public class KeyguardAffordanceHelper {

            boolean animateIcons = isReset && animateReset;
            float radius = getRadiusFromTranslation(absTranslation);
            boolean slowAnimation = isReset && isBelowFalsingThreshold();
            if (!isReset) {
                updateIcon(targetView, radius, alpha, false);
                updateIcon(targetView, radius, alpha, false, false);
            } else {
                updateIcon(targetView, 0.0f, fadeOutAlpha, animateIcons);
                updateIcon(targetView, 0.0f, fadeOutAlpha, animateIcons, slowAnimation);
            }
            updateIcon(otherView, 0.0f, fadeOutAlpha, animateIcons);
            updateIcon(mCenterIcon, 0.0f, fadeOutAlpha, animateIcons);
            updateIcon(otherView, 0.0f, fadeOutAlpha, animateIcons, slowAnimation);
            updateIcon(mCenterIcon, 0.0f, fadeOutAlpha, animateIcons, slowAnimation);

            mTranslation = translation;
        }
@@ -392,16 +395,16 @@ public class KeyguardAffordanceHelper {
    }

    public void animateHideLeftRightIcon() {
        updateIcon(mRightIcon, 0f, 0f, true);
        updateIcon(mLeftIcon, 0f, 0f, true);
        updateIcon(mRightIcon, 0f, 0f, true, false);
        updateIcon(mLeftIcon, 0f, 0f, true, false);
    }

    private void updateIcon(KeyguardAffordanceView view, float circleRadius, float alpha,
            boolean animate) {
            boolean animate, boolean slowRadiusAnimation) {
        if (view.getVisibility() != View.VISIBLE) {
            return;
        }
        view.setCircleRadius(circleRadius);
        view.setCircleRadius(circleRadius, slowRadiusAnimation);
        updateIconAlpha(view, alpha, animate);
    }

+14 −3
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ public class NotificationPanelView extends PanelView implements
    }

    private boolean flingExpandsQs(float vel) {
        if (!mQsTouchAboveFalsingThreshold && mStatusBarState == StatusBarState.KEYGUARD) {
        if (isBelowFalsingThreshold()) {
            return false;
        }
        if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
@@ -561,6 +561,10 @@ public class NotificationPanelView extends PanelView implements
        }
    }

    private boolean isBelowFalsingThreshold() {
        return !mQsTouchAboveFalsingThreshold && mStatusBar.isFalsingThresholdNeeded();
    }

    private float getQsExpansionFraction() {
        return Math.min(1f, (mQsExpansionHeight - mQsMinExpansionHeight)
                / (getTempQsMaxExpansion() - mQsMinExpansionHeight));
@@ -1125,9 +1129,16 @@ public class NotificationPanelView extends PanelView implements
            }
            return;
        }
        boolean belowFalsingThreshold = isBelowFalsingThreshold();
        if (belowFalsingThreshold) {
            vel = 0;
        }
        mScrollView.setBlockFlinging(true);
        ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
        mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel);
        if (belowFalsingThreshold) {
            animator.setDuration(350);
        }
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
@@ -1732,9 +1743,9 @@ public class NotificationPanelView extends PanelView implements
    }

    public void setEmptyDragAmount(float amount) {
        float factor = 1f;
        float factor = 0.8f;
        if (mNotificationStackScroller.getNotGoneChildCount() > 0) {
            factor = 0.6f;
            factor = 0.4f;
        } else if (!mStatusBar.hasActiveNotifications()) {
            factor = 0.4f;
        }
+12 −1
Original line number Diff line number Diff line
@@ -479,7 +479,7 @@ public abstract class PanelView extends FrameLayout {
     * @return whether a fling should expands the panel; contracts otherwise
     */
    protected boolean flingExpands(float vel, float vectorVel) {
        if (!mTouchAboveFalsingThreshold && mStatusBar.isFalsingThresholdNeeded()) {
        if (isBelowFalsingThreshold()) {
            return true;
        }
        if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
@@ -489,6 +489,10 @@ public abstract class PanelView extends FrameLayout {
        }
    }

    private boolean isBelowFalsingThreshold() {
        return !mTouchAboveFalsingThreshold && mStatusBar.isFalsingThresholdNeeded();
    }

    protected void fling(float vel, boolean expand) {
        cancelPeek();
        float target = expand ? getMaxPanelHeight() : 0.0f;
@@ -509,7 +513,14 @@ public abstract class PanelView extends FrameLayout {
        mOverExpandedBeforeFling = getOverExpansionAmount() > 0f;
        ValueAnimator animator = createHeightAnimator(target);
        if (expand) {
            boolean belowFalsingThreshold = isBelowFalsingThreshold();
            if (belowFalsingThreshold) {
                vel = 0;
            }
            mFlingAnimationUtils.apply(animator, mExpandedHeight, target, vel, getHeight());
            if (belowFalsingThreshold) {
                animator.setDuration(350);
            }
        } else {
            mFlingAnimationUtils.applyDismissing(animator, mExpandedHeight, target, vel,
                    getHeight());