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

Commit e8ae6082 authored by Nick Chameyev's avatar Nick Chameyev Committed by Android (Google) Code Review
Browse files

Merge "Reset NotificationPanelView when pressing power button before fold to AOD animation"

parents b9728c63 0950ca8a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3928,6 +3928,15 @@ public class NotificationPanelViewController extends PanelViewController {
        mKeyguardStatusViewController.animateFoldToAod();
    }

    /**
     * Cancels fold to AOD transition and resets view state
     */
    public void cancelFoldToAodAnimation() {
        cancelAnimation();
        resetAlpha();
        resetTranslation();
    }

    /** */
    public void setImportantForAccessibility(int mode) {
        mView.setImportantForAccessibility(mode);
@@ -4046,6 +4055,10 @@ public class NotificationPanelViewController extends PanelViewController {
        mView.setTranslationX(0f);
    }

    public void resetAlpha() {
        mView.setAlpha(1f);
    }

    public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) {
        return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration(
                durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction(
+3 −3
Original line number Diff line number Diff line
@@ -2998,7 +2998,7 @@ public class StatusBar extends CoreStartable implements
    }

    private void onLaunchTransitionFadingEnded() {
        mNotificationPanelViewController.setAlpha(1.0f);
        mNotificationPanelViewController.resetAlpha();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        releaseGestureWakeLock();
        runLaunchTransitionEndRunnable();
@@ -3029,7 +3029,7 @@ public class StatusBar extends CoreStartable implements
            }
            updateScrimController();
            mPresenter.updateMediaMetaData(false, true);
            mNotificationPanelViewController.setAlpha(1);
            mNotificationPanelViewController.resetAlpha();
            mNotificationPanelViewController.fadeOut(
                    FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION,
                    this::onLaunchTransitionFadingEnded);
@@ -3130,7 +3130,7 @@ public class StatusBar extends CoreStartable implements
        releaseGestureWakeLock();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.cancelAnimation();
        mNotificationPanelViewController.setAlpha(1f);
        mNotificationPanelViewController.resetAlpha();
        mNotificationPanelViewController.resetTranslation();
        mNotificationPanelViewController.resetViewGroupFade();
        updateDozingState();
+20 −5
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package com.android.systemui.unfold

import android.os.Handler
import android.os.PowerManager
import android.provider.Settings
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.statusbar.LightRevealScrim
@@ -37,6 +39,7 @@ import javax.inject.Inject
class FoldAodAnimationController
@Inject
constructor(
    @Main private val handler: Handler,
    private val keyguardViewMediatorLazy: Lazy<KeyguardViewMediator>,
    private val wakefulnessLifecycle: WakefulnessLifecycle,
    private val globalSettings: GlobalSettings
@@ -50,6 +53,14 @@ constructor(
    private var shouldPlayAnimation = false
    private val statusListeners = arrayListOf<FoldAodAnimationStatus>()

    private val startAnimationRunnable = Runnable {
        statusBar.notificationPanelViewController.startFoldToAodAnimation {
            // End action
            isAnimationPlaying = false
            keyguardViewMediatorLazy.get().maybeHandlePendingLock()
        }
    }

    private var isAnimationPlaying = false

    override fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) {
@@ -79,6 +90,11 @@ constructor(
        }

    override fun onStartedWakingUp() {
        if (isAnimationPlaying) {
            handler.removeCallbacks(startAnimationRunnable)
            statusBar.notificationPanelViewController.cancelFoldToAodAnimation();
        }

        shouldPlayAnimation = false
        isAnimationPlaying = false
    }
@@ -115,11 +131,10 @@ constructor(

    fun onScreenTurnedOn() {
        if (shouldPlayAnimation) {
            statusBar.notificationPanelViewController.startFoldToAodAnimation {
                // End action
                isAnimationPlaying = false
                keyguardViewMediatorLazy.get().maybeHandlePendingLock()
            }
            handler.removeCallbacks(startAnimationRunnable)

            // Post starting the animation to the next frame to avoid junk due to inset changes
            handler.post(startAnimationRunnable)
            shouldPlayAnimation = false
        }
    }