summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-06 16:23:56 -0700
committerDanesh M <daneshm90@gmail.com>2015-09-27 15:12:53 -0700
commit88699b6191c6e8f75b0cc64cce5313fc31ed1348 (patch)
tree538245db0ac03dcd0787ab8517bbd788eb935f8d /src/com/android/launcher3/Utilities.java
parent19b63da9550dd4734f2df0e663dc8009b29705a0 (diff)
downloadandroid_packages_apps_Trebuchet-88699b6191c6e8f75b0cc64cce5313fc31ed1348.tar.gz
android_packages_apps_Trebuchet-88699b6191c6e8f75b0cc64cce5313fc31ed1348.tar.bz2
android_packages_apps_Trebuchet-88699b6191c6e8f75b0cc64cce5313fc31ed1348.zip
Updating icons for sortcuts when the target app updates.
Bug: 17398260 Change-Id: I055abb971d1f72245e8616ac2ce07bcdf37cdd52
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index a75ddf6a1..862a96d1e 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -156,6 +156,27 @@ public final class Utilities {
}
/**
+ * Returns a bitmap suitable for the all apps view. If the package or the resource do not
+ * exist, it returns null.
+ */
+ static Bitmap createIconBitmap(String packageName, String resourceName, IconCache cache,
+ Context context) {
+ PackageManager packageManager = context.getPackageManager();
+ // the resource
+ try {
+ Resources resources = packageManager.getResourcesForApplication(packageName);
+ if (resources != null) {
+ final int id = resources.getIdentifier(resourceName, null, null);
+ return createIconBitmap(
+ resources.getDrawableForDensity(id, cache.getFullResIconDpi()), context);
+ }
+ } catch (Exception e) {
+ // Icon not found.
+ }
+ return null;
+ }
+
+ /**
* Returns a bitmap which is of the appropriate size to be displayed as an icon
*/
static Bitmap createIconBitmap(Bitmap icon, Context context) {