• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 package com.android.systemui.keyguard.ui.view.layout.sections
19 
20 import android.os.Handler
21 import android.view.LayoutInflater
22 import androidx.constraintlayout.widget.Barrier
23 import androidx.constraintlayout.widget.ConstraintLayout
24 import androidx.constraintlayout.widget.ConstraintSet
25 import com.android.keyguard.KeyguardSliceView
26 import com.android.keyguard.KeyguardSliceViewController
27 import com.android.systemui.customization.R as customR
28 import com.android.systemui.dagger.qualifiers.Background
29 import com.android.systemui.dagger.qualifiers.Main
30 import com.android.systemui.dump.DumpManager
31 import com.android.systemui.keyguard.shared.model.KeyguardSection
32 import com.android.systemui.plugins.ActivityStarter
33 import com.android.systemui.res.R
34 import com.android.systemui.settings.DisplayTracker
35 import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
36 import com.android.systemui.statusbar.policy.ConfigurationController
37 import javax.inject.Inject
38 
39 class KeyguardSliceViewSection
40 @Inject
41 constructor(
42     val smartspaceController: LockscreenSmartspaceController,
43     val layoutInflater: LayoutInflater,
44     @Main val handler: Handler,
45     @Background val bgHandler: Handler,
46     val activityStarter: ActivityStarter,
47     val configurationController: ConfigurationController,
48     val dumpManager: DumpManager,
49     val displayTracker: DisplayTracker,
50 ) : KeyguardSection() {
51     private lateinit var sliceView: KeyguardSliceView
52 
addViewsnull53     override fun addViews(constraintLayout: ConstraintLayout) {
54         if (smartspaceController.isEnabled) return
55 
56         sliceView =
57             layoutInflater.inflate(R.layout.keyguard_slice_view, null, false) as KeyguardSliceView
58         constraintLayout.addView(sliceView)
59     }
60 
bindDatanull61     override fun bindData(constraintLayout: ConstraintLayout) {
62         if (smartspaceController.isEnabled) return
63 
64         val controller =
65             KeyguardSliceViewController(
66                 handler,
67                 bgHandler,
68                 sliceView,
69                 activityStarter,
70                 configurationController,
71                 dumpManager,
72                 displayTracker,
73             )
74         controller.init()
75     }
76 
applyConstraintsnull77     override fun applyConstraints(constraintSet: ConstraintSet) {
78         if (smartspaceController.isEnabled) return
79 
80         constraintSet.apply {
81             connect(
82                 R.id.keyguard_slice_view,
83                 ConstraintSet.START,
84                 ConstraintSet.PARENT_ID,
85                 ConstraintSet.START,
86             )
87             connect(
88                 R.id.keyguard_slice_view,
89                 ConstraintSet.END,
90                 ConstraintSet.PARENT_ID,
91                 ConstraintSet.END,
92             )
93             constrainHeight(R.id.keyguard_slice_view, ConstraintSet.WRAP_CONTENT)
94 
95             connect(
96                 R.id.keyguard_slice_view,
97                 ConstraintSet.TOP,
98                 customR.id.lockscreen_clock_view,
99                 ConstraintSet.BOTTOM,
100             )
101 
102             createBarrier(
103                 R.id.smart_space_barrier_bottom,
104                 Barrier.BOTTOM,
105                 0,
106                 *intArrayOf(R.id.keyguard_slice_view),
107             )
108         }
109     }
110 
removeViewsnull111     override fun removeViews(constraintLayout: ConstraintLayout) {
112         if (smartspaceController.isEnabled) return
113 
114         constraintLayout.removeView(R.id.keyguard_slice_view)
115     }
116 }
117