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

Commit 83ce7c0b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Action icon should be used as a badge instead of main icon" into ub-launcher3-master

parents 679d920b d6b1f3c0
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -83,7 +84,8 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements
        if (payload.mRemoteAction != null) {
        if (payload.mRemoteAction != null) {
            prepareUsingRemoteAction(payload.mRemoteAction,
            prepareUsingRemoteAction(payload.mRemoteAction,
                    payload.bundle.getString(SearchTarget.REMOTE_ACTION_TOKEN),
                    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 {
        } else {
            prepareUsingShortcutInfo(payload.shortcuts.get(0));
            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);
        RemoteActionItemInfo itemInfo = new RemoteActionItemInfo(remoteAction, token, start);


        applyFromRemoteActionInfo(itemInfo);
        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.
            // If the Drawable from the remote action is not AdaptiveBitmap, styling will not work.
            try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
            try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
                Drawable d = itemInfo.getRemoteAction().getIcon().loadDrawable(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);
                        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);
                reapplyItemInfoAsync(itemInfo);
            }
            }
        });
        });