Always draw a background for the user avatar

Test: On wembley, verify that newly created users, which still have
      their default icon, are drawn with a background when displayed on
      the lock screen
Bug: 181176583
Change-Id: Id89e0be2a90956a1fb21216293b8c4c769cf2935
This commit is contained in:
Peter Kalauskas
2021-03-31 14:36:50 -07:00
parent e57091c6c3
commit a1d1f5a272
3 changed files with 19 additions and 27 deletions

View File

@@ -92,8 +92,6 @@
<color name="kg_user_switcher_avatar_icon_color">@android:color/background_light</color>
<!-- Icon color for selected user avatars in keyguard user switcher -->
<color name="kg_user_switcher_selected_avatar_icon_color">#202124</color>
<!-- Color of background circle of user avatars in keyguard user switcher -->
<color name="kg_user_switcher_avatar_background">#3C4043</color>
<!-- Icon color for user avatars in quick settings user switcher -->
<color name="qs_user_switcher_avatar_icon_color">@android:color/background_light</color>
<!-- Icon color for selected user avatars in quick settings user switcher -->

View File

@@ -79,7 +79,7 @@
(e.g. cannot be switched to) -->
<color name="kg_user_switcher_restricted_avatar_icon_color">@color/GM2_grey_600</color>
<!-- Color of background circle of user avatars in keyguard user switcher -->
<color name="kg_user_switcher_avatar_background">@color/GM2_grey_300</color>
<color name="kg_user_switcher_avatar_background">?android:attr/colorBackgroundFloating</color>
<!-- Icon color for user avatars in user switcher quick settings -->
<color name="qs_user_switcher_avatar_icon_color">#3C4043</color>

View File

@@ -224,35 +224,29 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
mView.setContentDescription(contentDescription);
}
mView.setDrawableWithBadge(getCurrentUserIcon().mutate(), mCurrentUser.resolveId());
}
Drawable getCurrentUserIcon() {
Drawable drawable;
if (mCurrentUser.picture == null) {
mView.setDrawableWithBadge(getDrawable(mCurrentUser).mutate(),
mCurrentUser.resolveId());
if (mCurrentUser.isCurrent && mCurrentUser.isGuest) {
drawable = mContext.getDrawable(R.drawable.ic_avatar_guest_user);
} else {
drawable = mAdapter.getIconDrawable(mContext, mCurrentUser);
}
int iconColorRes;
if (mCurrentUser.isSwitchToEnabled) {
iconColorRes = R.color.kg_user_switcher_avatar_icon_color;
} else {
iconColorRes = R.color.kg_user_switcher_restricted_avatar_icon_color;
}
drawable.setTint(mResources.getColor(iconColorRes, mContext.getTheme()));
} else {
int avatarSize =
(int) mResources.getDimension(R.dimen.kg_framed_avatar_size);
Drawable drawable = new CircleFramedDrawable(mCurrentUser.picture, avatarSize);
drawable.setColorFilter(
mCurrentUser.isSwitchToEnabled ? null
: mAdapter.getDisabledUserAvatarColorFilter());
mView.setDrawableWithBadge(drawable, mCurrentUser.info.id);
drawable = new CircleFramedDrawable(mCurrentUser.picture, avatarSize);
}
}
Drawable getDrawable(UserSwitcherController.UserRecord item) {
Drawable drawable;
if (item.isCurrent && item.isGuest) {
drawable = mContext.getDrawable(R.drawable.ic_avatar_guest_user);
} else {
drawable = mAdapter.getIconDrawable(mContext, item);
}
int iconColorRes;
if (item.isSwitchToEnabled) {
iconColorRes = R.color.kg_user_switcher_avatar_icon_color;
} else {
iconColorRes = R.color.kg_user_switcher_restricted_avatar_icon_color;
}
drawable.setTint(mResources.getColor(iconColorRes, mContext.getTheme()));
Drawable bg = mContext.getDrawable(R.drawable.kg_bg_avatar);
drawable = new LayerDrawable(new Drawable[]{bg, drawable});