+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/pink_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/indigo_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/blue_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/teal_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/green_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/light_green_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/orange_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/deep_orange_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/grey_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
<color name="setup_wizard_preference_background_color_dark">@*android:color/background_material_dark</color>
<color name="setup_wizard_preference_background_color_light">@*android:color/background_material_light</color>
- <!-- Default avatar colors -->
- <color name="pink_500">#ffe91e63</color>
- <color name="indigo_500">#ff3f51b5</color>
- <color name="blue_500">#ff4285f4</color>
- <color name="teal_500">#ff00bcd4</color>
- <color name="green_500">#ff0f9d58</color>
- <color name="light_green_500">#ff8bc34a</color>
- <color name="orange_500">#ffff9800</color>
- <color name="deep_orange_500">#ffff5722</color>
- <!-- Avatar color used for guest -->
- <color name="grey_500">#ff9e9e9e</color>
-
<color name="wifi_divider">#ffe0e0e0</color>
</resources>
import android.widget.SpinnerAdapter;
import android.widget.TextView;
+import com.android.internal.util.UserIcons;
import com.android.settings.drawable.CircleFramedDrawable;
import com.android.settings.R;
} else {
name = userInfo.name;
Bitmap bitmap = um.getUserIcon(userHandle.getIdentifier());
- icon = (bitmap == null) ? null : CircleFramedDrawable.getInstance(context, bitmap);
+ if (bitmap != null) {
+ icon = CircleFramedDrawable.getInstance(context, bitmap);
+ } else {
+ icon = UserIcons.getDefaultUserIcon(userInfo.id, /* light= */ false);
+ }
}
}
}
import android.widget.ListView;
import android.widget.TabWidget;
+import com.android.internal.util.ImageUtils;
+import com.android.internal.util.UserIcons;
import com.android.settings.UserSpinnerAdapter.UserDetails;
import com.android.settings.dashboard.DashboardCategory;
import com.android.settings.dashboard.DashboardTile;
* Returns a circular icon for a user.
*/
public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
- if (user.iconPath == null) return null;
- Bitmap icon = um.getUserIcon(user.id);
- if (icon == null) return null;
- return CircleFramedDrawable.getInstance(context, icon);
+ if (user.iconPath != null) {
+ Bitmap icon = um.getUserIcon(user.id);
+ if (icon != null) {
+ return CircleFramedDrawable.getInstance(context, icon);
+ }
+ }
+ return UserIcons.getDefaultUserIcon(user.id, /* light= */ false);
}
/**
canvas.drawPath(fillPath, mPaint);
// mask in the icon where the bitmap is opaque
- mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
+ mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(icon, cropRect, circleRect, mPaint);
// prepare paint for frame drawing
package com.android.settings.users;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.widget.SimpleAdapter;
+import com.android.internal.util.UserIcons;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ChooseLockGeneric;
import com.android.settings.OwnerInfoSettings;
import com.android.settings.Utils;
import com.android.settings.drawable.CircleFramedDrawable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
/**
* Screen that manages the list of users on the device.
* Guest user is an always visible entry, even if the guest is not currently
private static final String KEY_ADD_USER_LONG_MESSAGE_DISPLAYED =
"key_add_user_long_message_displayed";
- static final int[] USER_DRAWABLES = {
- R.drawable.ic_avatar_default_1,
- R.drawable.ic_avatar_default_2,
- R.drawable.ic_avatar_default_3,
- R.drawable.ic_avatar_default_4,
- R.drawable.ic_avatar_default_5,
- R.drawable.ic_avatar_default_6,
- R.drawable.ic_avatar_default_7,
- R.drawable.ic_avatar_default_8
- };
-
- private static final int GUEST_DRAWABLE_ID = R.drawable.ic_avatar_guest;
-
private static final String KEY_TITLE = "title";
private static final String KEY_SUMMARY = "summary";
private EditUserInfoController mEditUserInfoController =
new EditUserInfoController();
- // A place to cache the generated guest avatar
- private Drawable mGuestDrawable;
// A place to cache the generated default avatar
- private Drawable mDefaultAvatarDrawable;
+ private Drawable mDefaultIconDrawable;
private Handler mHandler = new Handler() {
@Override
private void loadProfile() {
if (mIsGuest) {
// No need to load profile information
- mMePreference.setIcon(getEncircledGuestDrawable());
+ mMePreference.setIcon(getEncircledDefaultIcon());
mMePreference.setTitle(R.string.user_exit_guest_title);
return;
}
Secure.putIntForUser(getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
- Bitmap bitmap = createBitmapFromDrawable(
- USER_DRAWABLES[userId % UserSettings.USER_DRAWABLES.length]);
- mUserManager.setUserIcon(userId, bitmap);
+ assignDefaultPhoto(newUserInfo);
// Add shared accounts
AccountManager am = AccountManager.get(getActivity());
Account [] accounts = am.getAccounts();
return newUserInfo;
}
- private Bitmap createBitmapFromDrawable(int resId) {
- Drawable icon = getResources().getDrawable(resId);
- icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
- Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
- Bitmap.Config.ARGB_8888);
- icon.draw(new Canvas(bitmap));
- return bitmap;
- }
-
private UserInfo createTrustedUser() {
UserInfo newUserInfo = mUserManager.createUser(
getResources().getString(R.string.user_new_user_name), 0);
}
if (user.iconPath != null) {
if (mUserIcons.get(user.id) == null) {
+ // Icon not loaded yet, print a placeholder
missingIcons.add(user.id);
- pref.setIcon(getEncircledDefaultAvatar());
+ pref.setIcon(getEncircledDefaultIcon());
} else {
setPhotoId(pref, user);
}
} else {
- pref.setIcon(getEncircledDefaultAvatar());
+ // Icon not available yet, print a placeholder
+ pref.setIcon(getEncircledDefaultIcon());
}
}
null, null);
pref.setEnabled(false);
pref.setTitle(R.string.user_new_user_name);
- pref.setIcon(getEncircledDefaultAvatar());
+ pref.setIcon(getEncircledDefaultIcon());
mUserListCategory.addPreference(pref);
}
mIsOwner && voiceCapable? this : null /* settings icon handler */,
null /* delete icon handler */);
pref.setTitle(R.string.user_guest);
- pref.setIcon(getEncircledGuestDrawable());
+ pref.setIcon(getEncircledDefaultIcon());
pref.setOnPreferenceClickListener(this);
mUserListCategory.addPreference(pref);
}
for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId);
if (bitmap == null) {
- bitmap = createBitmapFromDrawable(R.drawable.ic_avatar_default_1);
+ bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(userId,
+ /* light= */ false));
}
mUserIcons.append(userId, bitmap);
}
}
private void assignDefaultPhoto(UserInfo user) {
- Bitmap bitmap = createBitmapFromDrawable(
- USER_DRAWABLES[user.id % UserSettings.USER_DRAWABLES.length]);
+ Bitmap bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(user.id,
+ /* light= */ false));
mUserManager.setUserIcon(user.id, bitmap);
}
- private Drawable getEncircledGuestDrawable() {
- if (mGuestDrawable == null) {
- mGuestDrawable = encircle(createBitmapFromDrawable(GUEST_DRAWABLE_ID));
- }
- return mGuestDrawable;
- }
-
- private Drawable getEncircledDefaultAvatar() {
- if (mDefaultAvatarDrawable == null) {
- mDefaultAvatarDrawable =
- encircle(createBitmapFromDrawable(R.drawable.ic_avatar_default_1));
+ private Drawable getEncircledDefaultIcon() {
+ if (mDefaultIconDrawable == null) {
+ mDefaultIconDrawable = encircle(UserIcons.convertToBitmap(
+ UserIcons.getDefaultUserIcon(UserHandle.USER_NULL, /* light= */ false)));
}
- return mDefaultAvatarDrawable;
+ return mDefaultIconDrawable;
}
private void setPhotoId(Preference pref, UserInfo user) {