summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-03-31 16:56:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-03-31 16:56:31 +0000
commit56d3dd8af70f2b24aa7f2cabae025c5fea06a1c8 (patch)
tree16ee76807a2eda1a8ea29b20a8ad00bf85f6257a /core/java/android
parentc48dd5d81e2fadf33314f0e738fd9fc406c6c533 (diff)
parentbc48d8c6a8189c7043b47f629aab71d09d567388 (diff)
Merge "Chaning LauncherActivityInfo to return a density specific non-badged icon" into nyc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/LauncherActivityInfo.java47
1 files changed, 8 insertions, 39 deletions
diff --git a/core/java/android/content/pm/LauncherActivityInfo.java b/core/java/android/content/pm/LauncherActivityInfo.java
index a5617b46b403..40e1a9f8ba79 100644
--- a/core/java/android/content/pm/LauncherActivityInfo.java
+++ b/core/java/android/content/pm/LauncherActivityInfo.java
@@ -103,53 +103,22 @@ public class LauncherActivityInfo {
* @return The drawable associated with the activity.
*/
public Drawable getIcon(int density) {
- final int iconRes = mResolveInfo.getIconResource();
- Drawable icon = getDrawableForDensity(iconRes, density);
- // Get the default density icon
- if (icon == null) {
- icon = mResolveInfo.loadIcon(mPm);
- }
- return icon;
- }
-
- /**
- * Returns the icon for this activity, without any badging for the profile.
- * This function can get the icon no matter the icon needs to be badged or not.
- * @param density The preferred density of the icon, zero for default density. Use
- * density DPI values from {@link DisplayMetrics}.
- * @see #getBadgedIcon(int)
- * @see DisplayMetrics
- * @return The drawable associated with the activity.
- */
- private Drawable getOriginalIcon(int density) {
final int iconRes = mResolveInfo.getIconResourceInternal();
- Drawable icon = getDrawableForDensity(iconRes, density);
- // Get the default density icon
- if (icon == null) {
- icon = mResolveInfo.loadIcon(mPm);
- }
- return icon;
- }
-
- /**
- * Returns the drawable for this activity, without any badging for the profile.
- * @param iconRes id of the drawable.
- * @param density The preferred density of the icon, zero for default density. Use
- * density DPI values from {@link DisplayMetrics}.
- * @see DisplayMetrics
- * @return The drawable associated with the resource id.
- */
- private Drawable getDrawableForDensity(int iconRes, int density) {
+ Drawable icon = null;
// Get the preferred density icon from the app's resources
if (density != 0 && iconRes != 0) {
try {
final Resources resources
= mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
- return resources.getDrawableForDensity(iconRes, density);
+ icon = resources.getDrawableForDensity(iconRes, density);
} catch (NameNotFoundException | Resources.NotFoundException exc) {
}
}
- return null;
+ // Get the default density icon
+ if (icon == null) {
+ icon = mResolveInfo.loadIcon(mPm);
+ }
+ return icon;
}
/**
@@ -201,7 +170,7 @@ public class LauncherActivityInfo {
* @return A badged icon for the activity.
*/
public Drawable getBadgedIcon(int density) {
- Drawable originalIcon = getOriginalIcon(density);
+ Drawable originalIcon = getIcon(density);
if (originalIcon instanceof BitmapDrawable) {
return mPm.getUserBadgedIcon(originalIcon, mUser);