Merge "Always draw a background for the user avatar" into sc-dev

This commit is contained in:
Peter Kalauskas
2021-04-06 16:33:37 +00:00
committed by Android (Google) Code Review
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});