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

Commit ca76de0e authored by sfufa@google.com's avatar sfufa@google.com
Browse files

Support drag/drop on search results

Bug: 199341710
Test: manual
Change-Id: I9879c2a3769d4f930ab0289d2f26e4757971549d
parent fd326d1a
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.launcher3.model.data.SearchActionItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BubbleTextHolder;
import com.android.launcher3.views.IconLabelDotView;

import java.text.NumberFormat;
@@ -297,7 +298,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    @UiThread
    public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
        applyIconAndLabel(info);
        setTag(info);
        setItemInfo(info);
        applyLoadingState(promiseStateChanged);
        applyDotState(info, false /* animate */);
        setDownloadStateContentDescription(info, info.getProgressLevel());
@@ -308,7 +309,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        applyIconAndLabel(info);

        // We don't need to check the info since it's not a WorkspaceItemInfo
        super.setTag(info);
        setItemInfo(info);


        // Verify high res immediately
        verifyHighRes();
@@ -327,7 +329,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
    public void applyFromItemInfoWithIcon(ItemInfoWithIcon info) {
        applyIconAndLabel(info);
        // We don't need to check the info since it's not a WorkspaceItemInfo
        super.setTag(info);
        setItemInfo(info);

        // Verify high res immediately
        verifyHighRes();
@@ -335,13 +337,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        setDownloadStateContentDescription(info, info.getProgressLevel());
    }

    /**
     * Apply label and tag using a {@link SearchActionItemInfo}
     */
    @UiThread
    public void applyFromSearchActionItemInfo(SearchActionItemInfo searchActionItemInfo) {
        applyIconAndLabel(searchActionItemInfo);
        setTag(searchActionItemInfo);
    private void setItemInfo(ItemInfo itemInfo) {
        setTag(itemInfo);
        if (getParent() instanceof BubbleTextHolder) {
            ((BubbleTextHolder) getParent()).onItemInfoChanged(itemInfo);
        }
    }

    @UiThread
@@ -799,7 +799,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
            } else if (info instanceof PackageItemInfo) {
                applyFromItemInfoWithIcon((PackageItemInfo) info);
            } else if (info instanceof SearchActionItemInfo) {
                applyFromSearchActionItemInfo((SearchActionItemInfo) info);
                applyFromItemInfoWithIcon((SearchActionItemInfo) info);
            }

            mDisableRelayout = false;
+6 −0
Original line number Diff line number Diff line
@@ -94,6 +94,12 @@ public class LauncherSettings {
         */
        public static final int ITEM_TYPE_DEEP_SHORTCUT = 6;

        /**
         * The favroite is a search action
         */
        public static final int ITEM_TYPE_SEARCH_ACTION = 7;


        /**
         * Type of the item is recents task.
         * TODO(hyunyoungs): move constants not related to Favorites DB to a better location.
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.SearchActionItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
@@ -2735,11 +2736,17 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
                case ITEM_TYPE_APPLICATION:
                case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
                case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
                case LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION:
                    if (info instanceof AppInfo) {
                        // Came from all apps -- make a copy
                        info = ((AppInfo) info).makeWorkspaceItem();
                        d.dragInfo = info;
                    }
                    if (info instanceof SearchActionItemInfo) {
                        info = ((SearchActionItemInfo) info).createWorkspaceItem(
                                mLauncher.getModel());
                        d.dragInfo = info;
                    }
                    view = mLauncher.createShortcut(cellLayout, (WorkspaceItemInfo) info);
                    break;
                case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
+1 −0
Original line number Diff line number Diff line
@@ -584,6 +584,7 @@ public class LoaderTask implements Runnable {
                                        && pmHelper.isAppSuspended(targetPkg, c.user)) {
                                    disabledState |= FLAG_DISABLED_SUSPENDED;
                                }
                                info.options = c.getInt(optionsIndex);

                                // App shortcuts that used to be automatically added to Launcher
                                // didn't always have the correct intent flags set, so do that
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public class ItemInfo {

    public void copyFrom(ItemInfo info) {
        id = info.id;
        title = info.title;
        cellX = info.cellX;
        cellY = info.cellY;
        spanX = info.spanX;
Loading