am 8a924242: Merge "Revert "Only keep user switcher bitmaps if needed"" into lmp-mr1-dev

* commit '8a9242428b9d631ba841c166d062f158fd64f0f6':
  Revert "Only keep user switcher bitmaps if needed"
This commit is contained in:
Adrian Roos
2014-11-24 16:08:41 +00:00
committed by Android Git Automerger
3 changed files with 14 additions and 57 deletions

View File

@@ -872,10 +872,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController);
if (mUserSwitcherController != null) {
mUserSwitcherController.setKeyguardUserSwitcherAvailable(
mKeyguardUserSwitcher.isEnabled());
}
// Set up the quick settings tile panel // Set up the quick settings tile panel
@@ -2142,9 +2138,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
public void setQsExpanded(boolean expanded) { public void setQsExpanded(boolean expanded) {
mStatusBarWindowManager.setQsExpanded(expanded); mStatusBarWindowManager.setQsExpanded(expanded);
if (mUserSwitcherController != null) {
mUserSwitcherController.setQsExpanded(expanded);
}
} }
public boolean isGoingToNotificationShade() { public boolean isGoingToNotificationShade() {

View File

@@ -227,10 +227,6 @@ public class KeyguardUserSwitcher {
} }
}; };
public boolean isEnabled() {
return mUserSwitcherContainer != null;
}
public static class Adapter extends UserSwitcherController.BaseUserAdapter implements public static class Adapter extends UserSwitcherController.BaseUserAdapter implements
View.OnClickListener { View.OnClickListener {

View File

@@ -78,9 +78,6 @@ public class UserSwitcherController {
private boolean mSimpleUserSwitcher; private boolean mSimpleUserSwitcher;
private boolean mAddUsersWhenLocked; private boolean mAddUsersWhenLocked;
private boolean mKeyguardUserSwitcherAvailable;
private boolean mQsExpanded;
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor) { public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor) {
mContext = context; mContext = context;
mGuestResumeSessionReceiver.register(context); mGuestResumeSessionReceiver.register(context);
@@ -119,18 +116,16 @@ public class UserSwitcherController {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void refreshUsers(int forcePictureLoadForId) { private void refreshUsers(int forcePictureLoadForId) {
SparseArray<Bitmap> bitmaps = null;
if (allowCachingOfBitmaps()) { SparseArray<Bitmap> bitmaps = new SparseArray<>(mUsers.size());
bitmaps = new SparseArray<>(mUsers.size()); final int N = mUsers.size();
final int N = mUsers.size(); for (int i = 0; i < N; i++) {
for (int i = 0; i < N; i++) { UserRecord r = mUsers.get(i);
UserRecord r = mUsers.get(i); if (r == null || r.info == null
if (r == null || r.info == null || r.info.id == forcePictureLoadForId || r.picture == null) {
|| r.info.id == forcePictureLoadForId || r.picture == null) { continue;
continue;
}
bitmaps.put(r.info.id, r.picture);
} }
bitmaps.put(r.info.id, r.picture);
} }
final boolean addUsersWhenLocked = mAddUsersWhenLocked; final boolean addUsersWhenLocked = mAddUsersWhenLocked;
@@ -156,14 +151,13 @@ public class UserSwitcherController {
true /* isGuest */, isCurrent, false /* isAddUser */, true /* isGuest */, isCurrent, false /* isAddUser */,
false /* isRestricted */); false /* isRestricted */);
} else if (info.supportsSwitchTo()) { } else if (info.supportsSwitchTo()) {
Bitmap picture = bitmaps != null ? bitmaps.get(info.id) : null; Bitmap picture = bitmaps.get(info.id);
if (picture == null && allowCachingOfBitmaps()) { if (picture == null) {
Bitmap loadedPicture = mUserManager.getUserIcon(info.id); picture = mUserManager.getUserIcon(info.id);
if (loadedPicture != null) { if (picture != null) {
picture = BitmapHelper.createCircularClip( picture = BitmapHelper.createCircularClip(
loadedPicture, avatarSize, avatarSize); picture, avatarSize, avatarSize);
loadedPicture.recycle();
} }
} }
int index = isCurrent ? 0 : records.size(); int index = isCurrent ? 0 : records.size();
@@ -559,32 +553,6 @@ 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 private final class AddUserDialog extends SystemUIDialog implements
DialogInterface.OnClickListener { DialogInterface.OnClickListener {