summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-11-17 17:33:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-17 17:33:50 +0000
commit8c8d8b1012b409b653679a8f0236d57de346f4d7 (patch)
tree86a8600dc1b8ab6510f52b352b07b3868d7110c3 /packages
parent9c76a7b3e85ce7056071ac8627c8d675cc5c1599 (diff)
parentcba0faadbe1c8cf7c6b264b761d747f7381a2f93 (diff)
downloadframeworks_base-8c8d8b1012b409b653679a8f0236d57de346f4d7.zip
frameworks_base-8c8d8b1012b409b653679a8f0236d57de346f4d7.tar.gz
frameworks_base-8c8d8b1012b409b653679a8f0236d57de346f4d7.tar.bz2
Merge "Only keep user switcher bitmaps if needed" into lmp-mr1-dev
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java65
3 files changed, 60 insertions, 16 deletions
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 3f99630..f5c994a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -860,6 +860,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController);
+ if (mUserSwitcherController != null) {
+ mUserSwitcherController.setKeyguardUserSwitcherAvailable(
+ mKeyguardUserSwitcher.isEnabled());
+ }
// Set up the quick settings tile panel
@@ -2126,6 +2130,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
public void setQsExpanded(boolean expanded) {
mStatusBarWindowManager.setQsExpanded(expanded);
+ if (mUserSwitcherController != null) {
+ mUserSwitcherController.setQsExpanded(expanded);
+ }
}
public boolean isGoingToNotificationShade() {
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 7ee1fc5..0392e0d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -227,6 +227,10 @@ public class KeyguardUserSwitcher {
}
};
+ public boolean isEnabled() {
+ return mUserSwitcherContainer != null;
+ }
+
public static class Adapter extends UserSwitcherController.BaseUserAdapter implements
View.OnClickListener {
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 6ef4cff..5f6c399 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -78,6 +78,9 @@ public class UserSwitcherController {
private boolean mSimpleUserSwitcher;
private boolean mAddUsersWhenLocked;
+ private boolean mKeyguardUserSwitcherAvailable;
+ private boolean mQsExpanded;
+
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor) {
mContext = context;
mGuestResumeSessionReceiver.register(context);
@@ -116,16 +119,18 @@ public class UserSwitcherController {
*/
@SuppressWarnings("unchecked")
private void refreshUsers(int forcePictureLoadForId) {
-
- 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.info == null
- || r.info.id == forcePictureLoadForId || r.picture == null) {
- continue;
+ SparseArray<Bitmap> bitmaps = null;
+ if (allowCachingOfBitmaps()) {
+ 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.info == null
+ || r.info.id == forcePictureLoadForId || r.picture == null) {
+ continue;
+ }
+ bitmaps.put(r.info.id, r.picture);
}
- bitmaps.put(r.info.id, r.picture);
}
final boolean addUsersWhenLocked = mAddUsersWhenLocked;
@@ -151,13 +156,15 @@ public class UserSwitcherController {
true /* isGuest */, isCurrent, false /* isAddUser */,
false /* isRestricted */);
} else if (info.supportsSwitchTo()) {
- Bitmap picture = bitmaps.get(info.id);
- if (picture == null) {
- picture = mUserManager.getUserIcon(info.id);
- }
- if (picture != null) {
- picture = BitmapHelper.createCircularClip(
- picture, avatarSize, avatarSize);
+ Bitmap picture = bitmaps != null ? bitmaps.get(info.id) : null;
+ if (picture == null && allowCachingOfBitmaps()) {
+ Bitmap loadedPicture = mUserManager.getUserIcon(info.id);
+
+ if (loadedPicture != null) {
+ picture = BitmapHelper.createCircularClip(
+ loadedPicture, avatarSize, avatarSize);
+ loadedPicture.recycle();
+ }
}
int index = isCurrent ? 0 : records.size();
records.add(index, new UserRecord(info, picture, false /* isGuest */,
@@ -552,6 +559,32 @@ public class UserSwitcherController {
}
}
+ /**
+ * Notify if the keyguard user switcher is available.
+ */
+ public void setKeyguardUserSwitcherAvailable(boolean available) {
+ boolean oldShouldCacheBitmaps = allowCachingOfBitmaps();
+ mKeyguardUserSwitcherAvailable = available;
+ if (allowCachingOfBitmaps() != oldShouldCacheBitmaps) {
+ refreshUsers(UserHandle.USER_NULL);
+ }
+ }
+
+ /**
+ * Notify if the quick settings are expanded.
+ */
+ public void setQsExpanded(boolean qsExpanded) {
+ boolean oldShouldCacheBitmaps = allowCachingOfBitmaps();
+ mQsExpanded = qsExpanded;
+ if (allowCachingOfBitmaps() != oldShouldCacheBitmaps) {
+ refreshUsers(UserHandle.USER_NULL);
+ }
+ }
+
+ private boolean allowCachingOfBitmaps() {
+ return mQsExpanded || mKeyguardUserSwitcherAvailable;
+ }
+
private final class AddUserDialog extends SystemUIDialog implements
DialogInterface.OnClickListener {