Merge "Stop text selection mode when new text replaces selection." into honeycomb
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index cc5be00..7675e0c 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4780,7 +4780,6 @@
}
hideControllers();
- stopSelectionActionMode();
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
@@ -5119,6 +5118,7 @@
if (mInputMethodState != null) {
mInputMethodState.mExtracting = req;
}
+ // This stops a possible text selection mode. Maybe not intended.
hideControllers();
}
@@ -6781,7 +6781,7 @@
sendOnTextChanged(buffer, start, before, after);
onTextChanged(buffer, start, before, after);
- // Hide the controller if the amount of content changed
+ // Hide the controllers if the amount of content changed
if (before != after) {
hideControllers();
}
@@ -8207,9 +8207,12 @@
selectCurrentWord();
}
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(this, 0, null);
+ 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);
@@ -8233,6 +8236,7 @@
private void stopSelectionActionMode() {
if (mSelectionActionMode != null) {
+ // This will hide the mSelectionModifierCursorController
mSelectionActionMode.finish();
}
}
@@ -8356,8 +8360,12 @@
if (mCustomSelectionActionModeCallback != null) {
mCustomSelectionActionModeCallback.onDestroyActionMode(mode);
}
- Selection.setSelection((Spannable) mText, getSelectionStart());
- hideSelectionModifierCursorController();
+ Selection.setSelection((Spannable) mText, getSelectionEnd());
+
+ if (mSelectionModifierCursorController != null) {
+ mSelectionModifierCursorController.hide();
+ }
+
mSelectionActionMode = null;
}
}
@@ -9173,16 +9181,12 @@
}
}
- private void hideSelectionModifierCursorController() {
- // No need to create the controller to hide it.
- if (mSelectionModifierCursorController != null) {
- mSelectionModifierCursorController.hide();
- }
- }
-
+ /**
+ * Hides the insertion controller and stops text selection mode, hiding the selection controller
+ */
private void hideControllers() {
hideInsertionPointCursorController();
- hideSelectionModifierCursorController();
+ stopSelectionActionMode();
}
/**