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

Commit d6b1f3c0 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Action icon should be used as a badge instead of main icon

Bug: 169796517
Change-Id: I3f07fdc2ae6e1af463701f942c26c3ca5d836ee2
parent 8d14dbe0
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -83,7 +84,8 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements
        if (payload.mRemoteAction != null) {
            prepareUsingRemoteAction(payload.mRemoteAction,
                    payload.bundle.getString(SearchTarget.REMOTE_ACTION_TOKEN),
                    payload.bundle.getBoolean(SearchTarget.REMOTE_ACTION_SHOULD_START));
                    payload.bundle.getBoolean(SearchTarget.REMOTE_ACTION_SHOULD_START),
                    payload.type == ItemType.ACTION);
        } else {
            prepareUsingShortcutInfo(payload.shortcuts.get(0));
        }
@@ -102,7 +104,8 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements
        });
    }

    private void prepareUsingRemoteAction(RemoteAction remoteAction, String token, boolean start) {
    private void prepareUsingRemoteAction(RemoteAction remoteAction, String token, boolean start,
            boolean useIconToBadge) {
        RemoteActionItemInfo itemInfo = new RemoteActionItemInfo(remoteAction, token, start);

        applyFromRemoteActionInfo(itemInfo);
@@ -110,8 +113,17 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements
            // If the Drawable from the remote action is not AdaptiveBitmap, styling will not work.
            try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
                Drawable d = itemInfo.getRemoteAction().getIcon().loadDrawable(getContext());
                itemInfo.bitmap = li.createBadgedIconBitmap(d, itemInfo.user,
                BitmapInfo bitmap = li.createBadgedIconBitmap(d, itemInfo.user,
                        Build.VERSION.SDK_INT);

                if (useIconToBadge) {
                    BitmapInfo placeholder = li.createIconBitmap(
                            itemInfo.getRemoteAction().getTitle().toString().substring(0, 1),
                            bitmap.color);
                    itemInfo.bitmap = li.badgeBitmap(placeholder.icon, bitmap);
                } else {
                    itemInfo.bitmap = bitmap;
                }
                reapplyItemInfoAsync(itemInfo);
            }
        });