Skip to content

Commit b983e27

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Re-added a flag to prevent the IME from showing"
2 parents ad6283e + 3473b2b commit b983e27

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

core/java/android/widget/Editor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public class Editor {
151151
boolean mShowErrorAfterAttach;
152152

153153
boolean mInBatchEditControllers;
154+
boolean mShowSoftInputOnFocus = true;
154155

155156
SuggestionsPopupWindow mSuggestionsPopupWindow;
156157
SuggestionRangeSpan mSuggestionRangeSpan;
@@ -1437,7 +1438,7 @@ boolean startSelectionActionMode() {
14371438
}
14381439

14391440
final boolean selectionStarted = mSelectionActionMode != null || willExtract;
1440-
if (selectionStarted && !mTextView.isTextSelectable()) {
1441+
if (selectionStarted && !mTextView.isTextSelectable() && mShowSoftInputOnFocus) {
14411442
// Show the IME to be able to replace text, except when selecting non editable text.
14421443
final InputMethodManager imm = InputMethodManager.peekInstance();
14431444
if (imm != null) {

core/java/android/widget/TextView.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,27 @@ public void setHighlightColor(int color) {
23112311
}
23122312
}
23132313

2314+
/**
2315+
* Sets whether the soft input method will be made visible when this
2316+
* TextView gets focused. The default is true.
2317+
* @hide
2318+
*/
2319+
@android.view.RemotableViewMethod
2320+
public final void setShowSoftInputOnFocus(boolean show) {
2321+
createEditorIfNeeded("setShowSoftInputOnFocus");
2322+
mEditor.mShowSoftInputOnFocus = show;
2323+
}
2324+
2325+
/**
2326+
* Returns whether the soft input method will be made visible when this
2327+
* TextView gets focused. The default is true.
2328+
* @hide
2329+
*/
2330+
public final boolean getShowSoftInputOnFocus() {
2331+
// When there is no Editor, return default true value
2332+
return mEditor == null || mEditor.mShowSoftInputOnFocus;
2333+
}
2334+
23142335
/**
23152336
* Gives the text a shadow of the specified radius and color, the specified
23162337
* distance from its normal position.
@@ -4981,7 +5002,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
49815002
&& mLayout != null && onCheckIsTextEditor()) {
49825003
InputMethodManager imm = InputMethodManager.peekInstance();
49835004
viewClicked(imm);
4984-
if (imm != null) {
5005+
if (imm != null && getShowSoftInputOnFocus()) {
49855006
imm.showSoftInput(this, 0);
49865007
}
49875008
}
@@ -7014,7 +7035,7 @@ public boolean onTouchEvent(MotionEvent event) {
70147035
// Show the IME, except when selecting in read-only text.
70157036
final InputMethodManager imm = InputMethodManager.peekInstance();
70167037
viewClicked(imm);
7017-
if (!textIsSelectable) {
7038+
if (!textIsSelectable && mEditor.mShowSoftInputOnFocus) {
70187039
handled |= imm != null && imm.showSoftInput(this, 0);
70197040
}
70207041

0 commit comments

Comments
 (0)