• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.systemui.statusbar.phone
2 
3 import android.view.View
4 import com.android.systemui.Flags
5 import com.android.systemui.animation.ActivityTransitionAnimator
6 import com.android.systemui.animation.TransitionAnimator
7 import com.android.systemui.animation.TransitionAnimator.Companion.getProgress
8 import com.android.systemui.dagger.qualifiers.DisplayId
9 import com.android.systemui.shade.ShadeController
10 import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor
11 import com.android.systemui.statusbar.CommandQueue
12 import com.android.systemui.statusbar.NotificationShadeWindowController
13 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment
14 
15 /**
16  * A [ActivityTransitionAnimator.Controller] that takes care of collapsing the status bar at the
17  * right time.
18  */
19 class StatusBarTransitionAnimatorController(
20     private val delegate: ActivityTransitionAnimator.Controller,
21     private val shadeAnimationInteractor: ShadeAnimationInteractor,
22     private val shadeController: ShadeController,
23     private val notificationShadeWindowController: NotificationShadeWindowController,
24     private val commandQueue: CommandQueue,
25     @DisplayId private val displayId: Int,
26     private val isLaunchForActivity: Boolean = true,
27 ) : ActivityTransitionAnimator.Controller by delegate {
28     private var hideIconsDuringLaunchAnimation: Boolean = true
29 
30     // Always sync the opening window with the shade, given that we draw a hole punch in the shade
31     // of the same size and position as the opening app to make it visible.
32     override val openingWindowSyncView: View?
33         get() = notificationShadeWindowController.windowRootView
34 
onIntentStartednull35     override fun onIntentStarted(willAnimate: Boolean) {
36         delegate.onIntentStarted(willAnimate)
37         if (willAnimate) {
38             shadeAnimationInteractor.setIsLaunchingActivity(true)
39         } else {
40             shadeController.collapseOnMainThread()
41         }
42     }
43 
onTransitionAnimationStartnull44     override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) {
45         if (Flags.shadeLaunchAccessibility()) {
46             // We set this before calling the delegate to make sure that accessibility is disabled
47             // for the whole duration of the transition, so that we don't have stray TalkBack events
48             // once the animating view becomes invisible.
49             shadeAnimationInteractor.setIsLaunchingActivity(true)
50             delegate.onTransitionAnimationStart(isExpandingFullyAbove)
51         } else {
52             delegate.onTransitionAnimationStart(isExpandingFullyAbove)
53             shadeAnimationInteractor.setIsLaunchingActivity(true)
54         }
55         if (!isExpandingFullyAbove) {
56             shadeController.collapseWithDuration(
57                 ActivityTransitionAnimator.TIMINGS.totalDuration.toInt()
58             )
59         }
60     }
61 
onTransitionAnimationEndnull62     override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
63         delegate.onTransitionAnimationEnd(isExpandingFullyAbove)
64         shadeAnimationInteractor.setIsLaunchingActivity(false)
65         shadeController.onLaunchAnimationEnd(isExpandingFullyAbove)
66     }
67 
onTransitionAnimationProgressnull68     override fun onTransitionAnimationProgress(
69         state: TransitionAnimator.State,
70         progress: Float,
71         linearProgress: Float,
72     ) {
73         delegate.onTransitionAnimationProgress(state, progress, linearProgress)
74         val hideIcons =
75             getProgress(
76                 ActivityTransitionAnimator.TIMINGS,
77                 linearProgress,
78                 ANIMATION_DELAY_ICON_FADE_IN,
79                 100,
80             ) == 0.0f
81         if (hideIcons != hideIconsDuringLaunchAnimation) {
82             hideIconsDuringLaunchAnimation = hideIcons
83             if (!hideIcons) {
84                 commandQueue.recomputeDisableFlags(displayId, true /* animate */)
85             }
86         }
87     }
88 
onTransitionAnimationCancellednull89     override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) {
90         delegate.onTransitionAnimationCancelled()
91         shadeAnimationInteractor.setIsLaunchingActivity(false)
92         shadeController.onLaunchAnimationCancelled(isLaunchForActivity)
93     }
94 
95     companion object {
96         val ANIMATION_DELAY_ICON_FADE_IN =
97             (ActivityTransitionAnimator.TIMINGS.totalDuration -
98                 CollapsedStatusBarFragment.FADE_IN_DURATION -
99                 CollapsedStatusBarFragment.FADE_IN_DELAY -
100                 48)
101     }
102 }
103