summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/Utils.java
diff options
context:
space:
mode:
authorZoltan Szatmary-Ban <szatmz@google.com>2014-12-19 16:27:45 +0000
committerZoltan Szatmary-Ban <szatmz@google.com>2015-03-09 16:58:48 +0000
commite5814ffb1843e476af3f90f00bc12837591f915e (patch)
tree51c8868b856a90de147a19f9066bc083f63c62e1 /src/com/android/settings/Utils.java
parentbc614dfcb59a8a58dbb20e54535e58aba69bd27c (diff)
downloadpackages_apps_Settings-e5814ffb1843e476af3f90f00bc12837591f915e.zip
packages_apps_Settings-e5814ffb1843e476af3f90f00bc12837591f915e.tar.gz
packages_apps_Settings-e5814ffb1843e476af3f90f00bc12837591f915e.tar.bz2
Make default user icons retrievable as cached bitmaps
Also invoke that method where formerly we did a UserIcon.convertBitmap( UserIcon.getDefaultUserIcon(...)) call. Bug: 19620707 Change-Id: I2ae3bbcee7d1c6515f0f6253925ef9837d8e3548
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r--src/com/android/settings/Utils.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 5a2618e..16037c5 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -67,6 +67,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -133,6 +134,8 @@ public final class Utils {
private static final int SECONDS_PER_HOUR = 60 * 60;
private static final int SECONDS_PER_DAY = 24 * 60 * 60;
+ private static SparseArray<Bitmap> sDarkDefaultUserBitmapCache = new SparseArray<Bitmap>();
+
/**
* Finds a matching activity for a preference's intent. If a matching
* activity is not found, it will remove the preference.
@@ -1083,4 +1086,22 @@ public final class Utils {
return (sm.getStorageBytesUntilLow(context.getFilesDir()) < 0);
}
+
+ /**
+ * Returns a default user icon (as a {@link Bitmap}) for the given user.
+ *
+ * Note that for guest users, you should pass in {@code UserHandle.USER_NULL}.
+ * @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon
+ */
+ public static Bitmap getDefaultUserIconAsBitmap(int userId) {
+ Bitmap bitmap = null;
+ // Try finding the corresponding bitmap in the dark bitmap cache
+ bitmap = sDarkDefaultUserBitmapCache.get(userId);
+ if (bitmap == null) {
+ bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(userId, false));
+ // Save it to cache
+ sDarkDefaultUserBitmapCache.put(userId, bitmap);
+ }
+ return bitmap;
+ }
}