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

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

Merge "Events checking for long press events" into ub-launcher3-master

parents f1939f6f e277fec4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;

/**
 * Class to handle long-clicks on workspace items and start drag as a result.
@@ -46,6 +48,7 @@ public class ItemLongClickListener {
            ItemLongClickListener::onAllAppsItemLongClick;

    private static boolean onWorkspaceItemLongClick(View v) {
        TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onWorkspaceItemLongClick");
        Launcher launcher = Launcher.getLauncher(v.getContext());
        if (!canStartDrag(launcher)) return false;
        if (!launcher.isInState(NORMAL) && !launcher.isInState(OVERVIEW)) return false;
@@ -75,6 +78,8 @@ public class ItemLongClickListener {
    }

    private static boolean onAllAppsItemLongClick(View v) {
        TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onAllAppsItemLongClick");
        v.cancelLongPress();
        Launcher launcher = Launcher.getLauncher(v.getContext());
        if (!canStartDrag(launcher)) return false;
        // When we have exited all apps or are in transition, disregard long clicks
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.Workspace;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.views.OptionsPopupView;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -165,6 +167,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe

    @Override
    public void onLongPress(MotionEvent event) {
        TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Workspace.longPress");
        if (mLongPressState == STATE_REQUESTED) {
            if (canHandleLongPress()) {
                mLongPressState = STATE_PENDING_PARENT_INFORM;
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -92,6 +94,8 @@ abstract class BaseWidgetSheet extends AbstractSlideInView

    @Override
    public boolean onLongClick(View v) {
        TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Widgets.onLongClick");
        v.cancelLongPress();
        if (!ItemLongClickListener.canStartDrag(mLauncher)) return false;

        if (v instanceof WidgetCell) {
+7 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import java.util.regex.Pattern;
public final class AppIcon extends Launchable {

    private static final Pattern START_EVENT = Pattern.compile("start:");
    private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onAllAppsItemLongClick");

    AppIcon(LauncherInstrumentation launcher, UiObject2 icon) {
        super(launcher, icon);
@@ -47,10 +48,15 @@ public final class AppIcon extends Launchable {
    public AppIconMenu openMenu() {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
            return new AppIconMenu(mLauncher, mLauncher.clickAndGet(
                    mObject, "deep_shortcuts_container"));
                    mObject, "deep_shortcuts_container", LONG_CLICK_EVENT));
        }
    }

    @Override
    protected void addExpectedEventsForLongClick() {
        mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT);
    }

    @Override
    protected String getLongPressIndicator() {
        return "deep_shortcuts_container";
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ public class AppIconMenuItem extends Launchable {
        return mObject.getText();
    }

    @Override
    protected void addExpectedEventsForLongClick() {
    }

    @Override
    protected String getLongPressIndicator() {
        return "drop_target_bar";
Loading