Merge "Make spinner icons circular"
This commit is contained in:
committed by
Android (Google) Code Review
commit
cf054c0b74
@@ -213,7 +213,7 @@
|
|||||||
<dimen name="user_icon_view_height">56dp</dimen>
|
<dimen name="user_icon_view_height">56dp</dimen>
|
||||||
<!-- User spinner -->
|
<!-- User spinner -->
|
||||||
<dimen name="user_spinner_height">72dp</dimen>
|
<dimen name="user_spinner_height">72dp</dimen>
|
||||||
<dimen name="user_spinner_padding">8dp</dimen>
|
<dimen name="user_spinner_padding">4dp</dimen>
|
||||||
<dimen name="user_spinner_item_height">56dp</dimen>
|
<dimen name="user_spinner_item_height">56dp</dimen>
|
||||||
|
|
||||||
<!-- CheckBoxPreference -->
|
<!-- CheckBoxPreference -->
|
||||||
|
@@ -32,6 +32,7 @@ import android.widget.SpinnerAdapter;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.util.UserIcons;
|
import com.android.internal.util.UserIcons;
|
||||||
|
import com.android.settings.drawable.CircleFramedDrawable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -43,18 +44,19 @@ public class UserSpinnerAdapter implements SpinnerAdapter {
|
|||||||
/** Holder for user details */
|
/** Holder for user details */
|
||||||
public static class UserDetails {
|
public static class UserDetails {
|
||||||
private final UserHandle mUserHandle;
|
private final UserHandle mUserHandle;
|
||||||
private final String name;
|
private final String mName;
|
||||||
private final Drawable icon;
|
private final Drawable mIcon;
|
||||||
|
|
||||||
public UserDetails(UserHandle userHandle, UserManager um, Context context) {
|
public UserDetails(UserHandle userHandle, UserManager um, Context context) {
|
||||||
mUserHandle = userHandle;
|
mUserHandle = userHandle;
|
||||||
UserInfo userInfo = um.getUserInfo(mUserHandle.getIdentifier());
|
UserInfo userInfo = um.getUserInfo(mUserHandle.getIdentifier());
|
||||||
|
Drawable icon;
|
||||||
if (userInfo.isManagedProfile()) {
|
if (userInfo.isManagedProfile()) {
|
||||||
name = context.getString(R.string.managed_user_title);
|
mName = context.getString(R.string.managed_user_title);
|
||||||
icon = context.getDrawable(
|
icon = context.getDrawable(
|
||||||
com.android.internal.R.drawable.ic_corp_icon);
|
com.android.internal.R.drawable.ic_corp_icon);
|
||||||
} else {
|
} else {
|
||||||
name = userInfo.name;
|
mName = userInfo.name;
|
||||||
final int userId = userInfo.id;
|
final int userId = userInfo.id;
|
||||||
if (um.getUserIcon(userId) != null) {
|
if (um.getUserIcon(userId) != null) {
|
||||||
icon = new BitmapDrawable(context.getResources(), um.getUserIcon(userId));
|
icon = new BitmapDrawable(context.getResources(), um.getUserIcon(userId));
|
||||||
@@ -62,6 +64,11 @@ public class UserSpinnerAdapter implements SpinnerAdapter {
|
|||||||
icon = UserIcons.getDefaultUserIcon(userId, /* light= */ false);
|
icon = UserIcons.getDefaultUserIcon(userId, /* light= */ false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.mIcon = encircle(context, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Drawable encircle(Context context, Drawable icon) {
|
||||||
|
return CircleFramedDrawable.getInstance(context, UserIcons.convertToBitmap(icon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private ArrayList<UserDetails> data;
|
private ArrayList<UserDetails> data;
|
||||||
@@ -87,8 +94,8 @@ public class UserSpinnerAdapter implements SpinnerAdapter {
|
|||||||
final View row = convertView != null ? convertView : createUser(parent);
|
final View row = convertView != null ? convertView : createUser(parent);
|
||||||
|
|
||||||
UserDetails user = data.get(position);
|
UserDetails user = data.get(position);
|
||||||
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(user.icon);
|
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(user.mIcon);
|
||||||
((TextView) row.findViewById(android.R.id.title)).setText(user.name);
|
((TextView) row.findViewById(android.R.id.title)).setText(user.mName);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user