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

Commit 974a0fa1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "AnimateKeyguardInDelay should use the animator duration scale" into...

Merge "AnimateKeyguardInDelay should use the animator duration scale" into sc-qpr1-dev am: 872ae9e1 am: 95e215db

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

Change-Id: Ifb3965ef7f419b537358b7fa98564931c983fdf7
parents 36e20b28 95e215db
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -132,8 +132,7 @@ public class KeyguardVisibilityHelper {
                        .alpha(1f)
                        .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable)
                        .start();
            } else if (mUnlockedScreenOffAnimationController
                        .isScreenOffLightRevealAnimationPlaying()) {
            } else if (mUnlockedScreenOffAnimationController.shouldAnimateInKeyguard()) {
                mKeyguardViewVisibilityAnimating = true;

                // Ask the screen off animation controller to animate the keyguard visibility for us
+33 −6
Original line number Diff line number Diff line
@@ -5,20 +5,23 @@ import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Configuration
import android.database.ContentObserver
import android.os.Handler
import android.provider.Settings
import com.android.systemui.statusbar.StatusBarState
import android.view.View
import com.android.systemui.animation.Interpolators
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.StatusBarStateControllerImpl
import com.android.systemui.statusbar.notification.AnimatableProperty
import com.android.systemui.statusbar.notification.PropertyAnimator
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.settings.GlobalSettings
import javax.inject.Inject

/**
@@ -46,13 +49,16 @@ class UnlockedScreenOffAnimationController @Inject constructor(
    private val statusBarStateControllerImpl: StatusBarStateControllerImpl,
    private val keyguardViewMediatorLazy: dagger.Lazy<KeyguardViewMediator>,
    private val keyguardStateController: KeyguardStateController,
    private val dozeParameters: dagger.Lazy<DozeParameters>
    private val dozeParameters: dagger.Lazy<DozeParameters>,
    private val globalSettings: GlobalSettings
) : WakefulnessLifecycle.Observer {
    private val handler = Handler()

    private lateinit var statusBar: StatusBar
    private lateinit var lightRevealScrim: LightRevealScrim

    private var animatorDurationScale = 1f
    private var shouldAnimateInKeyguard = false
    private var lightRevealAnimationPlaying = false
    private var aodUiAnimationPlaying = false

@@ -79,6 +85,12 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        })
    }

    val animatorDurationScaleObserver = object : ContentObserver(null) {
        override fun onChange(selfChange: Boolean) {
            updateAnimatorDurationScale()
        }
    }

    fun initialize(
        statusBar: StatusBar,
        lightRevealScrim: LightRevealScrim
@@ -86,14 +98,25 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        this.lightRevealScrim = lightRevealScrim
        this.statusBar = statusBar

        updateAnimatorDurationScale()
        globalSettings.registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
                /* notify for descendants */ false,
                animatorDurationScaleObserver)
        wakefulnessLifecycle.addObserver(this)
    }

    fun updateAnimatorDurationScale() {
        animatorDurationScale =
                globalSettings.getFloat(Settings.Global.ANIMATOR_DURATION_SCALE, 1f)
    }

    /**
     * Animates in the provided keyguard view, ending in the same position that it will be in on
     * AOD.
     */
    fun animateInKeyguard(keyguardView: View, after: Runnable) {
        shouldAnimateInKeyguard = false
        keyguardView.alpha = 0f
        keyguardView.visibility = View.VISIBLE

@@ -138,6 +161,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        // Waking up, so reset this flag.
        decidedToAnimateGoingToSleep = null

        shouldAnimateInKeyguard = false
        lightRevealAnimator.cancel()
        handler.removeCallbacksAndMessages(null)
    }
@@ -146,7 +170,6 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        // Set this to false in onFinishedWakingUp rather than onStartedWakingUp so that other
        // observers (such as StatusBar) can ask us whether we were playing the screen off animation
        // and reset accordingly.
        lightRevealAnimationPlaying = false
        aodUiAnimationPlaying = false

        // If we can't control the screen off animation, we shouldn't mess with the StatusBar's
@@ -167,15 +190,15 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        if (dozeParameters.get().shouldControlUnlockedScreenOff()) {
            decidedToAnimateGoingToSleep = true

            shouldAnimateInKeyguard = true
            lightRevealAnimationPlaying = true
            lightRevealAnimator.start()

            handler.postDelayed({
                aodUiAnimationPlaying = true

                // Show AOD. That'll cause the KeyguardVisibilityHelper to call #animateInKeyguard.
                statusBar.notificationPanelViewController.showAodUi()
            }, ANIMATE_IN_KEYGUARD_DELAY)
            }, (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong())
        } else {
            decidedToAnimateGoingToSleep = false
        }
@@ -228,6 +251,10 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        return lightRevealAnimationPlaying || aodUiAnimationPlaying
    }

    fun shouldAnimateInKeyguard(): Boolean {
        return shouldAnimateInKeyguard
    }

    /**
     * Whether the light reveal animation is playing. The second part of the screen off animation,
     * where AOD animates in, might still be playing if this returns false.