summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2021-01-22 21:51:34 +0000
committerTony Mak <tonymak@google.com>2021-01-29 13:19:53 +0000
commit90e8a19f7c6d2fe2da69ce113ddae4efa6ef6279 (patch)
tree2173999643645391b33a315588c96658e754f5b8 /core/java
parent7ee87037f51e651e43c207c67582b36999b3de4a (diff)
Do not invoke textclassifier when dimissing the selection
Problem: When dismissing the selection by clicking the TextView, invalidateActionModeAsync is called to ask text classifier to generate a new smart action for the selected text. It is not necessary because the selection is going to be dismissed. Cause: To update the smart action chip when a user adjusts the selection span by dragging the selection handle, we call showFloatingToolbar() when we get an ACTION_UP event. The problem is that we also get an ACTION_UP event when user dismisses the seletion by clicking the textview. In that case, we don't need to update the smart action chip or show the floating toolbar. Solution: Only call ShowFloatingToolbar() when we get an ACTION_UP and also the user is modifying the selection/insertion curosr. Test: Added a test in TextViewIntegrationTest. Test: Manual. Input a long phone number. Change the selection span to select fewer digits. Click "Call" and check the prefilled number. Test: Manual. Drag the insertion curosr(w EditText), floating toolbar is reshown when lifting the finger. Fixes: 169042542 Change-Id: Ic398a8521d99218b14689fe0668adc22e6b143c5
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/Editor.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 26dd5e309fa7..012352d0a0f5 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -1705,15 +1705,23 @@ public class Editor {
}
private void updateFloatingToolbarVisibility(MotionEvent event) {
- 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:
+ 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())) {
showFloatingToolbar();
- }
+ }
}
}