Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80d57efd authored by Sunny Goyal's avatar Sunny Goyal Committed by android-build-merger
Browse files

Merge "Chaning LauncherActivityInfo to return a density specific non-badged icon" into nyc-dev

am: 56d3dd8a

* commit '56d3dd8a':
  Chaning LauncherActivityInfo to return a density specific non-badged icon

Change-Id: I642e890b23bbd59be6fce6ddee1cb74be6b5f71a
parents 6fa7b461 56d3dd8a
Loading
Loading
Loading
Loading
+8 −39
Original line number Diff line number Diff line
@@ -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);