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

Commit c9d779ca authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Fix drag down animation when bypassing" into sc-v2-dev

parents ca31c5e7 d879f880
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -52,13 +52,6 @@ public interface QS extends FragmentBase {
    void setListening(boolean listening);
    boolean isShowingDetail();
    void closeDetail();

    /**
     * Set that we're currently pulse expanding
     *
     * @param pulseExpanding if we're currently expanding during pulsing
     */
    default void setPulseExpanding(boolean pulseExpanding) {}
    void animateHeaderSlidingOut();
    void setQsExpansion(float qsExpansionFraction, float headerTranslation);
    void setHeaderListening(boolean listening);
+1 −1
Original line number Diff line number Diff line
@@ -1462,7 +1462,7 @@
    <dimen name="lockscreen_shade_notification_movement">24dp</dimen>

    <!-- Maximum overshoot for the pulse expansion -->
    <dimen name="pulse_expansion_max_top_overshoot">16dp</dimen>
    <dimen name="pulse_expansion_max_top_overshoot">32dp</dimen>

    <dimen name="people_space_widget_radius">28dp</dimen>
    <dimen name="people_space_image_radius">20dp</dimen>
+6 −9
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.qs.dagger.QSFragmentComponent;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.util.InjectionInflationController;
@@ -69,6 +70,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
    private final Rect mQsBounds = new Rect();
    private final StatusBarStateController mStatusBarStateController;
    private final FalsingManager mFalsingManager;
    private final KeyguardBypassController mBypassController;
    private boolean mQsExpanded;
    private boolean mHeaderAnimating;
    private boolean mStackScrollerOverscrolling;
@@ -135,6 +137,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
            StatusBarStateController statusBarStateController, CommandQueue commandQueue,
            QSDetailDisplayer qsDetailDisplayer, @Named(QS_PANEL) MediaHost qsMediaHost,
            @Named(QUICK_QS_PANEL) MediaHost qqsMediaHost,
            KeyguardBypassController keyguardBypassController,
            QSFragmentComponent.Factory qsComponentFactory,
            FalsingManager falsingManager) {
        mRemoteInputQuickSettingsDisabler = remoteInputQsDisabler;
@@ -147,6 +150,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
        commandQueue.observe(getLifecycle(), this);
        mHost = qsTileHost;
        mFalsingManager = falsingManager;
        mBypassController = keyguardBypassController;
        mStatusBarStateController = statusBarStateController;
    }

@@ -385,16 +389,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
        return mStatusBarStateController.getState() == StatusBarState.KEYGUARD;
    }

    @Override
    public void setPulseExpanding(boolean pulseExpanding) {
        if (pulseExpanding != mPulseExpanding) {
            mPulseExpanding = pulseExpanding;
            updateShowCollapsedOnKeyguard();
        }
    }

    private void updateShowCollapsedOnKeyguard() {
        boolean showCollapsed = mPulseExpanding || mTransitioningToFullShade;
        boolean showCollapsed = mBypassController.getBypassEnabled() || mTransitioningToFullShade;
        if (showCollapsed != mShowCollapsedOnKeyguard) {
            mShowCollapsedOnKeyguard = showCollapsed;
            updateQsState();
@@ -724,5 +720,6 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
    public void onStateChanged(int newState) {
        mState = newState;
        setKeyguardShowing(newState == StatusBarState.KEYGUARD);
        updateShowCollapsedOnKeyguard();
    }
}
+76 −8
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ class LockscreenShadeTransitionController @Inject constructor(
    configurationController: ConfigurationController,
    falsingManager: FalsingManager
) {
    private var pulseHeight: Float = 0f
    private var useSplitShade: Boolean = false
    private lateinit var nsslController: NotificationStackScrollLayoutController
    lateinit var notificationPanelController: NotificationPanelViewController
@@ -86,6 +87,12 @@ class LockscreenShadeTransitionController @Inject constructor(
    @VisibleForTesting
    internal var dragDownAnimator: ValueAnimator? = null

    /**
     * The current pulse height animator if any
     */
    @VisibleForTesting
    internal var pulseHeightAnimator: ValueAnimator? = null

    /**
     * Distance that the full shade transition takes in order for scrim to fully transition to
     * the shade (in alpha)
@@ -108,6 +115,12 @@ class LockscreenShadeTransitionController @Inject constructor(
     */
    private var nextHideKeyguardNeedsNoAnimation = false

    /**
     * The distance until we're showing the notifications when pulsing
     */
    val distanceUntilShowingPulsingNotifications
        get() = scrimTransitionDistance

    /**
     * The udfpsKeyguardViewController if it exists.
     */
@@ -285,21 +298,25 @@ class LockscreenShadeTransitionController @Inject constructor(
                    nsslController.setTransitionToFullShadeAmount(field)
                    notificationPanelController.setTransitionToFullShadeAmount(field,
                            false /* animate */, 0 /* delay */)
                    val scrimProgress = MathUtils.saturate(field / scrimTransitionDistance)
                    scrimController.setTransitionToFullShadeProgress(scrimProgress)
                    // TODO: appear qs also in split shade
                    val qsAmount = if (useSplitShade) 0f else field
                    qS.setTransitionToFullShadeAmount(qsAmount, false /* animate */)
                    // TODO: appear media also in split shade
                    val mediaAmount = if (useSplitShade) 0f else field
                    mediaHierarchyManager.setTransitionToFullShadeAmount(mediaAmount)
                    transitionToShadeAmountCommon(field)
                }
            }
        }

    private fun transitionToShadeAmountCommon(dragDownAmount: Float) {
        val scrimProgress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance)
        scrimController.setTransitionToFullShadeProgress(scrimProgress)
        // Fade out all content only visible on the lockscreen
        notificationPanelController.setKeyguardOnlyContentAlpha(1.0f - scrimProgress)
        depthController.transitionToFullShadeProgress = scrimProgress
        udfpsKeyguardViewController?.setTransitionToFullShadeProgress(scrimProgress)
    }
            }
        }

    private fun setDragDownAmountAnimated(
        target: Float,
@@ -452,15 +469,19 @@ class LockscreenShadeTransitionController @Inject constructor(
    /**
     * Notify this handler that the keyguard was just dismissed and that a animation to
     * the full shade should happen.
     *
     * @param delay the delay to do the animation with
     * @param previousState which state were we in when we hid the keyguard?
     */
    fun onHideKeyguard(delay: Long) {
    fun onHideKeyguard(delay: Long, previousState: Int) {
        if (animationHandlerOnKeyguardDismiss != null) {
            animationHandlerOnKeyguardDismiss!!.invoke(delay)
            animationHandlerOnKeyguardDismiss = null
        } else {
            if (nextHideKeyguardNeedsNoAnimation) {
                nextHideKeyguardNeedsNoAnimation = false
            } else {
            } else if (previousState != StatusBarState.SHADE_LOCKED) {
                // No animation necessary if we already were in the shade locked!
                performDefaultGoToFullShadeAnimation(delay)
            }
        }
@@ -478,6 +499,53 @@ class LockscreenShadeTransitionController @Inject constructor(
        notificationPanelController.animateToFullShade(delay)
        animateAppear(delay)
    }

    //
    // PULSE EXPANSION
    //

    /**
     * Set the height how tall notifications are pulsing. This is only set whenever we are expanding
     * from a pulse and determines how much the notifications are expanded.
     */
    fun setPulseHeight(height: Float, animate: Boolean = false) {
        if (animate) {
            val pulseHeightAnimator = ValueAnimator.ofFloat(pulseHeight, height)
            pulseHeightAnimator.interpolator = Interpolators.FAST_OUT_SLOW_IN
            pulseHeightAnimator.duration = SPRING_BACK_ANIMATION_LENGTH_MS
            pulseHeightAnimator.addUpdateListener { animation: ValueAnimator ->
                setPulseHeight(animation.animatedValue as Float)
            }
            pulseHeightAnimator.start()
            this.pulseHeightAnimator = pulseHeightAnimator
        } else {
            pulseHeight = height
            val overflow = nsslController.setPulseHeight(height)
            notificationPanelController.setOverStrechAmount(overflow)
            val transitionHeight = if (keyguardBypassController.bypassEnabled) height else 0.0f
            transitionToShadeAmountCommon(transitionHeight)
        }
    }

    /**
     * Finish the pulse animation when the touch interaction finishes
     * @param cancelled was the interaction cancelled and this is a reset?
     */
    fun finishPulseAnimation(cancelled: Boolean) {
        if (cancelled) {
            setPulseHeight(0f, animate = true)
        } else {
            notificationPanelController.onPulseExpansionFinished()
            setPulseHeight(0f, animate = false)
        }
    }

    /**
     * Notify this class that a pulse expansion is starting
     */
    fun onPulseExpansionStarted() {
        pulseHeightAnimator?.cancel()
    }
}

/**
+29 −56
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.systemui.statusbar
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Configuration
import android.os.PowerManager
import android.os.PowerManager.WAKE_REASON_GESTURE
import android.os.SystemClock
@@ -42,6 +42,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationRoundnessMa
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.policy.ConfigurationController
import javax.inject.Inject
import kotlin.math.max

@@ -56,18 +57,17 @@ constructor(
    private val bypassController: KeyguardBypassController,
    private val headsUpManager: HeadsUpManagerPhone,
    private val roundnessManager: NotificationRoundnessManager,
    private val configurationController: ConfigurationController,
    private val statusBarStateController: StatusBarStateController,
    private val falsingManager: FalsingManager,
    private val lockscreenShadeTransitionController: LockscreenShadeTransitionController,
    private val falsingCollector: FalsingCollector
) : Gefingerpoken {
    companion object {
        private val RUBBERBAND_FACTOR_STATIC = 0.25f
        private val SPRING_BACK_ANIMATION_LENGTH_MS = 375
    }
    private val mPowerManager: PowerManager?

    private val mMinDragDistance: Int
    private var mInitialTouchX: Float = 0.0f
    private var mInitialTouchY: Float = 0.0f
    var isExpanding: Boolean = false
@@ -81,6 +81,7 @@ constructor(
                    topEntry?.let {
                        roundnessManager.setTrackingHeadsUp(it.row)
                    }
                    lockscreenShadeTransitionController.onPulseExpansionStarted()
                } else {
                    roundnessManager.setTrackingHeadsUp(null)
                    if (!leavingLockscreen) {
@@ -93,8 +94,8 @@ constructor(
        }
    var leavingLockscreen: Boolean = false
        private set
    private val mTouchSlop: Float
    private lateinit var overStretchHandler: OverStretchHandler
    private var touchSlop = 0f
    private var minDragDistance = 0
    private lateinit var stackScrollerController: NotificationStackScrollLayoutController
    private val mTemp2 = IntArray(2)
    private var mDraggedFarEnough: Boolean = false
@@ -102,9 +103,7 @@ constructor(
    private var mPulsing: Boolean = false
    var isWakingToShadeLocked: Boolean = false
        private set
    private var overStretchAmount: Float = 0.0f
    private var mWakeUpHeight: Float = 0.0f
    private var mReachedWakeUpHeight: Boolean = false

    private var velocityTracker: VelocityTracker? = null

    private val isFalseTouch: Boolean
@@ -114,12 +113,21 @@ constructor(
    var bouncerShowing: Boolean = false

    init {
        mMinDragDistance = context.resources.getDimensionPixelSize(
                R.dimen.keyguard_drag_down_min_distance)
        mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat()
        initResources(context)
        configurationController.addCallback(object : ConfigurationController.ConfigurationListener {
            override fun onConfigChanged(newConfig: Configuration?) {
                initResources(context)
            }
        })
        mPowerManager = context.getSystemService(PowerManager::class.java)
    }

    private fun initResources(context: Context) {
        minDragDistance = context.resources.getDimensionPixelSize(
            R.dimen.keyguard_drag_down_min_distance)
        touchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat()
    }

    override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
        return canHandleMotionEvent() && startExpansion(event)
    }
@@ -148,14 +156,12 @@ constructor(

            MotionEvent.ACTION_MOVE -> {
                val h = y - mInitialTouchY
                if (h > mTouchSlop && h > Math.abs(x - mInitialTouchX)) {
                if (h > touchSlop && h > Math.abs(x - mInitialTouchX)) {
                    falsingCollector.onStartExpandingFromPulse()
                    isExpanding = true
                    captureStartingChild(mInitialTouchX, mInitialTouchY)
                    mInitialTouchY = y
                    mInitialTouchX = x
                    mWakeUpHeight = wakeUpCoordinator.getWakeUpHeight()
                    mReachedWakeUpHeight = false
                    return true
                }
            }
@@ -216,7 +222,6 @@ constructor(
    }

    private fun finishExpansion() {
        resetClock()
        val startingChild = mStartingChild
        if (mStartingChild != null) {
            setUserLocked(mStartingChild!!, false)
@@ -230,6 +235,7 @@ constructor(
        }
        lockscreenShadeTransitionController.goToLockedShade(startingChild,
                needsQSAnimation = false)
        lockscreenShadeTransitionController.finishPulseAnimation(cancelled = false)
        leavingLockscreen = true
        isExpanding = false
        if (mStartingChild is ExpandableNotificationRow) {
@@ -240,24 +246,19 @@ constructor(

    private fun updateExpansionHeight(height: Float) {
        var expansionHeight = max(height, 0.0f)
        if (!mReachedWakeUpHeight && height > mWakeUpHeight) {
            mReachedWakeUpHeight = true
        }
        if (mStartingChild != null) {
            val child = mStartingChild!!
            val newHeight = Math.min((child.collapsedHeight + expansionHeight).toInt(),
                    child.maxContentHeight)
            child.actualHeight = newHeight
            expansionHeight = max(newHeight.toFloat(), expansionHeight)
        } else {
            val target = if (mReachedWakeUpHeight) mWakeUpHeight else 0.0f
            wakeUpCoordinator.setNotificationsVisibleForExpansion(height > target,
            wakeUpCoordinator.setNotificationsVisibleForExpansion(
                height
                    > lockscreenShadeTransitionController.distanceUntilShowingPulsingNotifications,
                true /* animate */,
                true /* increaseSpeed */)
            expansionHeight = max(mWakeUpHeight, expansionHeight)
        }
        val dragDownAmount = wakeUpCoordinator.setPulseHeight(expansionHeight)
        setOverStretchAmount(dragDownAmount)
        lockscreenShadeTransitionController.setPulseHeight(expansionHeight, animate = false)
    }

    private fun captureStartingChild(x: Float, y: Float) {
@@ -269,11 +270,6 @@ constructor(
        }
    }

    private fun setOverStretchAmount(amount: Float) {
        overStretchAmount = amount
        overStretchHandler.setOverStretchAmount(amount)
    }

    private fun reset(child: ExpandableView) {
        if (child.actualHeight == child.collapsedHeight) {
            setUserLocked(child, false)
@@ -297,25 +293,14 @@ constructor(
        }
    }

    private fun resetClock() {
        val anim = ValueAnimator.ofFloat(overStretchAmount, 0f)
        anim.interpolator = Interpolators.FAST_OUT_SLOW_IN
        anim.duration = SPRING_BACK_ANIMATION_LENGTH_MS.toLong()
        anim.addUpdateListener {
            animation -> setOverStretchAmount(animation.animatedValue as Float)
        }
        anim.start()
    }

    private fun cancelExpansion() {
        isExpanding = false
        falsingCollector.onExpansionFromPulseStopped()
        if (mStartingChild != null) {
            reset(mStartingChild!!)
            mStartingChild = null
        } else {
            resetClock()
        }
        lockscreenShadeTransitionController.finishPulseAnimation(cancelled = true)
        wakeUpCoordinator.setNotificationsVisibleForExpansion(false /* visible */,
                true /* animate */,
                false /* increaseSpeed */)
@@ -333,11 +318,7 @@ constructor(
        } else null
    }

    fun setUp(
        stackScrollerController: NotificationStackScrollLayoutController,
        overStrechHandler: OverStretchHandler
    ) {
        this.overStretchHandler = overStrechHandler
    fun setUp(stackScrollerController: NotificationStackScrollLayoutController) {
        this.stackScrollerController = stackScrollerController
    }

@@ -348,12 +329,4 @@ constructor(
    fun onStartedWakingUp() {
        isWakingToShadeLocked = false
    }

    interface OverStretchHandler {

        /**
         * Set the overstretch amount in pixels This will be rubberbanded later
         */
        fun setOverStretchAmount(amount: Float)
    }
}
Loading