• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.content.Context
21 import androidx.constraintlayout.widget.ConstraintLayout
22 import androidx.constraintlayout.widget.ConstraintSet
23 import com.android.systemui.deviceentry.ui.binder.UdfpsAccessibilityOverlayBinder
24 import com.android.systemui.deviceentry.ui.view.UdfpsAccessibilityOverlay
25 import com.android.systemui.deviceentry.ui.viewmodel.DeviceEntryUdfpsAccessibilityOverlayViewModel
26 import com.android.systemui.keyguard.shared.model.KeyguardSection
27 import com.android.systemui.res.R
28 import com.android.systemui.shade.ShadeDisplayAware
29 import javax.inject.Inject
30 
31 /** Positions the UDFPS accessibility overlay on the bottom half of the keyguard. */
32 class DefaultUdfpsAccessibilityOverlaySection
33 @Inject
34 constructor(
35     @ShadeDisplayAware private val context: Context,
36     private val viewModel: DeviceEntryUdfpsAccessibilityOverlayViewModel,
37 ) : KeyguardSection() {
38     private val viewId = R.id.udfps_accessibility_overlay
39     private var cachedConstraintLayout: ConstraintLayout? = null
40 
addViewsnull41     override fun addViews(constraintLayout: ConstraintLayout) {
42         cachedConstraintLayout = constraintLayout
43         constraintLayout.addView(UdfpsAccessibilityOverlay(context).apply { id = viewId })
44     }
45 
bindDatanull46     override fun bindData(constraintLayout: ConstraintLayout) {
47         UdfpsAccessibilityOverlayBinder.bind(
48             constraintLayout.findViewById(viewId)!!,
49             viewModel,
50         )
51     }
52 
applyConstraintsnull53     override fun applyConstraints(constraintSet: ConstraintSet) {
54         constraintSet.apply {
55             connect(viewId, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START)
56             connect(viewId, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END)
57 
58             create(R.id.udfps_accessibility_overlay_top_guideline, ConstraintSet.HORIZONTAL)
59             setGuidelinePercent(R.id.udfps_accessibility_overlay_top_guideline, .5f)
60             connect(
61                 viewId,
62                 ConstraintSet.TOP,
63                 R.id.udfps_accessibility_overlay_top_guideline,
64                 ConstraintSet.BOTTOM,
65             )
66 
67             connect(
68                 viewId,
69                 ConstraintSet.BOTTOM,
70                 R.id.keyguard_indication_area,
71                 ConstraintSet.TOP,
72             )
73         }
74     }
75 
removeViewsnull76     override fun removeViews(constraintLayout: ConstraintLayout) {
77         constraintLayout.removeView(viewId)
78     }
79 }
80