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

Commit 844c92b4 authored by Adrian Roos's avatar Adrian Roos
Browse files

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
parent 07b4a291
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 {

+1 −0
Original line number Diff line number Diff line
@@ -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) {
+5 −12
Original line number Diff line number Diff line
@@ -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;
        }