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

Commit 156cc29a authored by Ben Kwa's avatar Ben Kwa Committed by Android (Google) Code Review
Browse files

Merge changes Ib6351831,I261c249c

* changes:
  Handle spacebar events.
  Handle shift-enter key events.
parents 4e5e8ae0 870fea3b
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -101,7 +101,6 @@ import com.android.documentsui.model.RootInfo;
import com.android.documentsui.services.FileOperationService;
import com.android.documentsui.services.FileOperationService;
import com.android.documentsui.services.FileOperationService.OpType;
import com.android.documentsui.services.FileOperationService.OpType;
import com.android.documentsui.services.FileOperations;
import com.android.documentsui.services.FileOperations;

import com.google.common.collect.Lists;
import com.google.common.collect.Lists;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
@@ -1267,8 +1266,12 @@ public class DirectoryFragment extends Fragment implements DocumentsAdapter.Envi


            // Handle enter key events
            // Handle enter key events
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.isShiftPressed()) {
                    return onSelect(doc);
                } else {
                    return onActivate(doc);
                    return onActivate(doc);
                }
                }
            }


            return false;
            return false;
        }
        }
+12 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,18 @@ class FocusManager implements View.OnFocusChangeListener {
     * @return Whether the event was handled.
     * @return Whether the event was handled.
     */
     */
    public boolean handleKey(DocumentHolder doc, int keyCode, KeyEvent event) {
    public boolean handleKey(DocumentHolder doc, int keyCode, KeyEvent event) {
        boolean extendSelection = false;
        // Translate space/shift-space into PgDn/PgUp
        if (keyCode == KeyEvent.KEYCODE_SPACE) {
            if (event.isShiftPressed()) {
                keyCode = KeyEvent.KEYCODE_PAGE_UP;
            } else {
                keyCode = KeyEvent.KEYCODE_PAGE_DOWN;
            }
        } else {
            extendSelection = event.isShiftPressed();
        }

        if (Events.isNavigationKeyCode(keyCode)) {
        if (Events.isNavigationKeyCode(keyCode)) {
            // Find the target item and focus it.
            // Find the target item and focus it.
            int endPos = findTargetPosition(doc.itemView, keyCode, event);
            int endPos = findTargetPosition(doc.itemView, keyCode, event);