summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Mak <tonymak@google.com> 2021-05-12 16:47:48 +0000
committer Tony Mak <tonymak@google.com> 2021-05-24 11:47:56 +0000
commitc103424e3ac05ca38783ba9a1a0cfae3c2e973fe (patch)
tree5438c3027a21d1f50d8ccf7e12de0ff027809311
parent90e8a19f7c6d2fe2da69ce113ddae4efa6ef6279 (diff)
Revert "Do not invoke textclassifier when dimissing the selection"
Reverting ag/13435448. The bug that the change fixed was that TextView invokes classifyText when the selection is going to be dimissed due to an ACTION_UP event. The fix was that we only call showFloatingToolbar() if users are dragging the selection curosr when we get an ACTION_UP event. QA has found a bug recently. When user selects some text and then scrolls the TextView, we hide the floating toolbar temporarily. When user finishes scrolling, TextView does not reshow the toolbar immediately due to the fix. I don't have a fix that I feel comfortable to get into S given that we are pretty late in the process, so reverting the fix. Some more details: IMO, the fix should be calling showFloatingToolbar() only if TextView has a selection(i.e. TextView.hasSelection()) when we are processing the ACTION_UP event in updateFloatingToolbarVisibility(). Sadly, it does not work because the selection is not actually dismissed yet when we are trying to update the visiblity of the floating toolbar in updateFloatingToolbarVisibility(). The selection is actually dismissed when Editor.onTouchUpEvent is called to handle the UP event, but updateFloatingToolbarVisibility() is called before that :/ Moving around the code so that updateFloatingToolbarVisibility() is called after Editor.onTouchEvent() may work, but I am not comfortable to get in a risky change like this at the moment. Reason for revert: b/187862341 Bug: 187862341 Change-Id: Ic49c6792dc86c01fcc78a4d3bc5bfd85b7772197
-rw-r--r--core/java/android/widget/Editor.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 012352d0a0f5..26dd5e309fa7 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -1705,23 +1705,15 @@ public class Editor {
}
private void updateFloatingToolbarVisibility(MotionEvent event) {
- if (mTextActionMode == null) {
- return;
- }
- switch (event.getActionMasked()) {
- case MotionEvent.ACTION_MOVE:
- hideFloatingToolbar(ActionMode.DEFAULT_HIDE_DURATION);
- break;
- case MotionEvent.ACTION_UP: // fall through
- case MotionEvent.ACTION_CANCEL:
- final SelectionModifierCursorController selectionController =
- getSelectionController();
- final InsertionPointCursorController insertionController = getInsertionController();
- if ((selectionController != null && selectionController.isCursorBeingModified())
- || (insertionController != null
- && insertionController.isCursorBeingModified())) {
+ if (mTextActionMode != null) {
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_MOVE:
+ hideFloatingToolbar(ActionMode.DEFAULT_HIDE_DURATION);
+ break;
+ case MotionEvent.ACTION_UP: // fall through
+ case MotionEvent.ACTION_CANCEL:
showFloatingToolbar();
- }
+ }
}
}