Mark/unmark activated state before the user switch begins.

This makes the screen freeze appear more fluid while switching users.

Bug: 146426568
Test: Manual
Change-Id: I7f18a560ce00c9037b182db1a5fc546480c43d91
This commit is contained in:
Ben Murdoch
2020-02-20 16:08:27 +00:00
parent 11d8a6ef87
commit b7c16ecf03
3 changed files with 26 additions and 0 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);
}
}