1 /* <lambda>null2 * 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 package com.android.systemui.user 18 19 import android.content.Context 20 import android.os.Bundle 21 import android.view.LayoutInflater 22 import android.view.ViewGroup.LayoutParams.MATCH_PARENT 23 import android.view.WindowInsets 24 import android.view.WindowInsetsController 25 import com.android.systemui.res.R 26 import com.android.systemui.classifier.FalsingCollector 27 import com.android.systemui.statusbar.phone.SystemUIDialog 28 import com.android.systemui.user.ui.binder.UserSwitcherViewBinder 29 import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel 30 31 class UserSwitchFullscreenDialog( 32 context: Context, 33 private val falsingCollector: FalsingCollector, 34 private val userSwitcherViewModel: UserSwitcherViewModel, 35 ) : SystemUIDialog(context, R.style.Theme_UserSwitcherFullscreenDialog) { 36 37 override fun onCreate(savedInstanceState: Bundle?) { 38 super.onCreate(savedInstanceState) 39 setShowForAllUsers(true) 40 setCanceledOnTouchOutside(true) 41 42 window?.decorView?.windowInsetsController?.let { controller -> 43 controller.systemBarsBehavior = 44 WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE 45 controller.hide(WindowInsets.Type.systemBars()) 46 } 47 48 val view = 49 LayoutInflater.from(this.context).inflate(R.layout.user_switcher_fullscreen, null) 50 setContentView(view) 51 52 UserSwitcherViewBinder.bind( 53 view = requireViewById(R.id.user_switcher_root), 54 viewModel = userSwitcherViewModel, 55 layoutInflater = layoutInflater, 56 falsingCollector = falsingCollector, 57 onFinish = this::dismiss, 58 ) 59 } 60 61 override fun getWidth(): Int { 62 val displayMetrics = context.resources.displayMetrics.apply { 63 checkNotNull(context.display).getRealMetrics(this) 64 } 65 return displayMetrics.widthPixels 66 } 67 68 override fun getHeight() = MATCH_PARENT 69 70 }