diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml index 7ea91454d175a..9912e89c5fab5 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml @@ -38,8 +38,8 @@ android:layout_alignParentEnd="true" android:background="@drawable/ripple_drawable" > diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 841bef5d59978..3d9f7232c4b89 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -405,6 +405,9 @@ 22dp + + 24dp + 14sp 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 4715d0abd9962..82f5a9eb0c264 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -67,15 +67,18 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener @Override public void onClick(View v) { - if (opensUserSwitcherWhenClicked()) { + if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)) { if (mKeyguardMode) { if (mKeyguardUserSwitcher != null) { mKeyguardUserSwitcher.show(true /* animate */); } } else { if (mQsPanel != null) { - mQsPanel.showDetailAdapter(true, - mQsPanel.getHost().getUserSwitcherController().userDetailAdapter); + UserSwitcherController userSwitcherController = + mQsPanel.getHost().getUserSwitcherController(); + if (userSwitcherController != null) { + mQsPanel.showDetailAdapter(true, userSwitcherController.userDetailAdapter); + } } } } else { @@ -92,12 +95,14 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener if (isClickable()) { String text; - if (opensUserSwitcherWhenClicked()) { + if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)) { String currentUser = null; if (mQsPanel != null) { UserSwitcherController controller = mQsPanel.getHost() .getUserSwitcherController(); - currentUser = controller.getCurrentUserName(mContext); + if (controller != null) { + currentUser = controller.getCurrentUserName(mContext); + } } if (TextUtils.isEmpty(currentUser)) { text = mContext.getString(R.string.accessibility_multi_user_switch_switcher); @@ -121,8 +126,4 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener return false; } - private boolean opensUserSwitcherWhenClicked() { - UserManager um = UserManager.get(getContext()); - return UserManager.supportsMultipleUsers() && um.isUserSwitcherEnabled(); - } } 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 d94f122176d03..3f99630203323 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -74,6 +74,7 @@ import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; +import android.os.UserManager; import android.provider.Settings; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; @@ -853,8 +854,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mKeyguardBottomArea.setAccessibilityController(mAccessibilityController); mNextAlarmController = new NextAlarmController(mContext); mKeyguardMonitor = new KeyguardMonitor(); - mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor); - + if (UserSwitcherController.isUserSwitcherAvailable(UserManager.get(mContext))) { + mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor); + } mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); @@ -1510,7 +1512,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // If the user switcher is simple then disable QS during setup because // the user intends to use the lock screen user switcher, QS in not needed. mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned() - && (!mUserSwitcherController.isSimpleUserSwitcher() || mUserSetup)); + && (mUserSetup || mUserSwitcherController == null + || !mUserSwitcherController.isSimpleUserSwitcher())); mShadeUpdates.check(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java index c71bccdaa5357..7ee1fc57e7acb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -58,7 +58,9 @@ public class KeyguardUserSwitcher { public KeyguardUserSwitcher(Context context, ViewStub userSwitcher, KeyguardStatusBarView statusBarView, NotificationPanelView panelView, UserSwitcherController userSwitcherController) { - if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) { + boolean keyguardUserSwitcherEnabled = + context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON; + if (userSwitcherController != null && keyguardUserSwitcherEnabled) { mUserSwitcherContainer = (Container) userSwitcher.inflate(); mUserSwitcher = (ViewGroup) mUserSwitcherContainer.findViewById(R.id.keyguard_user_switcher_inner); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java index d50e39fcbb1c5..a8d4f131b54ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.UserInfo; +import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; @@ -131,8 +132,11 @@ public final class UserInfoController { final int userId = userInfo.id; final boolean isGuest = userInfo.isGuest(); final String userName = userInfo.name; - final int avatarSize - = mContext.getResources().getDimensionPixelSize(R.dimen.max_avatar_size); + + final Resources res = mContext.getResources(); + final int avatarSize = Math.max( + res.getDimensionPixelSize(R.dimen.multi_user_avatar_expanded_size), + res.getDimensionPixelSize(R.dimen.multi_user_avatar_keyguard_size)); final Context context = currentUserContext; mUserInfoTask = new AsyncTask>() { @@ -160,8 +164,9 @@ public final class UserInfoController { // Try and read the display name from the local profile final Cursor cursor = context.getContentResolver().query( ContactsContract.Profile.CONTENT_URI, new String[] { - ContactsContract.CommonDataKinds.Phone._ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME}, - null, null, null); + ContactsContract.CommonDataKinds.Phone._ID, + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + }, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { 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 5c7909a25147b..6ef4cffc961f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -589,4 +589,9 @@ public class UserSwitcherController { } } } + + public static boolean isUserSwitcherAvailable(UserManager um) { + return UserManager.supportsMultipleUsers() && um.isUserSwitcherEnabled(); + } + }