am 8c8d8b10: Merge "Only keep user switcher bitmaps if needed" into lmp-mr1-dev
* commit '8c8d8b1012b409b653679a8f0236d57de346f4d7': Only keep user switcher bitmaps if needed
This commit is contained in:
@@ -860,6 +860,10 @@ 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
|
||||||
@@ -2126,6 +2130,9 @@ 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() {
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ 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 {
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ 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);
|
||||||
@@ -116,16 +119,18 @@ public class UserSwitcherController {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void refreshUsers(int forcePictureLoadForId) {
|
private void refreshUsers(int forcePictureLoadForId) {
|
||||||
|
SparseArray<Bitmap> bitmaps = null;
|
||||||
SparseArray<Bitmap> bitmaps = new SparseArray<>(mUsers.size());
|
if (allowCachingOfBitmaps()) {
|
||||||
final int N = mUsers.size();
|
bitmaps = new SparseArray<>(mUsers.size());
|
||||||
for (int i = 0; i < N; i++) {
|
final int N = mUsers.size();
|
||||||
UserRecord r = mUsers.get(i);
|
for (int i = 0; i < N; i++) {
|
||||||
if (r == null || r.info == null
|
UserRecord r = mUsers.get(i);
|
||||||
|| r.info.id == forcePictureLoadForId || r.picture == null) {
|
if (r == null || r.info == null
|
||||||
continue;
|
|| 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;
|
final boolean addUsersWhenLocked = mAddUsersWhenLocked;
|
||||||
@@ -151,13 +156,15 @@ 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.get(info.id);
|
Bitmap picture = bitmaps != null ? bitmaps.get(info.id) : null;
|
||||||
if (picture == null) {
|
if (picture == null && allowCachingOfBitmaps()) {
|
||||||
picture = mUserManager.getUserIcon(info.id);
|
Bitmap loadedPicture = mUserManager.getUserIcon(info.id);
|
||||||
}
|
|
||||||
if (picture != null) {
|
if (loadedPicture != null) {
|
||||||
picture = BitmapHelper.createCircularClip(
|
picture = BitmapHelper.createCircularClip(
|
||||||
picture, avatarSize, avatarSize);
|
loadedPicture, avatarSize, avatarSize);
|
||||||
|
loadedPicture.recycle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int index = isCurrent ? 0 : records.size();
|
int index = isCurrent ? 0 : records.size();
|
||||||
records.add(index, new UserRecord(info, picture, false /* isGuest */,
|
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
|
private final class AddUserDialog extends SystemUIDialog implements
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user