1 package com.android.systemui.statusbar 2 3 import android.content.Context 4 import android.util.IndentingPrintWriter 5 import android.util.MathUtils 6 import com.android.systemui.res.R 7 import com.android.systemui.dump.DumpManager 8 import com.android.systemui.statusbar.phone.ScrimController 9 import com.android.systemui.statusbar.policy.ConfigurationController 10 import com.android.systemui.statusbar.policy.SplitShadeStateController 11 import javax.inject.Inject 12 13 /** Controls the lockscreen to shade transition for scrims. */ 14 class LockscreenShadeScrimTransitionController 15 @Inject 16 constructor( 17 private val scrimController: ScrimController, 18 context: Context, 19 configurationController: ConfigurationController, 20 dumpManager: DumpManager, 21 splitShadeStateController: SplitShadeStateController 22 ) : AbstractLockscreenShadeTransitionController(context, configurationController, dumpManager, 23 splitShadeStateController) { 24 25 /** 26 * Distance that the full shade transition takes in order for scrim to fully transition to the 27 * shade (in alpha) 28 */ 29 private var scrimTransitionDistance = 0 30 31 /** Distance it takes in order for the notifications scrim fade in to start. */ 32 private var notificationsScrimTransitionDelay = 0 33 34 /** Distance it takes for the notifications scrim to fully fade if after it started. */ 35 private var notificationsScrimTransitionDistance = 0 36 37 /** The latest progress [0,1] the scrims transition. */ 38 var scrimProgress = 0f 39 40 /** The latest progress [0,1] specifically of the notifications scrim transition. */ 41 var notificationsScrimProgress = 0f 42 43 /** 44 * The last drag amount specifically for the notifications scrim. It is different to the normal 45 * [dragDownAmount] as the notifications scrim transition starts relative to the other scrims' 46 * progress. 47 */ 48 var notificationsScrimDragAmount = 0f 49 updateResourcesnull50 override fun updateResources() { 51 scrimTransitionDistance = 52 context.resources.getDimensionPixelSize( 53 R.dimen.lockscreen_shade_scrim_transition_distance) 54 notificationsScrimTransitionDelay = 55 context.resources.getDimensionPixelSize( 56 R.dimen.lockscreen_shade_notifications_scrim_transition_delay) 57 notificationsScrimTransitionDistance = 58 context.resources.getDimensionPixelSize( 59 R.dimen.lockscreen_shade_notifications_scrim_transition_distance) 60 } 61 onDragDownAmountChangednull62 override fun onDragDownAmountChanged(dragDownAmount: Float) { 63 scrimProgress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance) 64 notificationsScrimDragAmount = dragDownAmount - notificationsScrimTransitionDelay 65 notificationsScrimProgress = 66 MathUtils.saturate(notificationsScrimDragAmount / notificationsScrimTransitionDistance) 67 scrimController.setTransitionToFullShadeProgress(scrimProgress, notificationsScrimProgress) 68 } 69 dumpnull70 override fun dump(indentingPrintWriter: IndentingPrintWriter) { 71 indentingPrintWriter.let { 72 it.println("LockscreenShadeScrimTransitionController:") 73 it.increaseIndent() 74 it.println("Resources:") 75 it.increaseIndent() 76 it.println("scrimTransitionDistance: $scrimTransitionDistance") 77 it.println("notificationsScrimTransitionDelay: $notificationsScrimTransitionDelay") 78 it.println( 79 "notificationsScrimTransitionDistance: $notificationsScrimTransitionDistance") 80 it.decreaseIndent() 81 it.println("State") 82 it.increaseIndent() 83 it.println("dragDownAmount: $dragDownAmount") 84 it.println("scrimProgress: $scrimProgress") 85 it.println("notificationsScrimProgress: $notificationsScrimProgress") 86 it.println("notificationsScrimDragAmount: $notificationsScrimDragAmount") 87 } 88 } 89 } 90