Merge "Bug 5228934: added a flag to disable the display of the soft input on focus"
This commit is contained in:
committed by
Android (Google) Code Review
commit
19f4b66ddc
@@ -357,6 +357,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
private SpellChecker mSpellChecker;
|
private SpellChecker mSpellChecker;
|
||||||
|
|
||||||
|
private boolean mShowSoftInputOnFocus = true;
|
||||||
|
|
||||||
// The alignment to pass to Layout, or null if not resolved.
|
// The alignment to pass to Layout, or null if not resolved.
|
||||||
private Layout.Alignment mLayoutAlignment;
|
private Layout.Alignment mLayoutAlignment;
|
||||||
|
|
||||||
@@ -605,6 +607,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
mLinksClickable = a.getBoolean(attr, true);
|
mLinksClickable = a.getBoolean(attr, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// TODO uncomment when this attribute is made public in the next release
|
||||||
|
// also add TextView_showSoftInputOnFocus to the list of attributes above
|
||||||
|
// case com.android.internal.R.styleable.TextView_showSoftInputOnFocus:
|
||||||
|
// setShowSoftInputOnFocus(a.getBoolean(attr, true));
|
||||||
|
// break;
|
||||||
|
|
||||||
case com.android.internal.R.styleable.TextView_drawableLeft:
|
case com.android.internal.R.styleable.TextView_drawableLeft:
|
||||||
drawableLeft = a.getDrawable(attr);
|
drawableLeft = a.getDrawable(attr);
|
||||||
break;
|
break;
|
||||||
@@ -2367,6 +2375,29 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
return mLinksClickable;
|
return mLinksClickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the soft input method will be made visible when this
|
||||||
|
* TextView gets focused. The default is true.
|
||||||
|
*
|
||||||
|
* @attr ref android.R.styleable#TextView_showSoftInputOnFocus
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@android.view.RemotableViewMethod
|
||||||
|
public final void setShowSoftInputOnFocus(boolean show) {
|
||||||
|
mShowSoftInputOnFocus = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the soft input method will be made visible when this
|
||||||
|
* TextView gets focused. The default is true.
|
||||||
|
*
|
||||||
|
* @attr ref android.R.styleable#TextView_showSoftInputOnFocus
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public final boolean getShowSoftInputOnFocus() {
|
||||||
|
return mShowSoftInputOnFocus;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of URLSpans attached to the text
|
* Returns the list of URLSpans attached to the text
|
||||||
* (by {@link Linkify} or otherwise) if any. You can call
|
* (by {@link Linkify} or otherwise) if any. You can call
|
||||||
@@ -5465,7 +5496,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
&& mLayout != null && onCheckIsTextEditor()) {
|
&& mLayout != null && onCheckIsTextEditor()) {
|
||||||
InputMethodManager imm = InputMethodManager.peekInstance();
|
InputMethodManager imm = InputMethodManager.peekInstance();
|
||||||
viewClicked(imm);
|
viewClicked(imm);
|
||||||
if (imm != null) {
|
if (imm != null && mShowSoftInputOnFocus) {
|
||||||
imm.showSoftInput(this, 0);
|
imm.showSoftInput(this, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8303,7 +8334,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
// Show the IME, except when selecting in read-only text.
|
// Show the IME, except when selecting in read-only text.
|
||||||
final InputMethodManager imm = InputMethodManager.peekInstance();
|
final InputMethodManager imm = InputMethodManager.peekInstance();
|
||||||
viewClicked(imm);
|
viewClicked(imm);
|
||||||
if (!mTextIsSelectable) {
|
if (!mTextIsSelectable && mShowSoftInputOnFocus) {
|
||||||
handled |= imm != null && imm.showSoftInput(this, 0);
|
handled |= imm != null && imm.showSoftInput(this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10116,7 +10147,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
final boolean selectionStarted = mSelectionActionMode != null ||
|
final boolean selectionStarted = mSelectionActionMode != null ||
|
||||||
extractedTextModeWillBeStartedFullScreen;
|
extractedTextModeWillBeStartedFullScreen;
|
||||||
|
|
||||||
if (selectionStarted && !mTextIsSelectable && imm != null) {
|
if (selectionStarted && !mTextIsSelectable && imm != null && mShowSoftInputOnFocus) {
|
||||||
// Show the IME to be able to replace text, except when selecting non editable text.
|
// Show the IME to be able to replace text, except when selecting non editable text.
|
||||||
imm.showSoftInput(this, 0, null);
|
imm.showSoftInput(this, 0, null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user