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.util.LargeScreenUtils 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 ) : Dumpable { 18 19 protected var useSplitShade = false 20 21 /** 22 * The amount of pixels that the user has dragged down during the shade transition on 23 * lockscreen. 24 */ 25 var dragDownAmount = 0f 26 set(value) { 27 if (value == field) { 28 return 29 } 30 field = value 31 onDragDownAmountChanged(value) 32 } 33 34 init { 35 updateResourcesInternal() 36 configurationController.addCallback( 37 object : ConfigurationController.ConfigurationListener { 38 override fun onConfigChanged(newConfig: Configuration?) { 39 updateResourcesInternal() 40 } 41 }) 42 @Suppress("LeakingThis") 43 dumpManager.registerDumpable(this) 44 } 45 46 private fun updateResourcesInternal() { 47 useSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources) 48 updateResources() 49 } 50 51 protected abstract fun updateResources() 52 53 protected abstract fun onDragDownAmountChanged(dragDownAmount: Float) 54 55 override fun dump(pw: PrintWriter, args: Array<out String>) { 56 dump(IndentingPrintWriter(pw, /* singleIndent= */ " ")) 57 } 58 59 abstract fun dump(pw: IndentingPrintWriter) 60 } 61