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

Commit 40e8e4c9 authored by Danesh M's avatar Danesh M Committed by Gerrit Code Review
Browse files

Lockscreen : Bunch-o-fixes

- Prevent edge gesture from conflicting with lockscreen shortcuts
- Fix lockscreen shortcuts crash where animations were being run
  on detached view
- Fix statusbar flicker when swiping keyguard in from the left
- Fade scrim away when swiping lockscreen in and out
- Fix back button not working when showing bouncer in
  external keyguard.
- Ensure we collapse bottom area after up/cancel when
  in external keyguard
- Fix issue where clock/notifications can get off-center
  when swiping to left.
- Fix bottom flicker when swiping lockscreen to left
- Only lock directional swiping when swipe helper acknowledges it.
  This allows for all the standard swipe behavior to function.
- Ensure lockscreen shortcuts are not actionable when in SHADE
- Only dismiss bottom area after lockscreen shortcuts animations
  have finished animating
- Prevent swipe when album art showing

CYNGNOS-2585
CYNGNOS-2488
CYNGNOS-2517
CYNGNOS-2390
CYNGNOS-2632
CYNGNOS-2634

Change-Id: I2fe767ed7e07b621075c755aae98121c8517b997
parent a77b5bc9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.view.IWindowManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicy;
@@ -1294,9 +1295,17 @@ public class KeyguardViewMediator extends SystemUI {
    }

    public void showKeyguard() {
        // This is to prevent left edge from interfering
        // with affordances.
        if (mStatusBar.isAffordanceSwipeInProgress()) {
            return;
        }
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                // Hide status bar window to avoid flicker,
                // slideNotificationPanelIn will make it visible later.
                mStatusBar.getStatusBarWindow().setVisibility(View.INVISIBLE);
                // Get the keyguard into the correct state by calling mStatusBar.showKeyguard()
                mStatusBar.showKeyguard();
                // Now have the notification panel slid back into view
+7 −1
Original line number Diff line number Diff line
@@ -88,7 +88,13 @@ public class KeyguardBouncer {
        if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) {
            return;
        }
        mPhoneStatusBar.getScrimController().forceHideScrims(false);
        // Don't hide bottom area if we are in the middle of a affordance
        // launch transition, since once the animation is finished, NPV
        // will take care of setting it invisible.
        if (!mPhoneStatusBar.mNotificationPanel.isLaunchTransitionRunning()) {
            mPhoneStatusBar.mKeyguardBottomArea.setVisibility(View.GONE);
        }
        // Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole
        // Keyguard. If we need to authenticate, show the bouncer.
        if (!mKeyguardView.dismiss()) {
+71 −42
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public class NotificationPanelView extends PanelView implements
    private final int mScreenHeight;
    private LiveLockScreenController mLiveLockscreenController;
    private final GestureDetector mGestureDetector;
    private ViewLinker mViewLinker;

    private enum SwipeLockedDirection {
        UNKNOWN,
@@ -274,12 +275,12 @@ public class NotificationPanelView extends PanelView implements
    SwipeHelper.SimpleCallback mSwipeCallback = new SwipeHelper.SimpleCallback() {
        @Override
        public View getChildAtPosition(MotionEvent ev) {
            return mNotificationStackScroller;
            return mViewLinker.getParent();
        }

        @Override
        public View getChildContentView(View v) {
            return mNotificationStackScroller;
            return mViewLinker.getParent();
        }

        @Override
@@ -311,11 +312,10 @@ public class NotificationPanelView extends PanelView implements
            mLiveLockscreenController.getLiveLockScreenView()
                    .onLockscreenSlideOffsetChanged(swipeProgress);

            // Ensures the status view and notifications are kept in sync when
            // being swiped away
            mKeyguardStatusView.setTranslationX(mNotificationStackScroller.getTranslationX());
            mKeyguardStatusView.setAlpha(mNotificationStackScroller.getAlpha());
            mKeyguardStatusBar.setAlpha(mNotificationStackScroller.getAlpha());
            // Fade out scrim background
            float alpha = ScrimController.SCRIM_BEHIND_ALPHA_KEYGUARD - (1f - swipeProgress);
            alpha = Math.max(0, alpha);
            mStatusBar.getScrimController().setScrimBehindColor(alpha);
            return false;
        }

@@ -348,7 +348,7 @@ public class NotificationPanelView extends PanelView implements
        final int gradientEnd = res.getColor(R.color.live_lockscreen_gradient_end);
        mGestureDetector = new GestureDetector(getContext(),
                new GestureDetector.SimpleOnGestureListener() {
            public float mDown;
            private float mDown;

            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
@@ -359,12 +359,14 @@ public class NotificationPanelView extends PanelView implements
                mCanDismissKeyguard = true;
                mShowingExternalKeyguard = false;
                mStatusBar.showBouncer();
                mStatusBar.unfocusKeyguardExternalView();
                return true;
            }

            @Override
            public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                float delta = mDown - e2.getRawY();
                delta = Math.max(0, delta);
                float screenHeightHalf = (float) mScreenHeight / 2f;
                int color = (Integer) ArgbEvaluator.getInstance()
                        .evaluate(delta / screenHeightHalf, gradientStart, gradientEnd);
@@ -430,6 +432,11 @@ public class NotificationPanelView extends PanelView implements
        mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(getContext(),
                android.R.interpolator.linear_out_slow_in);

        mViewLinker = new ViewLinker<NotificationStackScrollLayout>(mNotificationStackScroller,
                new ViewLinker.LinkInfo(mKeyguardStatusBar, ViewLinker.LINK_ALPHA),
                new ViewLinker.LinkInfo(mKeyguardStatusView, ViewLinker.LINK_ALPHA
                        | ViewLinker.LINK_TRANSLATION));

        mKeyguardBottomArea = (KeyguardBottomAreaView) View.inflate(getContext(),
                R.layout.keyguard_bottom_area, null);
        /** Keyguard bottom area lives in a separate window, and as such,
@@ -438,16 +445,17 @@ public class NotificationPanelView extends PanelView implements
        mKeyguardBottomArea.setOnInterceptTouchListener(new KeyguardBottomAreaView.OnInterceptTouchEventListener() {
            @Override
            public boolean onInterceptTouchEvent(MotionEvent e) {
                boolean intercept = mAfforanceHelper.onInterceptTouchEvent(e);
                if (!intercept) {
                boolean intercept = false;
                if (mShowingExternalKeyguard) {
                    // Handles swipe up to fade/dismiss when showing
                    // live lock screen
                    intercept = mAfforanceHelper.onInterceptTouchEvent(e);
                    if (!intercept) {
                        intercept = mGestureDetector.onTouchEvent(e);
                    }
                } else {
                    intercept = NotificationPanelView.this.onInterceptTouchEvent(e);
                }
                }
                return intercept;
            }
        });
@@ -455,20 +463,25 @@ public class NotificationPanelView extends PanelView implements
            @Override
            public boolean onTouch(View v, MotionEvent e) {
                int action = e.getAction();
                // Ensure we collapse and clear fade
                if (action == MotionEvent.ACTION_UP ||
                        action == MotionEvent.ACTION_CANCEL) {

                boolean isCancelOrUp = action == MotionEvent.ACTION_UP ||
                        action == MotionEvent.ACTION_CANCEL;
                if (isCancelOrUp) {
                    mKeyguardBottomArea.setBackground(null);
                }

                boolean intercept = mAfforanceHelper.onTouchEvent(e);
                if (!intercept) {
                boolean intercept = false;
                if (mShowingExternalKeyguard) {
                    intercept = mAfforanceHelper.onTouchEvent(e);
                    if (isCancelOrUp) {
                        mKeyguardBottomArea.expand(false);
                    }
                    if (!intercept) {
                        intercept = mGestureDetector.onTouchEvent(e);
                    }
                } else {
                    intercept = NotificationPanelView.this.onTouchEvent(e);
                }
                }
                return intercept;
            }
        });
@@ -491,6 +504,10 @@ public class NotificationPanelView extends PanelView implements
        });
    }

    public boolean isAffordanceSwipeInProgress() {
        return mAfforanceHelper.isSwipingInProgress();
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
@@ -807,7 +824,7 @@ public class NotificationPanelView extends PanelView implements
            return true;
        }

        if (isKeyguardInteractiveAndShowing()) {
        if (isKeyguardInteractiveAndShowing() || mStatusBar.isKeyguardShowingMedia()) {
            return super.onInterceptTouchEvent(event);
        }

@@ -987,7 +1004,7 @@ public class NotificationPanelView extends PanelView implements
        }
        if ((!mIsExpanding || mHintAnimationRunning)
                && !mQsExpanded
                && mStatusBar.getBarState() != StatusBarState.SHADE) {
                && (mStatusBar.getBarState() != StatusBarState.SHADE || mShowingExternalKeyguard)) {
            mAfforanceHelper.onTouchEvent(event);
        }
        if (mOnlyAffordanceInThisMotion) {
@@ -1002,26 +1019,29 @@ public class NotificationPanelView extends PanelView implements
            updateVerticalPanelPosition(event.getX());
        }

        if (isKeyguardInteractiveAndShowing()) {
        if (isKeyguardInteractiveAndShowing() || mStatusBar.isKeyguardShowingMedia()) {
            super.onTouchEvent(event);
            return true;
        }

        if (!mSwipeHelper.isDragging() && super.onTouchEvent(event)) {
            mLockedDirection = SwipeLockedDirection.VERTICAL;
            return true;
        }

        if ((!mIsExpanding || mHintAnimationRunning)
                && !mQsExpanded
                && mLockedDirection != SwipeLockedDirection.VERTICAL
                && mStatusBar.getBarState() != StatusBarState.SHADE) {
            if (mSwipeHelper.onTouchEvent(event)) {
            mSwipeHelper.onTouchEvent(event);
            if (mSwipeHelper.isDragging()) {
                mLockedDirection = SwipeLockedDirection.HORIZONTAL;
            }
            if (mLockedDirection == SwipeLockedDirection.HORIZONTAL) {
                requestDisallowInterceptTouchEvent(true);
                return true;
            }
        }
        return false;

        if (super.onTouchEvent(event)) {
            mLockedDirection = SwipeLockedDirection.VERTICAL;
        }
        return true;
    }

    private boolean isKeyguardInteractiveAndShowing() {
@@ -2028,9 +2048,6 @@ public class NotificationPanelView extends PanelView implements
            alpha = getNotificationsTopY()
                    /
                    (mKeyguardStatusBar.getHeight() + mNotificationsHeaderCollideDistance);
        } else if (mStatusBar.getBarState() == StatusBarState.SHADE &&
                mLiveLockscreenController.isShowingLiveLockScreenView()) {
            alpha = 1;
        } else {

            // In SHADE_LOCKED, the top card is already really close to the header. Hide it as
@@ -2043,6 +2060,9 @@ public class NotificationPanelView extends PanelView implements
    }

    private void updateHeaderKeyguardAlpha() {
        if (mSwipeHelper.isDragging()) {
            return;
        }
        float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2);
        mKeyguardStatusBar.setAlpha(Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
                * mKeyguardStatusBarAnimateAlpha);
@@ -2057,6 +2077,9 @@ public class NotificationPanelView extends PanelView implements

    private void updateKeyguardBottomAreaAlpha() {
        float alpha = Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction());
        if (mShowingExternalKeyguard) {
            alpha = 1f;
        }
        mKeyguardBottomArea.setAlpha(alpha);
        mKeyguardBottomArea.setImportantForAccessibility(alpha == 0f
                ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
@@ -2280,6 +2303,7 @@ public class NotificationPanelView extends PanelView implements
            mLaunchAnimationEndRunnable.run();
            mLaunchAnimationEndRunnable = null;
        }
        mKeyguardBottomArea.setVisibility(View.GONE);
    }

    @Override
@@ -2836,16 +2860,20 @@ public class NotificationPanelView extends PanelView implements

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            View statusBarView = mStatusBar.getStatusBarWindow();
            if (valueAnimator.getAnimatedFraction() > 0 &&
                    statusBarView.getVisibility() != View.VISIBLE) {
                statusBarView.setVisibility(View.VISIBLE);
            }
            float translationX = (Float) valueAnimator.getAnimatedValue();
            float alpha = valueAnimator.getAnimatedFraction();

            mNotificationStackScroller.setTranslationX(translationX);
            mNotificationStackScroller.setAlpha(alpha);

            mKeyguardStatusView.setTranslationX(translationX);
            mKeyguardStatusView.setAlpha(alpha);
            mViewLinker.getParent().setTranslationX(translationX);
            mViewLinker.getParent().setAlpha(alpha);

            mKeyguardStatusBar.setAlpha(alpha);
            float alpha1 = ScrimController.SCRIM_BEHIND_ALPHA_KEYGUARD * alpha;
            alpha1 = Math.max(0, alpha1);
            mStatusBar.getScrimController().setScrimBehindColor(alpha1);
            mLiveLockscreenController.getLiveLockScreenView()
                    .onLockscreenSlideOffsetChanged(alpha);
        }
@@ -2866,6 +2894,7 @@ public class NotificationPanelView extends PanelView implements
        mKeyguardStatusView.setTranslationX(mNotificationStackScroller.getTranslationX());
        mKeyguardStatusBar.setAlpha(0f);

        mStatusBar.getScrimController().setScrimBehindColor(0f);
        ValueAnimator animator = ValueAnimator.ofFloat(
                mNotificationStackScroller.getTranslationX(),
                0f);
+14 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

    StatusBarWindowView mStatusBarWindow;
    FrameLayout mStatusBarWindowContent;
    PhoneStatusBarView mStatusBarView;
    private PhoneStatusBarView mStatusBarView;
    private int mStatusBarWindowState = WINDOW_STATE_SHOWING;
    private StatusBarWindowManager mStatusBarWindowManager;
    private UnlockMethodCache mUnlockMethodCache;
@@ -494,6 +494,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }
    }

    public void setStatusBarViewVisibility(boolean visible) {
        mStatusBarView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
    }

    class DevForceNavbarObserver extends UserContentObserver {
        DevForceNavbarObserver(Handler handler) {
            super(handler);
@@ -789,6 +793,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private RankingMap mLatestRankingMap;
    private boolean mNoAnimationOnNextBarModeChange;

    public ScrimController getScrimController() {
        return mScrimController;
    }

    @Override
    public void start() {
        mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
@@ -4338,6 +4346,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mDraggedDownRow = null;
        }
        mAssistManager.onLockscreenShown();
        mKeyguardBottomArea.requestFocus();
        if (mLiveLockScreenController.isShowingLiveLockScreenView()) {
            mLiveLockScreenController.getLiveLockScreenView().onKeyguardShowing(
                    mStatusBarKeyguardViewManager.isScreenTurnedOn());
@@ -5531,4 +5540,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            }
        }
    }

    public boolean isAffordanceSwipeInProgress() {
        return mNotificationPanel.isAffordanceSwipeInProgress();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -45,9 +45,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
    public static final long ANIMATION_DURATION = 220;
    public static final Interpolator KEYGUARD_FADE_OUT_INTERPOLATOR
            = new PathInterpolator(0f, 0, 0.7f, 1f);
    public static final float SCRIM_BEHIND_ALPHA_KEYGUARD = 0.45f;

    private static final float SCRIM_BEHIND_ALPHA = 0.62f;
    private static final float SCRIM_BEHIND_ALPHA_KEYGUARD = 0.45f;
    private static final float SCRIM_BEHIND_ALPHA_UNLOCKING = 0.2f;
    private static final float SCRIM_IN_FRONT_ALPHA = 0.75f;
    private static final int TAG_KEY_ANIM = R.id.scrim;
@@ -255,7 +255,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
        }
    }

    private void setScrimBehindColor(float alpha) {
    public void setScrimBehindColor(float alpha) {
        setScrimColor(mScrimBehind, alpha);
    }

Loading