Skip to content

Commit 2f9510c

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Touch moves cursor in text refactored"
2 parents e8bb6fe + 004b02d commit 2f9510c

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

core/java/android/text/method/ArrowKeyMovementMethod.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event
280280
if (isSelecting(buffer)) {
281281
buffer.removeSpan(LAST_TAP_DOWN);
282282
Selection.extendSelection(buffer, offset);
283-
} else if (!widget.shouldIgnoreActionUpEvent()) {
284-
Selection.setSelection(buffer, offset);
285283
}
286284

287285
MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);

core/java/android/widget/TextView.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8353,7 +8353,7 @@ public boolean onTouchEvent(MotionEvent event) {
83538353
}
83548354

83558355
final boolean touchIsFinished = (action == MotionEvent.ACTION_UP) &&
8356-
!shouldIgnoreActionUpEvent() && isFocused();
8356+
!mIgnoreActionUpEvent && isFocused();
83578357

83588358
if ((mMovement != null || onCheckIsTextEditor()) && isEnabled()
83598359
&& mText instanceof Spannable && mLayout != null) {
@@ -8377,6 +8377,10 @@ public boolean onTouchEvent(MotionEvent event) {
83778377
}
83788378

83798379
if (touchIsFinished && (isTextEditable() || mTextIsSelectable)) {
8380+
// Move cursor
8381+
final int offset = getOffsetForPosition(event.getX(), event.getY());
8382+
Selection.setSelection((Spannable) mText, offset);
8383+
83808384
// Show the IME, except when selecting in read-only text.
83818385
final InputMethodManager imm = InputMethodManager.peekInstance();
83828386
viewClicked(imm);
@@ -8529,17 +8533,6 @@ public void cancelLongPress() {
85298533
mIgnoreActionUpEvent = true;
85308534
}
85318535

8532-
/**
8533-
* This method is only valid during a touch event.
8534-
*
8535-
* @return true when the ACTION_UP event should be ignored, false otherwise.
8536-
*
8537-
* @hide
8538-
*/
8539-
public boolean shouldIgnoreActionUpEvent() {
8540-
return mIgnoreActionUpEvent;
8541-
}
8542-
85438536
@Override
85448537
public boolean onTrackballEvent(MotionEvent event) {
85458538
if (mMovement != null && mText instanceof Spannable &&
@@ -10145,8 +10138,8 @@ private boolean startSelectionActionMode() {
1014510138

1014610139
boolean willExtract = extractedTextModeWillBeStarted();
1014710140

10148-
// Do not start the action mode when extracted text will show up full screen, thus
10149-
// immediately hiding the newly created action bar, which would be visually distracting.
10141+
// Do not start the action mode when extracted text will show up full screen, which would
10142+
// immediately hide the newly created action bar and would be visually distracting.
1015010143
if (!willExtract) {
1015110144
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
1015210145
mSelectionActionMode = startActionMode(actionModeCallback);

0 commit comments

Comments
 (0)