|
36 | 36 | import android.graphics.Typeface; |
37 | 37 | import android.graphics.drawable.Drawable; |
38 | 38 | import android.inputmethodservice.ExtractEditText; |
39 | | -import android.net.Uri; |
40 | 39 | import android.os.Bundle; |
41 | 40 | import android.os.Handler; |
42 | 41 | import android.os.Message; |
|
101 | 100 | import android.util.TypedValue; |
102 | 101 | import android.view.ActionMode; |
103 | 102 | import android.view.ActionMode.Callback; |
104 | | -import android.view.ContextMenu; |
105 | 103 | import android.view.DragEvent; |
106 | 104 | import android.view.Gravity; |
107 | 105 | import android.view.HapticFeedbackConstants; |
@@ -8357,10 +8355,12 @@ public boolean onTouchEvent(MotionEvent event) { |
8357 | 8355 | // When the cursor moves, the word that was typed may need spell check |
8358 | 8356 | mSpellChecker.onSelectionChanged(); |
8359 | 8357 | } |
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 | + } |
8364 | 8364 | } |
8365 | 8365 | } |
8366 | 8366 |
|
@@ -10112,27 +10112,35 @@ private boolean startSelectionActionMode() { |
10112 | 10112 | } |
10113 | 10113 | } |
10114 | 10114 |
|
10115 | | - final InputMethodManager imm = InputMethodManager.peekInstance(); |
10116 | | - boolean extractedTextModeWillBeStartedFullScreen = !(this instanceof ExtractEditText) && |
10117 | | - imm != null && imm.isFullscreenMode(); |
| 10115 | + boolean willExtract = extractedTextModeWillBeStarted(); |
10118 | 10116 |
|
10119 | 10117 | // Do not start the action mode when extracted text will show up full screen, thus |
10120 | 10118 | // immediately hiding the newly created action bar, which would be visually distracting. |
10121 | | - if (!extractedTextModeWillBeStartedFullScreen) { |
| 10119 | + if (!willExtract) { |
10122 | 10120 | ActionMode.Callback actionModeCallback = new SelectionActionModeCallback(); |
10123 | 10121 | mSelectionActionMode = startActionMode(actionModeCallback); |
10124 | 10122 | } |
10125 | | - final boolean selectionStarted = mSelectionActionMode != null || |
10126 | | - extractedTextModeWillBeStartedFullScreen; |
10127 | 10123 |
|
10128 | | - if (selectionStarted && !mTextIsSelectable && imm != null && mSoftInputShownOnFocus) { |
| 10124 | + final boolean selectionStarted = mSelectionActionMode != null || willExtract; |
| 10125 | + if (selectionStarted && !mTextIsSelectable && mSoftInputShownOnFocus) { |
10129 | 10126 | // 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 | + } |
10131 | 10131 | } |
10132 | 10132 |
|
10133 | 10133 | return selectionStarted; |
10134 | 10134 | } |
10135 | 10135 |
|
| 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 | + |
10136 | 10144 | private void stopSelectionActionMode() { |
10137 | 10145 | if (mSelectionActionMode != null) { |
10138 | 10146 | // This will hide the mSelectionModifierCursorController |
|
0 commit comments