summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/statusbar/AbstractLockscreenShadeTransitionController.kt
blob: 5b24af038b6b06b4c82f64d1549eb260c435c620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.android.systemui.statusbar

import android.content.Context
import android.content.res.Configuration
import android.util.IndentingPrintWriter
import com.android.systemui.Dumpable
import com.android.systemui.dump.DumpManager
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.LargeScreenUtils
import java.io.PrintWriter

/** An abstract implementation of a class that controls the lockscreen to shade transition. */
abstract class AbstractLockscreenShadeTransitionController(
    protected val context: Context,
    configurationController: ConfigurationController,
    dumpManager: DumpManager
) : Dumpable {

    protected var useSplitShade = false

    /**
     * The amount of pixels that the user has dragged down during the shade transition on
     * lockscreen.
     */
    var dragDownAmount = 0f
        set(value) {
            if (value == field) {
                return
            }
            field = value
            onDragDownAmountChanged(value)
        }

    init {
        updateResourcesInternal()
        configurationController.addCallback(
            object : ConfigurationController.ConfigurationListener {
                override fun onConfigChanged(newConfig: Configuration?) {
                    updateResourcesInternal()
                }
            })
        @Suppress("LeakingThis")
        dumpManager.registerDumpable(this)
    }

    private fun updateResourcesInternal() {
        useSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources)
        updateResources()
    }

    protected abstract fun updateResources()

    protected abstract fun onDragDownAmountChanged(dragDownAmount: Float)

    override fun dump(pw: PrintWriter, args: Array<out String>) {
        dump(IndentingPrintWriter(pw, /* singleIndent= */ "  "))
    }

    abstract fun dump(pw: IndentingPrintWriter)
}