Skip to content

Commit 61ddbba

Browse files
author
Gilles Debunne
committed
Visual glitches when starting extracted text
Partially addresses Bug 5547923 In landscape, tapping on the text 1. starts extracted text mode 2. displays the cursor handle or the selection popup window. As a result, some ghost effects and race conditions create an unpleasing visual experience. Fixed this by not doing 2. in case extracted mode will start. The drawback of this quicl fix is that the user will have to tap again to get the handle/suggestion. That can be fixed later if needed. Change-Id: I10e1d8399bb35e5b2cd5cba1295f7d29d051cae0
1 parent da738d6 commit 61ddbba

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

core/java/android/widget/TextView.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import android.graphics.Typeface;
3737
import android.graphics.drawable.Drawable;
3838
import android.inputmethodservice.ExtractEditText;
39-
import android.net.Uri;
4039
import android.os.Bundle;
4140
import android.os.Handler;
4241
import android.os.Message;
@@ -101,7 +100,6 @@
101100
import android.util.TypedValue;
102101
import android.view.ActionMode;
103102
import android.view.ActionMode.Callback;
104-
import android.view.ContextMenu;
105103
import android.view.DragEvent;
106104
import android.view.Gravity;
107105
import android.view.HapticFeedbackConstants;
@@ -8355,10 +8353,12 @@ public boolean onTouchEvent(MotionEvent event) {
83558353
// When the cursor moves, the word that was typed may need spell check
83568354
mSpellChecker.onSelectionChanged();
83578355
}
8358-
if (isCursorInsideEasyCorrectionSpan()) {
8359-
showSuggestions();
8360-
} else if (hasInsertionController()) {
8361-
getInsertionController().show();
8356+
if (!extractedTextModeWillBeStarted()) {
8357+
if (isCursorInsideEasyCorrectionSpan()) {
8358+
showSuggestions();
8359+
} else if (hasInsertionController()) {
8360+
getInsertionController().show();
8361+
}
83628362
}
83638363
}
83648364

@@ -10113,27 +10113,35 @@ private boolean startSelectionActionMode() {
1011310113
}
1011410114
}
1011510115

10116-
final InputMethodManager imm = InputMethodManager.peekInstance();
10117-
boolean extractedTextModeWillBeStartedFullScreen = !(this instanceof ExtractEditText) &&
10118-
imm != null && imm.isFullscreenMode();
10116+
boolean willExtract = extractedTextModeWillBeStarted();
1011910117

1012010118
// Do not start the action mode when extracted text will show up full screen, thus
1012110119
// immediately hiding the newly created action bar, which would be visually distracting.
10122-
if (!extractedTextModeWillBeStartedFullScreen) {
10120+
if (!willExtract) {
1012310121
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
1012410122
mSelectionActionMode = startActionMode(actionModeCallback);
1012510123
}
10126-
final boolean selectionStarted = mSelectionActionMode != null ||
10127-
extractedTextModeWillBeStartedFullScreen;
1012810124

10129-
if (selectionStarted && !mTextIsSelectable && imm != null && mSoftInputShownOnFocus) {
10125+
final boolean selectionStarted = mSelectionActionMode != null || willExtract;
10126+
if (selectionStarted && !mTextIsSelectable && mSoftInputShownOnFocus) {
1013010127
// Show the IME to be able to replace text, except when selecting non editable text.
10131-
imm.showSoftInput(this, 0, null);
10128+
final InputMethodManager imm = InputMethodManager.peekInstance();
10129+
if (imm != null) {
10130+
imm.showSoftInput(this, 0, null);
10131+
}
1013210132
}
1013310133

1013410134
return selectionStarted;
1013510135
}
1013610136

10137+
private boolean extractedTextModeWillBeStarted() {
10138+
if (!(this instanceof ExtractEditText)) {
10139+
final InputMethodManager imm = InputMethodManager.peekInstance();
10140+
return imm != null && imm.isFullscreenMode();
10141+
}
10142+
return false;
10143+
}
10144+
1013710145
private void stopSelectionActionMode() {
1013810146
if (mSelectionActionMode != null) {
1013910147
// This will hide the mSelectionModifierCursorController

0 commit comments

Comments
 (0)