Refresh user list a little more eagerly
Unfortunately, we don't get a signal when user restrictions such as for adding new users change. That means the user switcher UI could get out of sync and showed the add user option when in fact it couldn't add one. Also cleans up an unused method. Bug: 18292723 Change-Id: I56f6f848d967d9d1c11bd6262eacbdb11f90cfe2
This commit is contained in:
@@ -47,6 +47,10 @@ public class UserDetailView extends PseudoGridView {
|
||||
ViewGroupAdapterBridge.link(this, mAdapter);
|
||||
}
|
||||
|
||||
public void refreshAdapter() {
|
||||
mAdapter.refresh();
|
||||
}
|
||||
|
||||
public static class Adapter extends UserSwitcherController.BaseUserAdapter
|
||||
implements OnClickListener {
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ public class KeyguardUserSwitcher {
|
||||
public void show(boolean animate) {
|
||||
if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) {
|
||||
cancelAnimations();
|
||||
mAdapter.refresh();
|
||||
mUserSwitcherContainer.setVisibility(View.VISIBLE);
|
||||
mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
|
||||
if (animate) {
|
||||
|
||||
@@ -417,18 +417,6 @@ public class UserSwitcherController {
|
||||
}
|
||||
}
|
||||
|
||||
public int getSwitchableUsers() {
|
||||
int result = 0;
|
||||
ArrayList<UserRecord> users = mController.mUsers;
|
||||
int N = users.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (users.get(i).info != null) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Drawable getDrawable(Context context, UserRecord item) {
|
||||
if (item.isAddUser) {
|
||||
return context.getDrawable(R.drawable.ic_add_circle_qs);
|
||||
@@ -436,6 +424,10 @@ public class UserSwitcherController {
|
||||
return UserIcons.getDefaultUserIcon(item.isGuest ? UserHandle.USER_NULL : item.info.id,
|
||||
/* light= */ true);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
mController.refreshUsers(UserHandle.USER_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class UserRecord {
|
||||
@@ -500,6 +492,7 @@ public class UserSwitcherController {
|
||||
} else {
|
||||
v = (UserDetailView) convertView;
|
||||
}
|
||||
v.refreshAdapter();
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user