Skip to content

Commit 3473b2b

Browse files
author
Gilles Debunne
committed
Re-added a flag to prevent the IME from showing
Revert of CL 161404 This flag will be used by the dialer. It prevents any IME from showing as a result of a focus given to a TextView through a tap or a D-Pad click. Change-Id: Ifa5bfcbff124b300780f76dea443d26cf172f5e3
1 parent 70c8723 commit 3473b2b

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;
@@ -1407,7 +1408,7 @@ boolean startSelectionActionMode() {
14071408
}
14081409

14091410
final boolean selectionStarted = mSelectionActionMode != null || willExtract;
1410-
if (selectionStarted && !mTextView.isTextSelectable()) {
1411+
if (selectionStarted && !mTextView.isTextSelectable() && mShowSoftInputOnFocus) {
14111412
// Show the IME to be able to replace text, except when selecting non editable text.
14121413
final InputMethodManager imm = InputMethodManager.peekInstance();
14131414
if (imm != null) {

core/java/android/widget/TextView.java

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

2316+
/**
2317+
* Sets whether the soft input method will be made visible when this
2318+
* TextView gets focused. The default is true.
2319+
* @hide
2320+
*/
2321+
@android.view.RemotableViewMethod
2322+
public final void setShowSoftInputOnFocus(boolean show) {
2323+
createEditorIfNeeded("setShowSoftInputOnFocus");
2324+
mEditor.mShowSoftInputOnFocus = show;
2325+
}
2326+
2327+
/**
2328+
* Returns whether the soft input method will be made visible when this
2329+
* TextView gets focused. The default is true.
2330+
* @hide
2331+
*/
2332+
public final boolean getShowSoftInputOnFocus() {
2333+
// When there is no Editor, return default true value
2334+
return mEditor == null || mEditor.mShowSoftInputOnFocus;
2335+
}
2336+
23162337
/**
23172338
* Gives the text a shadow of the specified radius and color, the specified
23182339
* distance from its normal position.
@@ -5030,7 +5051,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
50305051
&& mLayout != null && onCheckIsTextEditor()) {
50315052
InputMethodManager imm = InputMethodManager.peekInstance();
50325053
viewClicked(imm);
5033-
if (imm != null) {
5054+
if (imm != null && getShowSoftInputOnFocus()) {
50345055
imm.showSoftInput(this, 0);
50355056
}
50365057
}
@@ -7060,7 +7081,7 @@ public boolean onTouchEvent(MotionEvent event) {
70607081
// Show the IME, except when selecting in read-only text.
70617082
final InputMethodManager imm = InputMethodManager.peekInstance();
70627083
viewClicked(imm);
7063-
if (!textIsSelectable) {
7084+
if (!textIsSelectable && mEditor.mShowSoftInputOnFocus) {
70647085
handled |= imm != null && imm.showSoftInput(this, 0);
70657086
}
70667087

0 commit comments

Comments
 (0)