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

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

Merge "Disable vibration on actionMode start; make it perform on long press." into oc-dev

parents ee70251c 8dc19d64
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ public class ActionModeController
            if (mActionMode == null) {
                if (DEBUG) Log.d(TAG, "Starting action mode.");
                mActionMode = mActivity.startActionMode(this);
                mScope.hapticPerformer.accept(HapticFeedbackConstants.LONG_PRESS);
            }
            updateActionMenu();
        } else {
@@ -219,13 +218,12 @@ public class ActionModeController
    }

    public ActionModeController reset(
            SelectionDetails selectionDetails, EventHandler<MenuItem> menuItemClicker, View view) {
            SelectionDetails selectionDetails, EventHandler<MenuItem> menuItemClicker) {
        assert(mActionMode == null);
        assert(mMenu == null);

        mScope.menuItemClicker = menuItemClicker;
        mScope.selectionDetails = selectionDetails;
        mScope.hapticPerformer = view::performHapticFeedback;
        mScope.accessibilityImportanceSetter =
                (int accessibilityImportance, @IdRes int[] viewIds) -> {
                    setImportantForAccessibility(
@@ -238,7 +236,6 @@ public class ActionModeController
    private static final class ContentScope {
        private EventHandler<MenuItem> menuItemClicker;
        private SelectionDetails selectionDetails;
        private IntConsumer hapticPerformer;
        private AccessibilityImportanceSetter accessibilityImportanceSetter;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ public class Injector<T extends ActionHandler> {
    }

    public final ActionModeController getActionModeController(
            SelectionDetails selectionDetails, EventHandler<MenuItem> menuItemClicker, View view) {
        return actionModeController.reset(selectionDetails, menuItemClicker, view);
            SelectionDetails selectionDetails, EventHandler<MenuItem> menuItemClicker) {
        return actionModeController.reset(selectionDetails, menuItemClicker);
    }

    /**
+4 −3
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.ContextMenu;
import android.view.DragEvent;
import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -366,7 +367,8 @@ public class DirectoryFragment extends Fragment
                this::canSelect,
                this::onContextMenuClick,
                mDragStartListener::onTouchDragEvent,
                gestureHandler);
                gestureHandler,
                () -> mRecView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS));

        new ListeningGestureDetector(
                mInjector.features,
@@ -381,8 +383,7 @@ public class DirectoryFragment extends Fragment

        mActionModeController = mInjector.getActionModeController(
                mSelectionMetadata,
                this::handleMenuItemClick,
                mRecView);
                this::handleMenuItemClick);

        mSelectionMgr.addCallback(mActionModeController);

+11 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public final class UserInputHandler<T extends InputEvent>

    private final EventHandler<InputEvent> mTouchDragListener;
    private final EventHandler<InputEvent> mGestureSelectHandler;
    private final Runnable mPerformHapticFeedback;

    private final TouchInputDelegate mTouchDelegate;
    private final MouseInputDelegate mMouseDelegate;
@@ -69,7 +70,8 @@ public final class UserInputHandler<T extends InputEvent>
            Predicate<DocumentDetails> selectable,
            EventHandler<InputEvent> contextMenuClickHandler,
            EventHandler<InputEvent> touchDragListener,
            EventHandler<InputEvent> gestureSelectHandler) {
            EventHandler<InputEvent> gestureSelectHandler,
            Runnable performHapticFeedback) {

        mActions = actions;
        mFocusHandler = focusHandler;
@@ -79,6 +81,7 @@ public final class UserInputHandler<T extends InputEvent>
        mContextMenuClickHandler = contextMenuClickHandler;
        mTouchDragListener = touchDragListener;
        mGestureSelectHandler = gestureSelectHandler;
        mPerformHapticFeedback = performHapticFeedback;

        mTouchDelegate = new TouchInputDelegate();
        mMouseDelegate = new MouseInputDelegate();
@@ -266,8 +269,10 @@ public final class UserInputHandler<T extends InputEvent>
            }

            DocumentDetails doc = event.getDocumentDetails();
            boolean handled = false;
            if (isRangeExtension(event)) {
                extendSelectionRange(doc);
                handled = true;
            } else {
                if (!mSelectionMgr.getSelection().contains(doc.getModelId())) {
                    selectDocument(doc);
@@ -275,13 +280,18 @@ public final class UserInputHandler<T extends InputEvent>
                    // start gesture selection
                    if (mSelectable.test(doc)) {
                        mGestureSelectHandler.accept(event);
                        handled = true;
                    }
                } else {
                    // We only initiate drag and drop on long press for touch to allow regular
                    // touch-based scrolling
                    mTouchDragListener.accept(event);
                    handled = true;
                }
            }
            if (handled) {
                mPerformHapticFeedback.run();
            }
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -60,4 +60,10 @@ public class TestEventHandler<T> implements EventHandler<T> {
    public @Nullable T getLastValue() {
        return lastValue;
    }

    public void reset() {
        called = false;
        lastValue = null;
        nextReturnValue = false;
    }
}
Loading