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

Commit 61bcfba3 authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Support user event logging for drag and drop b/30039490" into ub-launcher3-calgary-polish

parents 3cc2d8b3 59a23809
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -19,11 +19,12 @@ package com.android.launcher3;
import android.view.View;

import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;

/**
 * Interface defining an object that can originate a drag.
 */
public interface DragSource {
public interface DragSource extends LaunchSourceProvider {

    /**
     * @return whether items dragged from this source supports
+4 −1
Original line number Diff line number Diff line
@@ -48,9 +48,12 @@ public interface DropTarget {
        /** The view that moves around while you drag.  */
        public DragView dragView = null;

        /** The data associated with the object being dragged */
        /** The data associated with the object, after item is dropped. */
        public ItemInfo dragInfo = null;

        /** The data associated with the object  being dragged */
        public ItemInfo originalDragInfo = null;

        /** Where the drag originated */
        public DragSource dragSource = null;

+8 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ import java.util.HashSet;
public class Workspace extends PagedView
        implements DropTarget, DragSource, DragScroller, View.OnTouchListener,
        DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener,
        Insettable, DropTargetSource, AccessibilityDragSource, UserEventDispatcher.LaunchSourceProvider {
        Insettable, DropTargetSource, AccessibilityDragSource {
    private static final String TAG = "Launcher.Workspace";

    private static boolean ENFORCE_DRAG_EVENT_ORDER = false;
@@ -3426,6 +3426,7 @@ public class Workspace extends PagedView
                if (info.container == NO_ID && info instanceof AppInfo) {
                    // Came from all apps -- make a copy
                    info = ((AppInfo) info).makeShortcut();
                    d.dragInfo = info;
                }
                view = mLauncher.createShortcut(cellLayout, (ShortcutInfo) info);
                break;
@@ -4295,6 +4296,12 @@ public class Workspace extends PagedView
        target.gridY = info.cellY;
        target.pageIndex = getCurrentPage();
        targetParent.containerType = LauncherLogProto.WORKSPACE;
        if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            target.rank = info.rank;
            targetParent.containerType = LauncherLogProto.HOTSEAT;
        } else if (info.container >= 0) {
            targetParent.containerType = LauncherLogProto.FOLDER;
        }
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.graphics.TintedDrawableSpan;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ComponentKey;

import java.nio.charset.Charset;
@@ -700,4 +702,9 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
        mSearchQueryBuilder.clearSpans();
        Selection.setSelection(mSearchQueryBuilder, 0);
    }

    @Override
    public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
        targetParent.containerType = mAppsRecyclerView.getContainerType(v);
    }
}
+5 −11
Original line number Diff line number Diff line
@@ -27,20 +27,16 @@ import android.view.View;
import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;

import java.util.List;

/**
 * A RecyclerView with custom fast scroll support for the all apps view.
 */
public class AllAppsRecyclerView extends BaseRecyclerView
        implements LaunchSourceProvider {
public class AllAppsRecyclerView extends BaseRecyclerView {

    private AlphabeticalAppsList mApps;
    private AllAppsFastScrollHelper mFastScrollHelper;
@@ -207,10 +203,9 @@ public class AllAppsRecyclerView extends BaseRecyclerView
        updateEmptySearchBackgroundBounds();
    }

    @Override
    public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
    public int getContainerType(View v) {
        if (mApps.hasFilter()) {
            targetParent.containerType = LauncherLogProto.SEARCHRESULT;
            return LauncherLogProto.SEARCHRESULT;
        } else {
            if (v instanceof BubbleTextView) {
                BubbleTextView icon = (BubbleTextView) v;
@@ -219,12 +214,11 @@ public class AllAppsRecyclerView extends BaseRecyclerView
                    List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
                    AlphabeticalAppsList.AdapterItem item = items.get(position);
                    if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) {
                        targetParent.containerType = LauncherLogProto.PREDICTION;
                        return;
                        return LauncherLogProto.PREDICTION;
                    }
                }
            }
            targetParent.containerType = LauncherLogProto.ALLAPPS;
            return LauncherLogProto.ALLAPPS;
        }
    }

Loading