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.view.View 21 import android.view.ViewGroup 22 import androidx.constraintlayout.widget.Barrier 23 import androidx.constraintlayout.widget.ConstraintLayout 24 import androidx.constraintlayout.widget.ConstraintSet 25 import com.android.systemui.keyguard.MigrateClocksToBlueprint 26 import com.android.systemui.keyguard.shared.model.KeyguardSection 27 import com.android.systemui.res.R 28 import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController 29 import javax.inject.Inject 30 31 class KeyguardSliceViewSection 32 @Inject 33 constructor( 34 val smartspaceController: LockscreenSmartspaceController, 35 ) : KeyguardSection() { addViewsnull36 override fun addViews(constraintLayout: ConstraintLayout) { 37 if (!MigrateClocksToBlueprint.isEnabled) return 38 if (smartspaceController.isEnabled()) return 39 40 constraintLayout.findViewById<View?>(R.id.keyguard_slice_view)?.let { 41 (it.parent as ViewGroup).removeView(it) 42 constraintLayout.addView(it) 43 } 44 } 45 bindDatanull46 override fun bindData(constraintLayout: ConstraintLayout) {} 47 applyConstraintsnull48 override fun applyConstraints(constraintSet: ConstraintSet) { 49 if (!MigrateClocksToBlueprint.isEnabled) return 50 if (smartspaceController.isEnabled()) return 51 52 constraintSet.apply { 53 connect( 54 R.id.keyguard_slice_view, 55 ConstraintSet.START, 56 ConstraintSet.PARENT_ID, 57 ConstraintSet.START 58 ) 59 connect( 60 R.id.keyguard_slice_view, 61 ConstraintSet.END, 62 ConstraintSet.PARENT_ID, 63 ConstraintSet.END 64 ) 65 constrainHeight(R.id.keyguard_slice_view, ConstraintSet.WRAP_CONTENT) 66 67 connect( 68 R.id.keyguard_slice_view, 69 ConstraintSet.TOP, 70 R.id.lockscreen_clock_view, 71 ConstraintSet.BOTTOM 72 ) 73 74 createBarrier( 75 R.id.smart_space_barrier_bottom, 76 Barrier.BOTTOM, 77 0, 78 *intArrayOf(R.id.keyguard_slice_view) 79 ) 80 } 81 } 82 removeViewsnull83 override fun removeViews(constraintLayout: ConstraintLayout) { 84 if (!MigrateClocksToBlueprint.isEnabled) return 85 if (smartspaceController.isEnabled()) return 86 87 constraintLayout.removeView(R.id.keyguard_slice_view) 88 } 89 } 90