From 57cf5702e0634b8cb25daa8f2f73292428ec4e08 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 3 Sep 2014 15:56:30 +0200 Subject: [PATCH 1/2] Add current user announce to MultiUserSwitch Bug: 17142162 Change-Id: I0322b1e653b8ceac473739dc6b52aa3700d81fb8 --- packages/SystemUI/res/values/strings.xml | 3 +++ .../statusbar/phone/MultiUserSwitch.java | 19 ++++++++++++++++--- .../policy/UserSwitcherController.java | 8 ++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index b488c562a42b8..eff519105b0ad 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -752,6 +752,9 @@ Switch user + + Switch user, current user %s + Show profile diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index d7144dadcd9e8..dc491183b4f01 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -30,6 +30,7 @@ import android.widget.FrameLayout; import com.android.systemui.R; import com.android.systemui.qs.QSPanel; import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; +import com.android.systemui.statusbar.policy.UserSwitcherController; /** * Container for image of the multi user switcher (tappable). @@ -90,9 +91,21 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener if (isClickable()) { final UserManager um = UserManager.get(getContext()); - String text = mContext.getString(um.isUserSwitcherEnabled() - ? R.string.accessibility_multi_user_switch_switcher - : R.string.accessibility_multi_user_switch_quick_contact); + String text; + if (um.isUserSwitcherEnabled()) { + UserSwitcherController controller = mQsPanel.getHost() + .getUserSwitcherController(); + String currentUser = controller.getCurrentUserName(mContext); + if (TextUtils.isEmpty(currentUser)) { + text = mContext.getString(R.string.accessibility_multi_user_switch_switcher); + } else { + text = mContext.getString( + R.string.accessibility_multi_user_switch_switcher_with_current, + currentUser); + } + } else { + text = mContext.getString(R.string.accessibility_multi_user_switch_quick_contact); + } if (!TextUtils.isEmpty(text)) { event.getText().add(text); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index adb71e714f388..27a89015b91ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -334,6 +334,14 @@ public class UserSwitcherController { } } + public String getCurrentUserName(Context context) { + if (mUsers.isEmpty()) return null; + UserRecord item = mUsers.get(0); + if (item == null || item.info == null) return null; + if (item.isGuest) return context.getString(R.string.guest_nickname); + return item.info.name; + } + public static abstract class BaseUserAdapter extends BaseAdapter { final UserSwitcherController mController; From aee70462c20e2c8c040c0032aa91c850812d8dcc Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 3 Sep 2014 16:27:39 +0200 Subject: [PATCH 2/2] Prevent full shade guesture from doing the wrong thing Also prevents us from getting into a state where it would do the wrong thing previously. Bug: 15934899 Change-Id: Ibb63814e80c50e4ccf65ef48d2b07cbe3a200e78 --- .../src/com/android/systemui/statusbar/BaseStatusBar.java | 2 ++ .../com/android/systemui/statusbar/phone/PhoneStatusBar.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 3f631f7ffbfa4..dcbca74d5d14c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -539,6 +539,8 @@ public abstract class BaseStatusBar extends SystemUI implements // disable lockscreen notifications until user acts on the banner. Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0); + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0); final String packageName = mContext.getPackageName(); PendingIntent cancelIntent = PendingIntent.getBroadcast(mContext, 0, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 8c7dad992417c..90b7c0e0c3c55 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3753,7 +3753,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, row = (ExpandableNotificationRow) expandView; row.setUserExpanded(true); } - if (isLockscreenPublicMode() && !userAllowsPrivateNotificationsInPublic(mCurrentUserId)) { + boolean fullShadeNeedsBouncer = !userAllowsPrivateNotificationsInPublic(mCurrentUserId) + || !mShowLockscreenNotifications; + if (isLockscreenPublicMode() && fullShadeNeedsBouncer) { mLeaveOpenOnKeyguardHide = true; showBouncer(); mDraggedDownRow = row;