Merge changes Id6f54480,I7f18a560

* changes:
  Don't re-order users in the lock screen / quick settings user switcher.
  Mark/unmark activated state before the user switch begins.
This commit is contained in:
TreeHugger Robot
2020-02-21 09:26:15 +00:00
committed by Android (Google) Code Review
4 changed files with 28 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ public class UserDetailView extends PseudoGridView {
private final Context mContext;
protected UserSwitcherController mController;
private View mCurrentUserView;
public Adapter(Context context, UserSwitcherController controller) {
super(controller);
@@ -89,6 +90,9 @@ public class UserDetailView extends PseudoGridView {
v.bind(name, item.picture, item.info.id);
}
v.setActivated(item.isCurrent);
if (item.isCurrent) {
mCurrentUserView = v;
}
v.setDisabledByAdmin(item.isDisabledByAdmin);
if (!item.isSwitchToEnabled) {
v.setEnabled(false);
@@ -107,6 +111,12 @@ public class UserDetailView extends PseudoGridView {
mController.startActivity(intent);
} else if (tag.isSwitchToEnabled) {
MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER);
if (!tag.isAddUser && !tag.isRestricted && !tag.isDisabledByAdmin) {
if (mCurrentUserView != null) {
mCurrentUserView.setActivated(false);
}
view.setActivated(true);
}
switchTo(tag);
}
}

View File

@@ -74,6 +74,12 @@ public class UserAvatarView extends View {
this(context, null);
}
@Override
public void setActivated(boolean activated) {
super.setActivated(activated);
mDrawable.invalidateSelf();
}
/**
* @deprecated use {@link #setAvatar(Bitmap)} instead.
*/

View File

@@ -257,6 +257,7 @@ public class KeyguardUserSwitcher {
private Context mContext;
private KeyguardUserSwitcher mKeyguardUserSwitcher;
private View mCurrentUserView;
public Adapter(Context context, UserSwitcherController controller,
KeyguardUserSwitcher kgu) {
@@ -285,6 +286,9 @@ public class KeyguardUserSwitcher {
// Disable the icon if switching is disabled
v.setAvatarEnabled(item.isSwitchToEnabled);
convertView.setActivated(item.isCurrent);
if (item.isCurrent) {
mCurrentUserView = convertView;
}
convertView.setTag(item);
return convertView;
}
@@ -297,6 +301,12 @@ public class KeyguardUserSwitcher {
// tapping the guest user while it's current clears the session.
mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
} else if (user.isSwitchToEnabled) {
if (!user.isAddUser && !user.isRestricted && !user.isDisabledByAdmin) {
if (mCurrentUserView != null) {
mCurrentUserView.setActivated(false);
}
v.setActivated(true);
}
switchTo(user);
}
}

View File

@@ -236,8 +236,7 @@ public class UserSwitcherController implements Dumpable {
picture, avatarSize, avatarSize, true);
}
}
int index = isCurrent ? 0 : records.size();
records.add(index, new UserRecord(info, picture, false /* isGuest */,
records.add(new UserRecord(info, picture, false /* isGuest */,
isCurrent, false /* isAddUser */, false /* isRestricted */,
switchToEnabled));
}
@@ -269,8 +268,7 @@ public class UserSwitcherController implements Dumpable {
records.add(guestRecord);
}
} else {
int index = guestRecord.isCurrent ? 0 : records.size();
records.add(index, guestRecord);
records.add(guestRecord);
}
if (canCreateUser) {