1 /* 2 * Copyright (C) 2020 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.settingslib.users; 18 19 import android.app.AlertDialog; 20 import android.content.Context; 21 import android.view.LayoutInflater; 22 import android.view.View; 23 import android.view.WindowManager; 24 import android.widget.TextView; 25 26 import com.android.settingslib.R; 27 28 /** 29 * Dialog to show when a user creation is in progress. 30 */ 31 public class UserCreatingDialog extends AlertDialog { 32 UserCreatingDialog(Context context)33 public UserCreatingDialog(Context context) { 34 // hardcoding theme to be consistent with UserSwitchingDialog's theme 35 // todo replace both to adapt to the device's theme 36 super(context, com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert); 37 38 inflateContent(); 39 getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); 40 41 WindowManager.LayoutParams attrs = getWindow().getAttributes(); 42 attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR 43 | WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; 44 getWindow().setAttributes(attrs); 45 } 46 inflateContent()47 private void inflateContent() { 48 // using the same design as UserSwitchingDialog 49 setCancelable(false); 50 View view = LayoutInflater.from(getContext()) 51 .inflate(R.layout.user_creation_progress_dialog, null); 52 String message = getContext().getString(R.string.creating_new_user_dialog_message); 53 view.setAccessibilityPaneTitle(message); 54 ((TextView) view.findViewById(R.id.message)).setText(message); 55 setView(view); 56 } 57 58 } 59