Introduce TextSelection.Builder.setIncludeTextClassification and...
Introduce TextSelection.Builder.setIncludeTextClassification and TextSelection.getTextClassification() This small API change enables us to optimize the latnecy of smart selection. To enable smart selection, TextView/WebView always call textClassifier.suggestSelection and textClassifier.classifyText back to back. There are a lot of overlaps between suggestSelection and classifyText, e.g. both API calls classify the entity type of the text. This optimization is important to make smart selection working responsively, especially that we enforce a 200ms timeout in TextView. This small API change allows the TextClassifier to implement smart selection with just one single API call. This change is backward-compatible. If the text classifier is not updated to return the text classification result in suggestSelection yet, clients can learn that by checking if textSelection.getTextClassification() returns null. If so, the client can then fallback to call ClassifyText(). You may find the textview integration in ag/13092679 Design doc: go/android-s-suggestselection Bug: 173512834 Test: atest TextSelectionTest Change-Id: If4cc827aa19d6d14c885cf10cd5ba16aa3041cf6
Loading
Please register or sign in to comment