Loading core/java/android/widget/Editor.java +21 −7 Original line number Diff line number Diff line Loading @@ -309,7 +309,7 @@ public class Editor { mTextView.setHasTransientState(false); // We had an active selection from before, start the selection mode. startSelectionActionMode(); startSelectionActionModeWithSelection(); } getPositionListener().addSubscriber(mCursorAnchorInfoNotifier, true); Loading Loading @@ -976,14 +976,15 @@ public class Editor { } public boolean performLongClick(boolean handled) { // Long press in empty space moves cursor and shows the Paste affordance if available. // Long press in empty space moves cursor and starts the selection action mode. if (!handled && !isPositionOnText(mLastDownPositionX, mLastDownPositionY) && mInsertionControllerEnabled) { final int offset = mTextView.getOffsetForPosition(mLastDownPositionX, mLastDownPositionY); stopSelectionActionMode(); Selection.setSelection((Spannable) mTextView.getText(), offset); getInsertionController().showWithActionPopup(); getInsertionController().show(); startSelectionActionModeWithoutSelection(); handled = true; } Loading @@ -999,14 +1000,14 @@ public class Editor { stopSelectionActionMode(); } else { stopSelectionActionMode(); startSelectionActionMode(); startSelectionActionModeWithSelection(); } handled = true; } // Start a new selection if (!handled) { handled = startSelectionActionMode(); handled = startSelectionActionModeWithSelection(); } return handled; Loading Loading @@ -1657,7 +1658,20 @@ public class Editor { /** * @return true if the selection mode was actually started. */ boolean startSelectionActionMode() { private boolean startSelectionActionModeWithoutSelection() { if (mSelectionActionMode != null) { // Selection action mode is already started return false; } ActionMode.Callback actionModeCallback = new SelectionActionModeCallback(); mSelectionActionMode = mTextView.startActionMode(actionModeCallback); return mSelectionActionMode != null; } /** * @return true if the selection mode was actually started. */ boolean startSelectionActionModeWithSelection() { if (mSelectionActionMode != null) { // Selection action mode is already started return false; Loading Loading @@ -4203,7 +4217,7 @@ public class Editor { boolean stayedInArea = distanceSquared < doubleTapSlop * doubleTapSlop; if (stayedInArea && isPositionOnText(x, y)) { startSelectionActionMode(); startSelectionActionModeWithSelection(); mDiscardNextActionUp = true; } } Loading core/java/android/widget/TextView.java +3 −3 Original line number Diff line number Diff line Loading @@ -5104,7 +5104,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // - onFocusChanged cannot start it when focus is given to a view with selected text (after // a screen rotation) since layout is not yet initialized at that point. if (mEditor != null && mEditor.mCreatedWithASelection) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); mEditor.mCreatedWithASelection = false; } Loading @@ -5112,7 +5112,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // ExtractEditText does not call onFocus when it is displayed, and mHasSelectionOnFocus can // not be set. Do the test here instead. if (this instanceof ExtractEditText && hasSelection() && mEditor != null) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); } unregisterForPreDraw(); Loading Loading @@ -8745,7 +8745,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Selection.setSelection((Spannable) text, start, end); // Make sure selection mode is engaged. if (mEditor != null) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); } return true; } Loading Loading
core/java/android/widget/Editor.java +21 −7 Original line number Diff line number Diff line Loading @@ -309,7 +309,7 @@ public class Editor { mTextView.setHasTransientState(false); // We had an active selection from before, start the selection mode. startSelectionActionMode(); startSelectionActionModeWithSelection(); } getPositionListener().addSubscriber(mCursorAnchorInfoNotifier, true); Loading Loading @@ -976,14 +976,15 @@ public class Editor { } public boolean performLongClick(boolean handled) { // Long press in empty space moves cursor and shows the Paste affordance if available. // Long press in empty space moves cursor and starts the selection action mode. if (!handled && !isPositionOnText(mLastDownPositionX, mLastDownPositionY) && mInsertionControllerEnabled) { final int offset = mTextView.getOffsetForPosition(mLastDownPositionX, mLastDownPositionY); stopSelectionActionMode(); Selection.setSelection((Spannable) mTextView.getText(), offset); getInsertionController().showWithActionPopup(); getInsertionController().show(); startSelectionActionModeWithoutSelection(); handled = true; } Loading @@ -999,14 +1000,14 @@ public class Editor { stopSelectionActionMode(); } else { stopSelectionActionMode(); startSelectionActionMode(); startSelectionActionModeWithSelection(); } handled = true; } // Start a new selection if (!handled) { handled = startSelectionActionMode(); handled = startSelectionActionModeWithSelection(); } return handled; Loading Loading @@ -1657,7 +1658,20 @@ public class Editor { /** * @return true if the selection mode was actually started. */ boolean startSelectionActionMode() { private boolean startSelectionActionModeWithoutSelection() { if (mSelectionActionMode != null) { // Selection action mode is already started return false; } ActionMode.Callback actionModeCallback = new SelectionActionModeCallback(); mSelectionActionMode = mTextView.startActionMode(actionModeCallback); return mSelectionActionMode != null; } /** * @return true if the selection mode was actually started. */ boolean startSelectionActionModeWithSelection() { if (mSelectionActionMode != null) { // Selection action mode is already started return false; Loading Loading @@ -4203,7 +4217,7 @@ public class Editor { boolean stayedInArea = distanceSquared < doubleTapSlop * doubleTapSlop; if (stayedInArea && isPositionOnText(x, y)) { startSelectionActionMode(); startSelectionActionModeWithSelection(); mDiscardNextActionUp = true; } } Loading
core/java/android/widget/TextView.java +3 −3 Original line number Diff line number Diff line Loading @@ -5104,7 +5104,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // - onFocusChanged cannot start it when focus is given to a view with selected text (after // a screen rotation) since layout is not yet initialized at that point. if (mEditor != null && mEditor.mCreatedWithASelection) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); mEditor.mCreatedWithASelection = false; } Loading @@ -5112,7 +5112,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // ExtractEditText does not call onFocus when it is displayed, and mHasSelectionOnFocus can // not be set. Do the test here instead. if (this instanceof ExtractEditText && hasSelection() && mEditor != null) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); } unregisterForPreDraw(); Loading Loading @@ -8745,7 +8745,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Selection.setSelection((Spannable) text, start, end); // Make sure selection mode is engaged. if (mEditor != null) { mEditor.startSelectionActionMode(); mEditor.startSelectionActionModeWithSelection(); } return true; } Loading