1 /* 2 * Copyright (C) 2022 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 package com.android.systemui.statusbar.phone 18 19 import com.android.systemui.flags.FeatureFlagsClassic 20 import com.android.systemui.flags.Flags 21 import com.android.systemui.Flags.smartspaceRelocateToBottom 22 import android.view.View 23 import android.view.ViewGroup 24 import android.widget.LinearLayout 25 import com.android.systemui.res.R 26 import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController 27 import com.android.systemui.util.ViewController 28 import javax.inject.Inject 29 30 class KeyguardBottomAreaViewController 31 @Inject constructor( 32 view: KeyguardBottomAreaView, 33 private val smartspaceController: LockscreenSmartspaceController, 34 featureFlags: FeatureFlagsClassic 35 ) : ViewController<KeyguardBottomAreaView> (view) { 36 37 private var smartspaceView: View? = null 38 39 init { 40 view.setIsLockscreenLandscapeEnabled( 41 featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)) 42 } 43 onViewAttachednull44 override fun onViewAttached() { 45 if (!smartspaceRelocateToBottom() || !smartspaceController.isEnabled()) { 46 return 47 } 48 49 val ambientIndicationArea = mView.findViewById<View>(R.id.ambient_indication_container) 50 ambientIndicationArea?.visibility = View.GONE 51 52 addSmartspaceView() 53 } 54 onViewDetachednull55 override fun onViewDetached() { 56 } 57 getViewnull58 fun getView(): KeyguardBottomAreaView { 59 // TODO: remove this method. 60 return mView 61 } 62 addSmartspaceViewnull63 private fun addSmartspaceView() { 64 if (!smartspaceRelocateToBottom()) { 65 return 66 } 67 68 val smartspaceContainer = mView.findViewById<View>(R.id.smartspace_container) 69 smartspaceContainer!!.visibility = View.VISIBLE 70 71 smartspaceView = smartspaceController.buildAndConnectView(smartspaceContainer as ViewGroup) 72 val lp = LinearLayout.LayoutParams( 73 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) 74 (smartspaceContainer as ViewGroup).addView(smartspaceView, 0, lp) 75 val startPadding = context.resources.getDimensionPixelSize( 76 R.dimen.below_clock_padding_start) 77 val endPadding = context.resources.getDimensionPixelSize( 78 R.dimen.below_clock_padding_end) 79 smartspaceView?.setPaddingRelative(startPadding, 0, endPadding, 0) 80 // mKeyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView 81 } 82 } 83