summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Stingaceanu <stg@google.com>2015-05-12 12:39:07 +0100
committerAndrei Stingaceanu <stg@google.com>2015-05-12 12:54:25 +0100
commiteeb9afc78f5f0770b5a311f97d7b0702fdf81e28 (patch)
tree84b43f51287efebe3b071b91e70547aef024aec2
parent5a7587fa90732c013bb9266f1bdae0a557455c15 (diff)
downloadframeworks_base-eeb9afc78f5f0770b5a311f97d7b0702fdf81e28.zip
frameworks_base-eeb9afc78f5f0770b5a311f97d7b0702fdf81e28.tar.gz
frameworks_base-eeb9afc78f5f0770b5a311f97d7b0702fdf81e28.tar.bz2
Fix: replace terminates extract mode (floating toolbar)
Moved the replace action to be triggered from the TextView rather than the Editor. Previously the ExtractedEditText was calling the TextView.onTextContextMenuItem which did not hold an entry for replace and thus was returning false. Note: this CL does not fix the extracted mode being (randomly) terminated when edit actions are pressed. This is still under investigation. Bug: 20930071 Change-Id: I71f87418f040f6860fe7723e4cd731c298cf3c5f
-rw-r--r--core/java/android/widget/Editor.java18
-rw-r--r--core/java/android/widget/TextView.java6
2 files changed, 13 insertions, 11 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 2e36cee..cf1ff17 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -286,6 +286,13 @@ public class Editor {
mUndoManager.redo(owners, 1); // Redo 1 action.
}
+ void replace() {
+ int middle = (mTextView.getSelectionStart() + mTextView.getSelectionEnd()) / 2;
+ stopSelectionActionMode();
+ Selection.setSelection((Spannable) mTextView.getText(), middle);
+ showSuggestions();
+ }
+
void onAttachedToWindow() {
if (mShowErrorAfterAttach) {
showError();
@@ -3185,10 +3192,6 @@ public class Editor {
mCustomSelectionActionModeCallback.onActionItemClicked(mode, item)) {
return true;
}
- if (item.getItemId() == TextView.ID_REPLACE) {
- onReplace();
- return true;
- }
return mTextView.onTextContextMenuItem(item.getItemId());
}
@@ -3262,13 +3265,6 @@ public class Editor {
}
}
- private void onReplace() {
- int middle = (mTextView.getSelectionStart() + mTextView.getSelectionEnd()) / 2;
- stopSelectionActionMode();
- Selection.setSelection((Spannable) mTextView.getText(), middle);
- showSuggestions();
- }
-
/**
* A listener to call {@link InputMethodManager#updateCursorAnchorInfo(View, CursorAnchorInfo)}
* while the input method is requesting the cursor/anchor position. Does nothing as long as
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 68c49cd..8826fce 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9014,6 +9014,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
stopSelectionActionMode();
return true;
+ case ID_REPLACE:
+ if (mEditor != null) {
+ mEditor.replace();
+ }
+ return true;
+
case ID_SHARE:
shareSelectedText();
return true;