1 package com.android.systemui.statusbar.phone 2 3 import android.view.View 4 import com.android.systemui.animation.ActivityTransitionAnimator 5 import com.android.systemui.animation.TransitionAnimator 6 import com.android.systemui.animation.TransitionAnimator.Companion.getProgress 7 import com.android.systemui.dagger.qualifiers.DisplayId 8 import com.android.systemui.shade.ShadeController 9 import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor 10 import com.android.systemui.statusbar.CommandQueue 11 import com.android.systemui.statusbar.NotificationShadeWindowController 12 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment 13 14 /** 15 * A [ActivityTransitionAnimator.Controller] that takes care of collapsing the status bar at the 16 * right time. 17 */ 18 class StatusBarTransitionAnimatorController( 19 private val delegate: ActivityTransitionAnimator.Controller, 20 private val shadeAnimationInteractor: ShadeAnimationInteractor, 21 private val shadeController: ShadeController, 22 private val notificationShadeWindowController: NotificationShadeWindowController, 23 private val commandQueue: CommandQueue, 24 @DisplayId private val displayId: Int, 25 private val isLaunchForActivity: Boolean = true 26 ) : ActivityTransitionAnimator.Controller by delegate { 27 private var hideIconsDuringLaunchAnimation: Boolean = true 28 29 // Always sync the opening window with the shade, given that we draw a hole punch in the shade 30 // of the same size and position as the opening app to make it visible. 31 override val openingWindowSyncView: View? 32 get() = notificationShadeWindowController.windowRootView 33 onIntentStartednull34 override fun onIntentStarted(willAnimate: Boolean) { 35 delegate.onIntentStarted(willAnimate) 36 if (willAnimate) { 37 shadeAnimationInteractor.setIsLaunchingActivity(true) 38 } else { 39 shadeController.collapseOnMainThread() 40 } 41 } 42 onTransitionAnimationStartnull43 override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { 44 delegate.onTransitionAnimationStart(isExpandingFullyAbove) 45 shadeAnimationInteractor.setIsLaunchingActivity(true) 46 if (!isExpandingFullyAbove) { 47 shadeController.collapseWithDuration( 48 ActivityTransitionAnimator.TIMINGS.totalDuration.toInt() 49 ) 50 } 51 } 52 onTransitionAnimationEndnull53 override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) { 54 delegate.onTransitionAnimationEnd(isExpandingFullyAbove) 55 shadeAnimationInteractor.setIsLaunchingActivity(false) 56 shadeController.onLaunchAnimationEnd(isExpandingFullyAbove) 57 } 58 onTransitionAnimationProgressnull59 override fun onTransitionAnimationProgress( 60 state: TransitionAnimator.State, 61 progress: Float, 62 linearProgress: Float 63 ) { 64 delegate.onTransitionAnimationProgress(state, progress, linearProgress) 65 val hideIcons = 66 getProgress( 67 ActivityTransitionAnimator.TIMINGS, 68 linearProgress, 69 ANIMATION_DELAY_ICON_FADE_IN, 70 100 71 ) == 0.0f 72 if (hideIcons != hideIconsDuringLaunchAnimation) { 73 hideIconsDuringLaunchAnimation = hideIcons 74 if (!hideIcons) { 75 commandQueue.recomputeDisableFlags(displayId, true /* animate */) 76 } 77 } 78 } 79 onTransitionAnimationCancellednull80 override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) { 81 delegate.onTransitionAnimationCancelled() 82 shadeAnimationInteractor.setIsLaunchingActivity(false) 83 shadeController.onLaunchAnimationCancelled(isLaunchForActivity) 84 } 85 86 companion object { 87 val ANIMATION_DELAY_ICON_FADE_IN = 88 (ActivityTransitionAnimator.TIMINGS.totalDuration - 89 CollapsedStatusBarFragment.FADE_IN_DURATION - 90 CollapsedStatusBarFragment.FADE_IN_DELAY - 91 48) 92 } 93 } 94