Fix density change bugs in SystemUI
- Reinflate KeyguardUserSwitcher on density changes.
- Update size of UserAvatar on Keyguard.
- Fix brightness slider width in quick settings.
- Refetch and rescale user icons on density changes.
Change-Id: I961c59b8b224d6ac22cbbb8e115b8a12547a04b9
Fixes: 28535987
Fixes: 28454340
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 74bd096..e08b945 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 @@
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 20809ea..dd0d31a 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 @@
super.onDensityOrFontScaleChanged();
mScrimController.onDensityOrFontScaleChanged();
mStatusBarView.onDensityOrFontScaleChanged();
- mBrightnessMirrorController.onDensityOrFontScaleChanged();
+ if (mBrightnessMirrorController != null) {
+ mBrightnessMirrorController.onDensityOrFontScaleChanged();
+ }
inflateSignalClusters();
mIconController.onDensityOrFontScaleChanged();
inflateDismissView();
@@ -975,6 +977,13 @@
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 c39d718..21f3f5e 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.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 @@
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 @@
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 @@
mUserSwitcherContainer.setKeyguardUserSwitcher(this);
} else {
mUserSwitcherContainer = null;
- mUserSwitcher = null;
mStatusBarView = null;
mAdapter = null;
mAppearAnimationUtils = null;
@@ -86,6 +82,22 @@
}
}
+ 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 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 353e07d..49f5bcd 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 @@
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 bae5bda..c5a4f5e 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 @@
new ArrayList<OnUserInfoChangedListener>();
private AsyncTask<Void, Void, Pair<String, Drawable>> mUserInfoTask;
- private boolean mUseDefaultAvatar;
private String mUserName;
private Drawable mUserDrawable;
@@ -58,7 +57,6 @@
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 @@
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 @@
} 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 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 6800772..415b7a1 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.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 @@
return;
}
+ boolean forceAllUsers = mForcePictureLoadForUserId.get(UserHandle.USER_ALL);
SparseArray<Bitmap> 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 @@
return item.info.name;
}
+ public void onDensityOrFontScaleChanged() {
+ refreshUsers(UserHandle.USER_ALL);
+ }
+
public static abstract class BaseUserAdapter extends BaseAdapter {
final UserSwitcherController mController;