diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher.xml b/packages/SystemUI/res/layout/keyguard_user_switcher.xml index 22834e1ce5606..983ba6d5e2404 100644 --- a/packages/SystemUI/res/layout/keyguard_user_switcher.xml +++ b/packages/SystemUI/res/layout/keyguard_user_switcher.xml @@ -19,14 +19,5 @@ android:visibility="gone" android:layout_height="match_parent" android:layout_width="match_parent"> - - + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml b/packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml new file mode 100644 index 0000000000000..4c1042e70c1ac --- /dev/null +++ b/packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml @@ -0,0 +1,27 @@ + + + + diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml index 5fde4f6969790..5cbe635f9c917 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -16,6 +16,7 @@ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 74bd096aaff39..e08b945493c98 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -85,6 +85,11 @@ public class KeyguardStatusBarView extends RelativeLayout com.android.internal.R.dimen.text_size_small_material)); mBatteryLevel.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.battery_level_text_size)); + + MarginLayoutParams lp = (MarginLayoutParams) mMultiUserAvatar.getLayoutParams(); + lp.width = lp.height = getResources().getDimensionPixelSize( + R.dimen.multi_user_avatar_keyguard_size); + mMultiUserAvatar.setLayoutParams(lp); } private void loadDimens() { 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 3c6e999329110..115b1a7fda708 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -966,7 +966,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, super.onDensityOrFontScaleChanged(); mScrimController.onDensityOrFontScaleChanged(); mStatusBarView.onDensityOrFontScaleChanged(); - mBrightnessMirrorController.onDensityOrFontScaleChanged(); + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.onDensityOrFontScaleChanged(); + } inflateSignalClusters(); mIconController.onDensityOrFontScaleChanged(); inflateDismissView(); @@ -975,6 +977,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, updateEmptyShadeView(); inflateOverflowContainer(); mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged(); + mUserInfoController.onDensityOrFontScaleChanged(); + if (mUserSwitcherController != null) { + mUserSwitcherController.onDensityOrFontScaleChanged(); + } + if (mKeyguardUserSwitcher != null) { + mKeyguardUserSwitcher.onDensityOrFontScaleChanged(); + } } private void inflateSignalClusters() { 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 c39d718a44f48..21f3f5e8da06c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -21,8 +21,6 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; import android.database.DataSetObserver; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -47,11 +45,12 @@ public class KeyguardUserSwitcher { private static final boolean ALWAYS_ON = false; private final Container mUserSwitcherContainer; - private final ViewGroup mUserSwitcher; private final KeyguardStatusBarView mStatusBarView; private final Adapter mAdapter; private final AppearAnimationUtils mAppearAnimationUtils; private final KeyguardUserSwitcherScrim mBackground; + + private ViewGroup mUserSwitcher; private ObjectAnimator mBgAnimator; private UserSwitcherController mUserSwitcherController; private boolean mAnimating; @@ -63,10 +62,8 @@ public class KeyguardUserSwitcher { 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); - mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher); - mUserSwitcher.setBackground(mBackground); + mBackground = new KeyguardUserSwitcherScrim(context); + reinflateViews(); mStatusBarView = statusBarView; mStatusBarView.setKeyguardUserSwitcher(this); panelView.setKeyguardUserSwitcher(this); @@ -78,7 +75,6 @@ public class KeyguardUserSwitcher { mUserSwitcherContainer.setKeyguardUserSwitcher(this); } else { mUserSwitcherContainer = null; - mUserSwitcher = null; mStatusBarView = null; mAdapter = null; mAppearAnimationUtils = null; @@ -86,6 +82,22 @@ public class KeyguardUserSwitcher { } } + private void reinflateViews() { + if (mUserSwitcher != null) { + mUserSwitcher.setBackground(null); + mUserSwitcher.removeOnLayoutChangeListener(mBackground); + } + mUserSwitcherContainer.removeAllViews(); + + LayoutInflater.from(mUserSwitcherContainer.getContext()) + .inflate(R.layout.keyguard_user_switcher_inner, mUserSwitcherContainer); + + mUserSwitcher = (ViewGroup) mUserSwitcherContainer.findViewById( + R.id.keyguard_user_switcher_inner); + mUserSwitcher.addOnLayoutChangeListener(mBackground); + mUserSwitcher.setBackground(mBackground); + } + public void setKeyguard(boolean keyguard, boolean animate) { if (mUserSwitcher != null) { if (keyguard && shouldExpandByDefault()) { @@ -228,6 +240,13 @@ public class KeyguardUserSwitcher { } }; + public void onDensityOrFontScaleChanged() { + if (mUserSwitcherContainer != null) { + reinflateViews(); + refresh(); + } + } + public static class Adapter extends UserSwitcherController.BaseUserAdapter implements View.OnClickListener { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java index 353e07d6c8c59..49f5bcdd5a44a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.policy; +import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; @@ -45,9 +46,8 @@ public class KeyguardUserSwitcherScrim extends Drawable private Paint mRadialGradientPaint = new Paint(); private int mLayoutWidth; - public KeyguardUserSwitcherScrim(View host) { - host.addOnLayoutChangeListener(this); - mDarkColor = host.getContext().getColor( + public KeyguardUserSwitcherScrim(Context context) { + mDarkColor = context.getColor( R.color.keyguard_user_switcher_background_gradient_color); } 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 bae5bdab07bcc..c5a4f5ece7460 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoController.java @@ -50,7 +50,6 @@ public final class UserInfoController { new ArrayList(); private AsyncTask> mUserInfoTask; - private boolean mUseDefaultAvatar; private String mUserName; private Drawable mUserDrawable; @@ -58,7 +57,6 @@ public final class UserInfoController { mContext = context; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); - filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); mContext.registerReceiver(mReceiver, filter); IntentFilter profileFilter = new IntentFilter(); @@ -83,10 +81,6 @@ public final class UserInfoController { final String action = intent.getAction(); if (Intent.ACTION_USER_SWITCHED.equals(action)) { reloadUserInfo(); - } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { - if (mUseDefaultAvatar) { - reloadUserInfo(); - } } } }; @@ -159,7 +153,6 @@ public final class UserInfoController { } else { avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId, /* light= */ true); - mUseDefaultAvatar = true; } // If it's a single-user device, get the profile name, since the nickname is not @@ -202,6 +195,10 @@ public final class UserInfoController { } } + public void onDensityOrFontScaleChanged() { + reloadUserInfo(); + } + public interface OnUserInfoChangedListener { public void onUserInfoChanged(String name, Drawable picture); } 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 6800772b754fd..415b7a18e553d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -23,7 +23,6 @@ import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -169,12 +168,13 @@ public class UserSwitcherController { return; } + boolean forceAllUsers = mForcePictureLoadForUserId.get(UserHandle.USER_ALL); SparseArray bitmaps = new SparseArray<>(mUsers.size()); final int N = mUsers.size(); for (int i = 0; i < N; i++) { UserRecord r = mUsers.get(i); - if (r == null || r.picture == null || - r.info == null || mForcePictureLoadForUserId.get(r.info.id)) { + if (r == null || r.picture == null || r.info == null || forceAllUsers + || mForcePictureLoadForUserId.get(r.info.id)) { continue; } bitmaps.put(r.info.id, r.picture); @@ -600,6 +600,10 @@ public class UserSwitcherController { return item.info.name; } + public void onDensityOrFontScaleChanged() { + refreshUsers(UserHandle.USER_ALL); + } + public static abstract class BaseUserAdapter extends BaseAdapter { final UserSwitcherController mController;