summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-01-27 11:02:18 -0800
committerGilles Debunne <debunne@google.com>2011-01-27 12:55:28 -0800
commit17d31decef349b4f6026b41a7425a4e64940aef5 (patch)
treeddcb92cefbfe46141366fd9136f5d6bb133e0252 /core/java/android
parentce3b35a7b0b80061692d9fa1977cee68b365728c (diff)
downloadframeworks_base-17d31decef349b4f6026b41a7425a4e64940aef5.zip
frameworks_base-17d31decef349b4f6026b41a7425a4e64940aef5.tar.gz
frameworks_base-17d31decef349b4f6026b41a7425a4e64940aef5.tar.bz2
Soft keyboard is not shown when text selection mode is aborted.
Bug 3381317 Also generalized and uniformized the use of peekInstance. Added null tests, and isActive tests before hiding. Change-Id: Ifd1a053fd920841333e0ebab3e2a8d26b469a0f6
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/widget/TextView.java38
1 files changed, 17 insertions, 21 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b024dcb..b217052 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3320,7 +3320,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} else if (actionCode == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
+ if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
return;
@@ -4822,9 +4822,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mOnClickListener == null) {
if (mMovement != null && mText instanceof Editable
&& mLayout != null && onCheckIsTextEditor()) {
- InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(this, 0);
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0);
}
}
}
@@ -4877,7 +4876,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// No target for next focus, but make sure the IME
// if this came from it.
InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
+ if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
}
@@ -7149,10 +7148,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// the IME. Showing the IME while focus is moved using the D-Pad is a bad idea, however this
// does not happen in that case (using the arrows on a bluetooth keyboard).
if (focused && isTextEditable()) {
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
- imm.showSoftInput(this, 0, null);
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0, null);
}
}
@@ -7346,10 +7343,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Show the IME, except when selecting in read-only text.
if (!mTextIsSelectable) {
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
- handled |= imm.showSoftInput(this, 0, csr) && (csr != null);
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ handled |= imm != null && imm.showSoftInput(this, 0, csr) && (csr != null);
}
stopSelectionActionMode();
@@ -8247,16 +8242,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
selectCurrentWord();
}
- if (!mTextIsSelectable) {
- // Show the IME, except when selection non editable text.
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(this, 0, null);
- }
-
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
mSelectionActionMode = startActionMode(actionModeCallback);
- return mSelectionActionMode != null;
+ final boolean selectionStarted = mSelectionActionMode != null;
+
+ if (selectionStarted && !mTextIsSelectable) {
+ // Show the IME to be able to replace text, except when selecting non editable text.
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0, null);
+ }
+
+ return selectionStarted;
}
/**