Skip to content

Commit 3909242

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Double tap to select enabled on suggestions"
2 parents a6b8fe1 + 822b8f0 commit 3909242

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

core/java/android/widget/TextView.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ static class InputMethodState {
342342
private int mTextEditSuggestionItemLayout;
343343
private SuggestionsPopupWindow mSuggestionsPopupWindow;
344344
private SuggestionRangeSpan mSuggestionRangeSpan;
345+
private Runnable mShowSuggestionRunnable;
345346

346347
private int mCursorDrawableRes;
347348
private final Drawable[] mCursorDrawable = new Drawable[2];
@@ -4513,6 +4514,10 @@ protected void onDetachedFromWindow() {
45134514
mSelectionModifierCursorController.onDetached();
45144515
}
45154516

4517+
if (mShowSuggestionRunnable != null) {
4518+
removeCallbacks(mShowSuggestionRunnable);
4519+
}
4520+
45164521
hideControllers();
45174522

45184523
resetResolvedDrawables();
@@ -8330,6 +8335,10 @@ public boolean onTouchEvent(MotionEvent event) {
83308335
getSelectionController().onTouchEvent(event);
83318336
}
83328337

8338+
if (mShowSuggestionRunnable != null) {
8339+
removeCallbacks(mShowSuggestionRunnable);
8340+
}
8341+
83338342
if (action == MotionEvent.ACTION_DOWN) {
83348343
mLastDownPositionX = event.getX();
83358344
mLastDownPositionY = event.getY();
@@ -8370,7 +8379,7 @@ public boolean onTouchEvent(MotionEvent event) {
83708379
ClickableSpan[] links = ((Spannable) mText).getSpans(getSelectionStart(),
83718380
getSelectionEnd(), ClickableSpan.class);
83728381

8373-
if (links.length != 0) {
8382+
if (links.length > 0) {
83748383
links[0].onClick(this);
83758384
handled = true;
83768385
}
@@ -8397,7 +8406,15 @@ public boolean onTouchEvent(MotionEvent event) {
83978406
}
83988407
if (!extractedTextModeWillBeStarted()) {
83998408
if (isCursorInsideEasyCorrectionSpan()) {
8400-
showSuggestions();
8409+
if (mShowSuggestionRunnable == null) {
8410+
mShowSuggestionRunnable = new Runnable() {
8411+
public void run() {
8412+
showSuggestions();
8413+
}
8414+
};
8415+
}
8416+
postDelayed(mShowSuggestionRunnable,
8417+
ViewConfiguration.getDoubleTapTimeout());
84018418
} else if (hasInsertionController()) {
84028419
getInsertionController().show();
84038420
}

0 commit comments

Comments
 (0)