Skip to content

Commit e5504ba

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Visual glitches when starting extracted text" into ics-mr1
2 parents b5dbf66 + 61ddbba commit e5504ba

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;
@@ -8357,10 +8355,12 @@ public boolean onTouchEvent(MotionEvent event) {
83578355
// When the cursor moves, the word that was typed may need spell check
83588356
mSpellChecker.onSelectionChanged();
83598357
}
8360-
if (isCursorInsideEasyCorrectionSpan()) {
8361-
showSuggestions();
8362-
} else if (hasInsertionController()) {
8363-
getInsertionController().show();
8358+
if (!extractedTextModeWillBeStarted()) {
8359+
if (isCursorInsideEasyCorrectionSpan()) {
8360+
showSuggestions();
8361+
} else if (hasInsertionController()) {
8362+
getInsertionController().show();
8363+
}
83648364
}
83658365
}
83668366

@@ -10112,27 +10112,35 @@ private boolean startSelectionActionMode() {
1011210112
}
1011310113
}
1011410114

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

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

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

1013310133
return selectionStarted;
1013410134
}
1013510135

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

0 commit comments

Comments
 (0)