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.ConstraintSet 22 import androidx.constraintlayout.widget.ConstraintSet.BOTTOM 23 import androidx.constraintlayout.widget.ConstraintSet.END 24 import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID 25 import androidx.constraintlayout.widget.ConstraintSet.START 26 import androidx.constraintlayout.widget.ConstraintSet.TOP 27 import com.android.systemui.Flags.centralizedStatusBarHeightFix 28 import com.android.systemui.keyguard.MigrateClocksToBlueprint 29 import com.android.systemui.res.R 30 import com.android.systemui.shade.LargeScreenHeaderHelper 31 import com.android.systemui.shade.NotificationPanelView 32 import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer 33 import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder 34 import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel 35 import dagger.Lazy 36 import javax.inject.Inject 37 38 /** Single column format for notifications (default for phones) */ 39 class DefaultNotificationStackScrollLayoutSection 40 @Inject 41 constructor( 42 context: Context, 43 notificationPanelView: NotificationPanelView, 44 sharedNotificationContainer: SharedNotificationContainer, 45 sharedNotificationContainerViewModel: SharedNotificationContainerViewModel, 46 sharedNotificationContainerBinder: SharedNotificationContainerBinder, 47 private val largeScreenHeaderHelperLazy: Lazy<LargeScreenHeaderHelper>, 48 ) : 49 NotificationStackScrollLayoutSection( 50 context, 51 notificationPanelView, 52 sharedNotificationContainer, 53 sharedNotificationContainerViewModel, 54 sharedNotificationContainerBinder, 55 ) { applyConstraintsnull56 override fun applyConstraints(constraintSet: ConstraintSet) { 57 if (!MigrateClocksToBlueprint.isEnabled) { 58 return 59 } 60 constraintSet.apply { 61 val bottomMargin = 62 context.resources.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin) 63 if (MigrateClocksToBlueprint.isEnabled) { 64 val useLargeScreenHeader = 65 context.resources.getBoolean(R.bool.config_use_large_screen_shade_header) 66 val marginTopLargeScreen = 67 if (centralizedStatusBarHeightFix()) { 68 largeScreenHeaderHelperLazy.get().getLargeScreenHeaderHeight() 69 } else { 70 context.resources.getDimensionPixelSize( 71 R.dimen.large_screen_shade_header_height 72 ) 73 } 74 connect( 75 R.id.nssl_placeholder, 76 TOP, 77 R.id.smart_space_barrier_bottom, 78 BOTTOM, 79 bottomMargin + 80 if (useLargeScreenHeader) { 81 marginTopLargeScreen 82 } else { 83 0 84 } 85 ) 86 } else { 87 connect(R.id.nssl_placeholder, TOP, R.id.keyguard_status_view, BOTTOM, bottomMargin) 88 } 89 connect(R.id.nssl_placeholder, START, PARENT_ID, START) 90 connect(R.id.nssl_placeholder, END, PARENT_ID, END) 91 92 addNotificationPlaceholderBarrier(this) 93 } 94 } 95 } 96