Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 681f86ed authored by Linus Lee's avatar Linus Lee Committed by Gerrit Code Review
Browse files

SystemUI: Refresh user list a little more eagerly

Manual cherry-pick (since merge wasn't happy) of
844c92b4

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: I804f22eed626bdbfa3bd98013b55d9992112a350
parent 2fa5cab4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -83,4 +83,8 @@ public class UserDetailView extends PseudoGridView {
            switchTo(tag);
        }
    }

    public void refreshAdapter() {
        mAdapter.refresh();
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ public class KeyguardUserSwitcher {
    public void show(boolean animate) {
        if (mUserSwitcher != null && mUserSwitcher.getVisibility() != View.VISIBLE) {
            cancelAnimations();
            mAdapter.refresh();
            mUserSwitcher.setVisibility(View.VISIBLE);
            mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
            if (animate) {
+5 −12
Original line number Diff line number Diff line
@@ -416,18 +416,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);
@@ -435,6 +423,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 {
@@ -499,6 +491,7 @@ public class UserSwitcherController {
            } else {
                v = (UserDetailView) convertView;
            }
            v.refreshAdapter();
            return v;
        }