1 package com.android.systemui.statusbar
2 
3 import android.content.Context
4 import android.content.res.Configuration
5 import android.util.IndentingPrintWriter
6 import com.android.systemui.Dumpable
7 import com.android.systemui.dump.DumpManager
8 import com.android.systemui.statusbar.policy.ConfigurationController
9 import com.android.systemui.statusbar.policy.SplitShadeStateController
10 import java.io.PrintWriter
11 
12 /** An abstract implementation of a class that controls the lockscreen to shade transition. */
13 abstract class AbstractLockscreenShadeTransitionController(
14     protected val context: Context,
15     configurationController: ConfigurationController,
16     dumpManager: DumpManager,
17     private val splitShadeStateController: SplitShadeStateController
18 ) : Dumpable {
19 
20     protected var useSplitShade = false
21 
22     /**
23      * The amount of pixels that the user has dragged down during the shade transition on
24      * lockscreen.
25      */
26     var dragDownAmount = 0f
27         set(value) {
28             if (value == field) {
29                 return
30             }
31             field = value
32             onDragDownAmountChanged(value)
33         }
34 
35     init {
36         updateResourcesInternal()
37         configurationController.addCallback(
38             object : ConfigurationController.ConfigurationListener {
onConfigChangednull39                 override fun onConfigChanged(newConfig: Configuration?) {
40                     updateResourcesInternal()
41                 }
42             })
43         @Suppress("LeakingThis")
44         dumpManager.registerDumpable(this)
45     }
46 
updateResourcesInternalnull47     private fun updateResourcesInternal() {
48         useSplitShade = splitShadeStateController
49                 .shouldUseSplitNotificationShade(context.resources)
50         updateResources()
51     }
52 
updateResourcesnull53     protected abstract fun updateResources()
54 
55     protected abstract fun onDragDownAmountChanged(dragDownAmount: Float)
56 
57     override fun dump(pw: PrintWriter, args: Array<out String>) {
58         dump(IndentingPrintWriter(pw, /* singleIndent= */ "  "))
59     }
60 
dumpnull61     abstract fun dump(pw: IndentingPrintWriter)
62 }
63