Merge "Improve user switching interstitial" into lmp-dev
diff --git a/core/res/res/layout/user_switching_dialog.xml b/core/res/res/layout/user_switching_dialog.xml
new file mode 100644
index 0000000..8617e5d
--- /dev/null
+++ b/core/res/res/layout/user_switching_dialog.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/message"
+ style="?attr/textAppearanceListItem"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:paddingStart="@dimen/alert_dialog_padding_material"
+ android:paddingEnd="@dimen/alert_dialog_padding_material"
+ android:paddingTop="24dp"
+ android:paddingBottom="24dp" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index d2cf689..d6224da 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4545,7 +4545,7 @@
<!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
<string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
<!-- Message shown when switching to a user [CHAR LIMIT=none] -->
- <string name="user_switching_message">Switching to user <xliff:g id="name" example="Bob">%1$s</xliff:g></string>
+ <string name="user_switching_message">Switching to <xliff:g id="name" example="Bob">%1$s</xliff:g>\u2026</string>
<!-- Default name of the owner user [CHAR LIMIT=20] -->
<string name="owner_name" msgid="3879126011135546571">Owner</string>
<!-- Error message title [CHAR LIMIT=35] -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3f373aa..11d712e 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1253,6 +1253,7 @@
<java-symbol type="layout" name="restrictions_pin_challenge" />
<java-symbol type="layout" name="restrictions_pin_setup" />
<java-symbol type="layout" name="immersive_mode_cling" />
+ <java-symbol type="layout" name="user_switching_dialog" />
<java-symbol type="anim" name="slide_in_child_bottom" />
<java-symbol type="anim" name="slide_in_right" />
diff --git a/services/core/java/com/android/server/am/UserSwitchingDialog.java b/services/core/java/com/android/server/am/UserSwitchingDialog.java
index 59d53ec..dfc8df5 100644
--- a/services/core/java/com/android/server/am/UserSwitchingDialog.java
+++ b/services/core/java/com/android/server/am/UserSwitchingDialog.java
@@ -16,6 +16,7 @@
package com.android.server.am;
+import android.app.AlertDialog;
import android.app.Service;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -25,7 +26,12 @@
import android.os.Handler;
import android.os.Message;
import android.util.Slog;
+import android.view.LayoutInflater;
+import android.view.View;
import android.view.WindowManager;
+import android.widget.TextView;
+
+import com.android.internal.R;
/**
* Dialog to show when a user switch it about to happen. The intent is to snapshot the screen
@@ -33,7 +39,7 @@
* in the background rather than just freeze the screen and not know if the user-switch affordance
* was being handled.
*/
-final class UserSwitchingDialog extends BaseErrorDialog {
+final class UserSwitchingDialog extends AlertDialog {
private static final String TAG = "ActivityManagerUserSwitchingDialog";
private static final int MSG_START_USER = 1;
@@ -47,9 +53,16 @@
mService = service;
mUserId = userId;
- Resources res = context.getResources();
+
+ // Set up the dialog contents
setCancelable(false);
- setMessage(res.getString(com.android.internal.R.string.user_switching_message, userName));
+ Resources res = getContext().getResources();
+ // Custom view due to alignment and font size requirements
+ View view = LayoutInflater.from(getContext()).inflate(R.layout.user_switching_dialog, null);
+ ((TextView) view.findViewById(R.id.message)).setText(
+ res.getString(com.android.internal.R.string.user_switching_message, userName));
+ setView(view);
+
if (aboveSystem) {
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
}