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

Commit 225ad9cb authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE Text selection: tapping on selection opens context menu" into gingerbread

parents b8fd0473 45b2d699
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -78424,7 +78424,7 @@
 type="float"
 transient="false"
 volatile="false"
 value="0.0010f"
 value="0.001f"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -224842,7 +224842,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+36 −5
Original line number Diff line number Diff line
@@ -4303,6 +4303,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                if (shouldAdvanceFocusOnEnter()) {
                    return 0;
                }
                break;
                
            case KeyEvent.KEYCODE_BACK:
                if (mIsInTextSelectionMode) {
                    stopTextSelectionMode();
                    return -1;
                }
                break;
        }

        if (mInput != null) {
@@ -6618,9 +6626,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                end = mPrevEnd;
            } else {
                if ((mPrevStart != mPrevEnd) && (start == end)) {
                    if ((start >= mPrevStart) && (start <= mPrevEnd)) {
                    if ((start >= mPrevStart) && (start < mPrevEnd)) {
                        // Tapping inside the selection does nothing
                        Selection.setSelection((Spannable) mText, mPrevStart, mPrevEnd);
                        showContextMenu();
                        return;
                    } else {
                        // Tapping outside stops selection mode, if any
@@ -7221,9 +7230,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                     setAlphabeticShortcut('v');
            }

            menu.add(0, ID_STOP_SELECTING_TEXT, 0, com.android.internal.R.string.stopSelectingText).
                 setOnMenuItemClickListener(handler);
            
            added = true;
        } else {
            /*
@@ -7272,10 +7278,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                }
            }
            
            if (canPaste()) {
            // Paste location is too imprecise. Only allow on empty text fields.
            if (canPaste() && textIsOnlySpaces()) {
                menu.add(0, ID_PASTE, 0, com.android.internal.R.string.paste).
                     setOnMenuItemClickListener(handler).
                     setAlphabeticShortcut('v');
                added = true;
            }

            if (isInputMethodTarget()) {
@@ -7299,6 +7307,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
    }

    private boolean textIsOnlySpaces() {
        final int length = mTransformed.length();
        for (int i=0; i<length; i++) {
            final char c = mTransformed.charAt(i);
            final int type = Character.getType(c);
            if (type != Character.SPACE_SEPARATOR)
                return false;
        }
        return true;
    }

    /**
     * Returns whether this text view is a current input method target.  The
     * default implementation just checks with {@link InputMethodManager}.
@@ -7737,6 +7756,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        private boolean mStartIsDragged = false;
        // Starting time of the fade timer
        private long mFadeOutTimerStart;
        // Used to detect a tap (vs drag) on the controller
        private long mOnDownTimerStart;
        // The cursor controller images
        private final Handle mStartHandle, mEndHandle;
        // Offset between finger hot point on active cursor controller and actual cursor
@@ -7884,12 +7905,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                                    mOffsetX = (bounds.left + bounds.right) / 2.0f - x;
                                    mOffsetY = draggedHandle.mHotSpotVerticalPosition - y;

                                    mOnDownTimerStart = event.getEventTime();
                                    ((ArrowKeyMovementMethod)mMovement).setCursorController(this);
                                }
                            }
                        }
                        break;

                    case MotionEvent.ACTION_UP:
                        int time = (int) (event.getEventTime() - mOnDownTimerStart);

                        if (time <= ViewConfiguration.getTapTimeout()) {
                            // A tap on the controller (not a drag) opens the contextual Copy menu
                            showContextMenu();
                        }
                        break;

                    case MotionEvent.ACTION_POINTER_DOWN:
                    case MotionEvent.ACTION_POINTER_UP:
                        // Handle multi-point gestures. Keep min and max offset positions.
+0 −3
Original line number Diff line number Diff line
@@ -1856,9 +1856,6 @@
    <!-- Item on EditText context menu. This action is used to start selecting text in the edit field. -->
    <string name="selectText">Select word</string>

    <!-- Item on EditText context menu. This action is used to stop selecting text in the edit field. -->
    <string name="stopSelectingText">Stop selecting text</string>

    <!-- Item on EditText context menu.  This action is used to cut selected the text into the clipboard.  -->
    <string name="cut">Cut</string>