1 package com.android.systemui.statusbar.phone 2 3 import android.view.View 4 import com.android.systemui.animation.ActivityLaunchAnimator 5 import com.android.systemui.animation.LaunchAnimator 6 import com.android.systemui.shade.ShadeController 7 import com.android.systemui.shade.ShadeViewController 8 import com.android.systemui.statusbar.NotificationShadeWindowController 9 10 /** 11 * A [ActivityLaunchAnimator.Controller] that takes care of collapsing the status bar at the right 12 * time. 13 */ 14 class StatusBarLaunchAnimatorController( 15 private val delegate: ActivityLaunchAnimator.Controller, 16 private val shadeViewController: ShadeViewController, 17 private val shadeController: ShadeController, 18 private val notificationShadeWindowController: NotificationShadeWindowController, 19 private val isLaunchForActivity: Boolean = true 20 ) : ActivityLaunchAnimator.Controller by delegate { 21 // Always sync the opening window with the shade, given that we draw a hole punch in the shade 22 // of the same size and position as the opening app to make it visible. 23 override val openingWindowSyncView: View? 24 get() = notificationShadeWindowController.windowRootView 25 26 override fun onIntentStarted(willAnimate: Boolean) { 27 delegate.onIntentStarted(willAnimate) 28 if (willAnimate) { 29 shadeViewController.setIsLaunchAnimationRunning(true) 30 } else { 31 shadeController.collapseOnMainThread() 32 } 33 } 34 35 override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { 36 delegate.onLaunchAnimationStart(isExpandingFullyAbove) 37 shadeViewController.setIsLaunchAnimationRunning(true) 38 if (!isExpandingFullyAbove) { 39 shadeViewController.collapseWithDuration( 40 ActivityLaunchAnimator.TIMINGS.totalDuration.toInt()) 41 } 42 } 43 44 override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) { 45 delegate.onLaunchAnimationEnd(isExpandingFullyAbove) 46 shadeViewController.setIsLaunchAnimationRunning(false) 47 shadeController.onLaunchAnimationEnd(isExpandingFullyAbove) 48 } 49 50 override fun onLaunchAnimationProgress( 51 state: LaunchAnimator.State, 52 progress: Float, 53 linearProgress: Float 54 ) { 55 delegate.onLaunchAnimationProgress(state, progress, linearProgress) 56 shadeViewController.applyLaunchAnimationProgress(linearProgress) 57 } 58 59 override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { 60 delegate.onLaunchAnimationCancelled() 61 shadeViewController.setIsLaunchAnimationRunning(false) 62 shadeController.onLaunchAnimationCancelled(isLaunchForActivity) 63 } 64 }