summaryrefslogtreecommitdiff
path: root/core/java/android/widget/SelectionActionModeHelper.java
Commit message (Collapse)AuthorAgeFilesLines
* Fix the empty selection issue when onCreateActionMode returns falseTony Mak2022-02-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | One of the optimizations ag/12911059 did was calling SelectionModifierCursorController.show() before startActionModeInternal(). The rationale was that if we start the action mode first, SelectionModifierCursorController.show() would end up invalidating the action mode twice unnecessarily, once for each handle. However, with this optimization, we are calling SelectionModifierCursorController.show() even when onCreateActionMode returns false. Reverted this particular optimization to fix the issue. Added a test which was failing without this fix but passing with it. Fixes: 199380016 Fixes: 214341747 Test: atest TextViewActivityTest Change-Id: I793f76a23978cbbbbde2d16e8a522615174bcdd5
* Merge "Notify Content Capture when deselected" into sc-devTYM Tsai2021-07-021-0/+1
|\
| * Notify Content Capture when deselectedTYM Tsai2021-06-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Notify Content Capture with the text changed event when deselected. Bug: 184311217 Test: manual 1.long press trigger selection, event is sent. 2.drag selection indicators, send event after the drag is done. 3.deselecting, event is sent. Test: atest CtsContentCaptureServiceTestCases Change-Id: I3d05b8e798bfb5b213817b36f163aab0a688bdf4
* | Notify Content Capture the selection was changedTYM Tsai2021-06-171-0/+2
|/ | | | | | | | | | | | | The ContentCapture service is interested in the selection changes. When the selection was changed, notifies a text changed event to ContentCapture. Bug: 184311217 Test: manual 1.long press trigger selection, event is sent. 2.drag selection indicators, send event after the drag is done. Test: atest CtsContentCaptureServiceTestCases Change-Id: Ie45f617b132bc240b6cf61ee7ebc3041275f1694
* Make SelectionActionModeHelper hardcoded constants configurable.Joanne Chung2021-03-021-10/+16
| | | | | | | | | | | | | | | | | | Read the selection timeout value from ViewConfiguration, ViewConfiguration is statically configurable by the OEM. OEMs can set the value which works on their device before shipping it. After privacy sync, we can make the selection context size configurable by DeviceConfig but we need to provide a reasonable upper bound. The value is 240 after experiment. Bug: 169042855 Test: atest CtsTextClassifierTestCases Test: atest CtsWidgetTestCases:TextViewTest Test: atest android.widget.TextViewActivityTest Test: manual. Changes values by command and checks the values. Change-Id: I59346fdc3b482bca586c13ba6c653d1e9b593922
* Integrate the SuggestSelection API in TextViewTony Mak2020-12-021-0/+3
| | | | | | | | | Fixes: 173512834 Test: atest cts/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java Change-Id: Ice57e69bf173b45ea2dded5cb7585c0710aeecc7
* Always swallow the IllegalStateException from AsyncTask.Chang Li2020-11-271-23/+6
| | | | | | | | | | | | | Because we use suppliers for TextClassifier, the mTextClassificationHelper::isTextClassifierDestroyed actually always returns false. Always swallows the exception temporarily to unblock other teams. We may want to keep a reference of the TCSession in the AsyncTask and check it ideally (b/174300371). Bug: 174300371 Fix: 172627102 Test: atest AccessibilityTextTraversalTest.java Change-Id: I5988db992956d666e24e608cd99d4fc87fd6820b
* Conditionally swallows Exceptions from TextClassificationAsyncTask.Chang Li2020-11-231-5/+28
| | | | | | | | | | | | | | | | | | After ag/12036126, the AsyncTask may throw RuntimeException if we destroy the TCSession before it is done. However, this kind of Exception should be swallowed silently because we do not need the result anymore. In b/172627102, the test fails because we perform a cut action to the text immediately after we trigger a selection. The cut action will destroy and TCSession and thus cause a session-already-destroyed Exception in the AsyncTask. With this, we will check whether the Text Classifier has already been destroyed and therefore can fix it. Bug: 172627102 Fix: 172627102 Test: atest AccessibilityTextTraversalTest.java Change-Id: Ia2ca04a06e97858cd897e5d35f707f5edeee56cf
* Reduce the latency between the selection span is adjusted and the toolbar is ↵Tony Mak2020-11-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | shown Results: We measure the latency between Editor.startActionModeInternal is called and FloatingToolbar.show() is called. When there is only smart action (url) Before: ~150ms After ~30ms When there are 5 smart actions (phone number) Before: ~400ms After: ~100ms Before and after videos: https://recall.googleplex.com/projects/ea8c4705-96bd-46f0-9f37-786708050727 Fixed a few issues: 1. updateAssistMenuItems() gets the Icons from TextClassification object, calls loadDrawable on them and creates the MenuItem objects loadDrawable() is slow, especially if we have a lot of smart action icons to load. Even worse, we are calling this function 4 times in a row when selecting something! 1 time from onCreateActionMode and 3 times from onPrepareActionMode. The fix here is to avoid reloading the drawable if it is the same text classification object. 2. From SelectionActionModeHelper, we call startActionModeInternal before SelectionModifierCursorController.show() Internally, SelectionModifierCursorController.show() show the two selection handles by calling startHandle.show() and endHandle.show(). Apparently, each handle.show() call invalidates the action model right after it is just created! This explains two of the unnecessary onPrepareActionModel calls. The fix is to call SelectionModifierCursorController.show() before startActionModeInternal() is called. 3. Editor.startActionModeInternal() does not invoke FloatingToolbar.show() right away. There are two issues here. a) Editor.startActionModeInternal() ends up calling FloatingActionModel.repositionToolbar() which hopefully calls FloatingToolbar.show(). Sadly, it is not the case because mViewRectOnScreen is not set at that time. mViewRectOnScreen is set in next onPreDrawCall() call. b) When mViewRectOnScreen is finally set and calls repositionToolbar() again , it still won't call FloatingToolbar.show() immediately because we think that the toolbar is moving by comparing the previous content rect and the current content rect. They are different because the previous one is empty(it wasn't shown before). Becoz we think it is moving, we schedule the FloatingToolbar.show() call after 50ms. To fix a, we now update mViewRectOnScreen() right away wihout waiting for the next onPreDraw call(). To fix b, when the previous content rect is moving, we don't consider the toolbar as moving anymore. Bug: 169043706 Test: atest android.widget.TextViewActivityTest Test: atest cts/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java Test: atest cts/tests/tests/widget/src/android/widget/cts/TextViewTest.java Test: Smart select a phone number and then smart select a link. Make sure the smart actions menuitems are updated. Test: Click on a smart linkify link. Then dismiss it by tapping outside. Change-Id: I634b21ac7ed66a14883dc17e03ef006df5b3f223
* Merge "Fix typos related to sortSelectionIndices" am: 5247f04147 am: 7a42f1c980Treehugger Robot2020-07-081-13/+13
|\ | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1355842 Change-Id: Iec31622cc351a635b8d590b2509523167141d32c
| * Fix typos related to sortSelectionIndicesWang Han2020-07-061-13/+13
| | | | | | | | | | | | Bug: 160555160 Change-Id: I2710e10776a4f6f633abc14d6898c186b5a01124
| * Fix app crash if the selection is from reverse direction.Joanne Chung2020-07-061-17/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When user types some text and then long presses on end of empty area to open context menu, if user opens Gboard and selects text from the reverse direction, SelectionEnd will be less than SelectionStart. The IllegalArgumentException occurred because TextClassification does not allow SelectionEnd is less than SelectionStart. We swap the start and end index if end index is less than start index. Bug: 150916165 Bug: 157452302 Test: Manual. No crash occurs. Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest (cherry picked from commit cb3c97db0cf21df076735d71c573a754fa4ef072) Merged-In: I8dbc92f0f31e64b7e3a45ae91762e1b741629a8e Change-Id: Ie0e2b5840e147f98174cae4521eb777e1a080706
| * Hold a strong reference to the callback in TextClassifierServiceTony Mak2019-08-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: TextClassifierService failed to invoke the callback to send the result back to client occasionally because the callback object may be GCed. And thus smart selection failed occasionally, as the client doesn't get a response back when it hits this issue. It won't fallback to local textclassifier due to the timeout specified in TextView. Cause: We thought that ITextClassifierCallback is a "cross process" reference, and so we only store a weak reference of it to avoid leak. And it turns out that it is wrong. As soon as the weak ref gets GCed in the service, that counts as dropping the callback. The service doesn't know about any strong references the client has. Bug: 138865849 Test: Try smart selection over 30 times, make sure smart action is shown for every single time. Merged-In: Ia9218cf67e8d67697a0fdff22c7918a55efc39ca Change-Id: I4d89518dfff777ba5d999d9ba89d7f4cf7598e75
* | Disable language logging in TextClassifier/TranslateEventTony Mak2020-06-081-1/+2
| | | | | | | | | | | | | | Bug: 158481016 Test: atest android.widget.cts.TextViewTest Test: atest tests/tests/textclassifier/src/android/view/textclassifier/cts Change-Id: I7e9ea69f67858714a7fd3b0d06ad1b88000999e0
* | Merge "Use TextClassicationSession to call smart selection APIs." into rvc-devTreeHugger Robot2020-04-291-2/+2
|\ \
| * | Use TextClassicationSession to call smart selection APIs.Tony Mak2020-04-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to use TextClassicationSession to send us logging only (i.e. onSelectionEvent()). Now we use TCSession to call smart selection APIs (i.e. suggestSelection and classifyText). This allows the TCS to obtain the session ID in onSuggestSelection and onClassifyText. BUG: 149077320 Test: atest TextViewActivityTest Test: Try a few smart selections and log the sessionID of each TC APIs. Change-Id: I320249735aa08fb7e8612060955b2aa5496da94b
* | | Fix app crash if the selection is from reverse direction.Joanne Chung2020-04-161-18/+55
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | When user types some text and then long presses on end of empty area to open context menu, if user opens Gboard and selects text from the reverse direction, SelectionEnd will be less than SelectionStart. The IllegalArgumentException occurred because TextClassification does not allow SelectionEnd is less than SelectionStart. We swap the start and end index if end index is less than start index. Bug: 150916165 Test: Manual. No crash occurs. Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest Change-Id: I8dbc92f0f31e64b7e3a45ae91762e1b741629a8e
* | Remove local text classifier and related tests.Tony Mak2020-03-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. libtextclassifier and libtextclassifier-java are no longer built into framework/base. 2. Removed local text classifier code 3. Removed local text classifier test code. All of them should be already moved to libtextclassifier/tcs side. 4. Unify all the TC related log tags to "androidtc". BUG: 147412216 Test: mts-tradefed run mts-extservices Test: atest frameworks/base/core/java/android/view/textclassifier Test: Sanity test: Smart selection Change-Id: Icb1076153f51d5674c8a6c58681ffed5aa772149
* | Replace com.android.internal.util.Preconditions.checkNotNull withDaulet Zhanguzin2020-01-031-11/+11
| | | | | | | | | | | | | | | | | | | | java.util.Objects.requireNonNull Bug: 126528330 Test: Treehugger Exempt-From-Owner-Approval: Global refactoring. Change-Id: Idf0949bd58a73bef2b5f3ecb6b99b2be2d1059c4
* | Hold a strong reference to the callback in TextClassifierServiceTony Mak2019-08-221-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | Issue: TextClassifierService failed to invoke the callback to send the result back to client occasionally because the callback object may be GCed. And thus smart selection failed occasionally, as the client doesn't get a response back when it hits this issue. It won't fallback to local textclassifier due to the timeout specified in TextView. Cause: We thought that ITextClassifierCallback is a "cross process" reference, and so we only store a weak reference of it to avoid leak. And it turns out that it is wrong. As soon as the weak ref gets GCed in the service, that counts as dropping the callback. The service doesn't know about any strong references the client has. Bug: 138865849 Test: Try smart selection over 30 times, make sure smart action is shown for every single time. Change-Id: Ia9218cf67e8d67697a0fdff22c7918a55efc39ca
* Split TextClassifierEvent into multiple subclassesAbodunrinwa Toki2019-04-161-3/+2
| | | | | | | | | | | | | As per the suggestion from API council, we now have a subclass for event of each category. Bug: 129344540 Test: atest frameworks/base/core/tests/coretests/src/android/view/textclassifier/ Test: atest cts/tests/tests/view/src/android/view/textclassifier/cts/ Test: atest frameworks/base/packages/ExtServices/tests/src/android/ext/services/notification/SmartActionsHelperTest.java Change-Id: Ic43b33c2176447c40e64bd0e410e906d5fb9c4cc
* Log translate action's views and clicks.Abodunrinwa Toki2019-01-311-9/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This logs a "view" event for the translate action *once* for each selection session that involves a foreign language. It logs a "click" action when the translate action is clicked. The logged action index will give an indication of whether the translate action was the primary action (index 0) and thus immediately visible to the user or whether it was one of the secondary actions (index > 0) and possibly in the selection toolbar's overflow. Bug: 123414932 Bug: 120837847 Test: atest core/tests/coretests/src/android/view/textclassifier Test: atest cts/tests/tests/view/src/android/view/textclassifier Test: atest android.widget.TextViewTest Test: atest android.widget.cts.TextViewTest Test: (MANUAL): 1. Ensure device has an app that supports Intent.ACTION_TRANSLATE 2. Run the following command on the shell: adb logcat -c "TCEventTronLogger" 3. Select some foreign lanugage text in a TextView 4. Click on "Translate" item on the toolbar 5. Observe that the device logs a "view" and a "click" event 6. Repeat 3 7. Click on a different menu item, e.g. "Copy" 8. Observe that the device logs only a "view" event Change-Id: I36f32459c577cf8f8bcf1e65960c4e6d7ffa5e01
* Do not linkify text with RLO/LRO characters.Abodunrinwa Toki2018-11-271-12/+7
| | | | | | | | | | | | | Also don't show smart actions for selections in text with unsupported characters. Bug: 116321860 Test: atest android.view.textclassifier.TextClassifierTest \ android.text.util.cts.LinkifyTest \ android.text.util.LinkifyTest \ android.widget.TextViewActivityTest Change-Id: Id271cab8aef6b9b13ef17f1a8654c7616f75cf13
* Fix monkey crash in smart selection animationMihai Popa2018-05-251-2/+6
| | | | | | | | | | | | | In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash happening when the smart selected text had changed while the smart selection animation was running. However, the change introduced a new crash, happening when the smart selection result was null. This CL fixes it, and lets startSelectionActionMode run even when the result is null, as there seems to be some logic there which should happen in this case. Bug: 80244201 Test: none Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
* Merge "Cheaper crash check post smart selection animation"TreeHugger Robot2018-05-221-2/+2
|\
| * Cheaper crash check post smart selection animationMihai Popa2018-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the end of the smart selection animation, we run a callback that sets the selection on the TextView (subsequently starting the action mode toolbar and showing the handles). However, when the text changes before the animation finishes, the selection might not be valid, and might get out of the text bounds, which was producing a crash. This was initially fixed in Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa, by checking whether the text has not changed since the animation started. The fix was implying one text copy and a potentially full text comparison, being unnecessary costly. This CL instead only checks whether the selection is still within the text bounds when animation ends. Bug: 69919777 Test: manual testing before and after the fix Change-Id: Id65443e93d277c106ea955c867d39e94192cc55d
* | Merge "End the TC session on terminal selection event actions" into pi-dev ↵Abodunrinwa Toki2018-05-221-23/+33
|\ \ | |/ |/| | | | | | | | | | | am: d0a4dddb9b am: 6826a4ab53 Change-Id: Ifca422285ca1faa681e0b761efedc0a2bfb31561
| * Merge "End the TC session on terminal selection event actions" into pi-devTreeHugger Robot2018-05-221-23/+33
| |\
| | * End the TC session on terminal selection event actionsAbodunrinwa Toki2018-05-221-23/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This regressed when introducing TC sessions in I3c9ceea0863099fc4f0a5ce5e823c648ee9c4521 When the user triggers a terminal selection event such as "Copy", we should immediately end the session instead of waiting for the "Abandon" event (i.e. selection dismissed) to be included in the logs. Terminal selection events implicitly dismiss a selection and we'd rather distiguish between an actual "selection dismiss" from one that happened because of a "terminal" selection event. This cl also removes the "*" marker used to distinguish the new logging from the old ones. The code for the old logging has already been deleted so no more need for a marker. Bug: 78541105 Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Change-Id: Iac7d45dbc63e7076683742bd045766a1d927cfc9
| * | Merge "Fix crash after smart selection animation" into pi-devMihai Popa2018-05-221-1/+6
| |\ \ | | |/ | |/|
| | * Fix crash after smart selection animationMihai Popa2018-05-221-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the end of the smart selection animation, we run a callback that sets the selection on the TextView (subsequently starting the action mode toolbar and showing the handles). However, when the text changes before the animation finishes, the selection might not be valid, and might get out of the text bounds, which was producing a crash. This was observed in a monkey crash. This CL fixes this bug by refusing to set the selection when it goes outside the text bounds, corresponding to the case when text has changed between the time the animation has started and the time it ended. Bug: 69919777 Test: manual testing before and after the fix Change-Id: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa (cherry picked from commit cce6e82d35b5a6c8eb29e76fbae53eae8b70e99a) Merged-in: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa
* | | Merge "Refresh TCM settings when they change" into pi-dev am: 3fa564030fAbodunrinwa Toki2018-05-171-9/+12
|\| | | | | | | | | | | | | | | | | am: f08646f13e Change-Id: I2a7fc61dac52817b053a680b82c18514f76ec6b8
| * | Refresh TCM settings when they changeAbodunrinwa Toki2018-05-171-9/+12
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Approach here is to register a content observer that invalidates the TC settings whenever updates to the settings happen. This CL also ensures that the TC is invalidated when a settings update happens. This is because the settings may change what TC the system returns. TextView's SelectionActionModeHelper has been updated to not cache the settings and get them directly from TCM (which caches the settings). NOTE that we expect TC settings to rarely change. Bug: 77539576 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: manual - Made changes to TC settings and observed logs / app behaviour Change-Id: I88bbb6f951708b17323fac1a72385fe808d270a5
* / Fix crash after smart selection animationMihai Popa2018-05-091-1/+6
|/ | | | | | | | | | | | | | | At the end of the smart selection animation, we run a callback that sets the selection on the TextView (subsequently starting the action mode toolbar and showing the handles). However, when the text changes before the animation finishes, the selection might not be valid, and might get out of the text bounds, which was producing a crash. This was observed in a monkey crash. This CL fixes this bug by refusing to set the selection when the text has changed between the time the animation has started and the time it ends. Bug: 69919777 Test: manual testing before and after the fix Change-Id: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa
* Fix broken target SDK checks.Jeff Sharkey2018-04-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Consider an app targeting the final API 28, but running on an older build where "P" is still API 10000. Those apps need to be treated as legacy apps. In general, the logical pattern that should be used when enforcing target SDK behaviors is below. For applying behavior to legacy apps: // BROKEN if (targetSdkVersion <= Build.VERSION_CODES.N_MR1) { // CORRECT if (targetSdkVersion < Build.VERSION_CODES.O) { For applying behavior to new apps: // BROKEN if (targetSdkVersion > Build.VERSION_CODES.N_MR1) { // CORRECT if (targetSdkVersion >= Build.VERSION_CODES.O) { Bug: 77865751 Test: builds, boots Change-Id: Ia83bd446a940751d51a6542c7a5b9cca174c5296
* Remove legacy loggerJan Althaus2018-04-071-22/+2
| | | | | | | | | | | | | | | | | | Migrate DefaultLogger implementation to SelectionSessionLogger. This cleans up after the API refactor and fixes two bugs: - All events are currently logged twice. - Interfaces accept a null signature, but it currently crashes the legacy logger. Bug: 73392698 Bug: 77659305 Test: atest FrameworksCoreTests:TextClassificationManagerTest Test: atest FrameworksCoreTests:TextClassificationTest Test: atest CtsViewTestCases:TextClassificationManagerTest Test: atest CtsViewTestCases:TextClassifierValueObjectsTest Test: atest CtsWidgetTestCases:TextViewTest Test: atest CtsWidgetTestCases:EditTextTest Test: Manually examined logs Change-Id: I0d2b925abf5cab12d71fc2cc0fa527530c86ab10
* TextClassifier API updates.Abodunrinwa Toki2018-04-011-41/+52
| | | | | | | | | | | | | | | | | | | | | 1. Wraps TC queries in Request objects 2. Adds create/destroyTextClassificationSession system APIs 3. Adds the session Ids to system API calls 4. Change setSignature() to setId() on result objects 5. Plumbing to make the API updates work as things currently work 6. Hide Linkify.addLinksAsync APIs Bug: 74461129 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationTest Test: bit FrameworksCoreTests:android.view.textclassifier.TextSelectionTest Test: bit FrameworksCoreTests:android.view.textclassifier.TextLinksTest Change-Id: I933ada8b37ef9893331a265e3b4fc08e043f1029
* Merge "Implement Stateful TextClassifier APIs." into pi-devAbodunrinwa Toki2018-03-281-18/+48
|\
| * Implement Stateful TextClassifier APIs.Abodunrinwa Toki2018-03-281-18/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Outstanding work tbd in other CLs - Introduce request objects with session Ids - Implement character based indexing for Selection events. This CL hides the old Logger API but still keeps running so that we can check that the modifications to the new API does not break anything. We will remove the old Logger once we're convinced this is stable. Please refer to I3c9ceea0863099fc4f0a5ce5e823c648ee9c4521 for previous reviews related to this CL. Bug: 74461129 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Change-Id: Iea744f1fa5964b4399290c31863ebeffa99af8d3
| * Fix smart_linkify_enabled flag.Abodunrinwa Toki2018-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The flag should only ensure that smart linkify calls behave in the legacy way instead of totally disabling linkify. Also, to keep the flag consistent with smart_selection_enabled and smart_text_share_enabled flags, the flag should only disable the SmartLinkify (i.e. Linkify.addLinksAsync) feature not TextClassifier APIs (i.e. TextClassifier.generateLinks). Also fixes issue with non-focusable TextViews by firing the primary action instead of showing the floating toolbar. (b/73156794) Bug: 75967597 Bug: 73156794 Test: bit FrameworksCoreTests:android.text.util.LinkifyTest Test: bit CtsTextTestCases:android.text.util.cts.LinkifyTest Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: manual - checked behaviour turning flag on/off Test: manual - checked behaviour with TextView.setFocusableInTouchMode(true/false) Change-Id: I541f60161b9cd63ce7e57235607500f2fb0841e7
* | Fix random SmartLinkify-related TextView bugs.Abodunrinwa Toki2018-03-261-10/+21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Preserve selection when the TC times out. (See: SelectionActionModeHelper) 2. Fix highlight/toolbar flicker when tapping on a smart link. - Highlight flicker happening because we reset the selection while in the process of starting a link action mode. i.e. onLinkDown: show highlight onLinkUp: start the link action mode asynchronously onLinkUp: reset the selection to an insertion cursor* onLinkActionModeStarted: reset the highlight *Fix: Don't reset selection while starting a link action mode. - Toolbar flicker happening because the toolbar positions itself over the current selection. The way link highlights have traditionally been done is to set the selection to the links bounds* *Fix: Hide the toolbar for a few milliseconds when changing selection for smoother transition. 3. Fix Paste menu overriding link action mode toolbar after a recent "Copy" action. The Paste menu appearing is a feature. Whenever the user inserts a cursor after just copying some text, we show the Paste menu as a way to make it easy for the user to select the text. Because of the problem described in (2) above, changing the selection to an insertion triggers the Paste menu feature. Fixing (2) fixes this. 4. Fix IME popping up on non-selectable + focusable TextViews. See: imm.showSoftInput(...) in Editor. And see comment in the code around that. We should only pop up the IME for editable text. Fixes: 73872461 Fixes: 75985239 Fixes: 76011461 Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Change-Id: If9ddb7f4e6d4db480ba4a495a22f7f2924ab937e
* TextClassifierService.onSelectionEventAbodunrinwa Toki2018-03-121-0/+3
| | | | | | | | | Bug: 74466564 Bug: 67609167 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit FrameworksCoreTests:android.view.textclassifier.logging.SelectionEventTest Merged-In: Ib5af1ec80a38432d1201fbc913acdc3597d6ba82 Change-Id: Ib5af1ec80a38432d1201fbc913acdc3597d6ba82
* Merge textclassifier/logging/ into textclassifier/Abodunrinwa Toki2018-03-101-2/+2
| | | | | | | | | | | | | | This is based on feedback on Ib5af1ec80a38432d1201fbc913acdc3597d6ba82 Bug: 74466564 Bug: 67609167 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.LoggerTest Merged-In: Ic8d58acb2bbd63cedcac4aa16940b4ac852aadc8 Change-Id: Ic8d58acb2bbd63cedcac4aa16940b4ac852aadc8
* Don't use highlighting in non-selectable text. Also fixes potential ↵Richard Ledley2018-03-061-11/+6
| | | | | | | | | discrepancy in indexes for Linkified entities. Test: atest CtsWidgetTestCases:TextViewTest FrameworksCoreTests:android.widget.TextViewActivityTest CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest FrameworksCoreTests:android.view.textclassifier.TextLinksTest Change-Id: Ib479afa9af2b921e6a217a34322a766561867b79 (cherry picked from commit bda1d9e740f2a1db186baedc41524cd2d56d145a)
* Associate TCconstants with the TCM instead of TCImplAbodunrinwa Toki2018-02-281-15/+16
| | | | | | | | | | | | Also updates flags list. Bug: 72946306 Bug: 72946123 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationConstantsTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Change-Id: I8af9d3d1da01836fbadcbbf6ce7c1c0db7456a05
* Merge "Logging for linkify selections"TreeHugger Robot2018-02-121-6/+15
|\
| * Logging for linkify selectionsJan Althaus2018-02-051-6/+15
| | | | | | | | | | | | Bug: 67629726, 70246800 Test: Manually validated, ran CTS tests, and framework tests Change-Id: Icd41f1e171767bc466f47c87a6ab611185745fd4
* | Updating smart text selection animationJan Althaus2018-02-051-2/+6
|/ | | | | | | | Now animates the highlight itself as opposed to an outline. Bug: 70540865 Test: Manually tested it with single and multi-line - ltr and rtl Change-Id: I8afee259c9952fcff0b713bca62c82a1022f2b0d
* Implement TextClassifier.getLogger APIAbodunrinwa Toki2018-01-311-39/+46
| | | | | | | | | | | | | | | | | | | | - Introduces getLogger() API. - A logger should run in the client's process. This helps us manage sessions specific to a client. - The logger exposes a tokenizer that clients may use to tokenize strings for logging purposes. - Logger subclasses need to provide a writeEvent() implementation. - SelectionEvent is serializable over IPC. - Logger takes care of the session management. It writes session specific information into the SelectionEvent. - We still keep the SmartSelectionEventTracker for now so clients can slowly move off of it. The plan is to delete it. - The plan is to include support other event types. e.g. link events. Bug: 64914512 Bug: 67609167 Test: See topic Change-Id: Ic9470cf8f969add8a4c6570f78603d0b118956cd
* Introduce a TextClassifierManagerService.Abodunrinwa Toki2018-01-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Apps wanting to use a TextClassifier service (instead of an in-app-process TextClassifier) bind to this service. The service binds to and reroutes calls to a configured system TextClassifierService. TextClassifierManagerService manages the lifecycle of the configured TextClassifierService and binds/unbinds to preserve system health. A configurable TextClassifierService extends TextClassifierService, declares an android.textclassifier.TextClassifierService intent, and requires a permission that is only granted to the system so only the system may bind to it. The TextClassifierManagerService implements a similar interface to TextClassifierService (i.e. ITextClassifierService) but doesn't have to. This is done for simplicity sake and things may change in the future. The configuration of the default service is in config.xml. OEMs may change this with a config overlay. If no TextClassifierService is specified, the default in app process TextClassifierImpl is used. Bug: 67609167 Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest Test: tbd Change-Id: I8e7bd6d12aa1a772897529c3b12f47f48757cfe6