summaryrefslogtreecommitdiff
path: root/core/java/android/widget/SpellChecker.java
Commit message (Collapse)AuthorAgeFilesLines
* Send TYPE_VIEW_TEXT_CHANGED a11y event when SuggestionSpan is addedyingleiw2021-11-171-3/+20
| | | | | | | | | | | | | | | | When user types space after a word, we receive a text change event, but the suggestion span is not added to the text yet. The spell checker adds the span after the text change event is sent. Previously we send the event in onSpanAdded in TextView, but we don't do anything or update the before text for span removed. This is a bit confusing and error prone. This change moves the send event logic into spell checker. Bug: b/143378480 Test: tested with talkback. Change-Id: Ibd45843494304602b177df8da520a51058989f10
* Merge "Fix a bug in sentence detection when input is too long." into sc-devTreeHugger Robot2021-05-251-2/+2
|\
| * Fix a bug in sentence detection when input is too long.Qi Wang2021-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | When the unchecked length of the current sentence is too long, the spell checker should check the first MAX_SENTENCE_LGNTH characters of the unchecked part. In this case, detectSentenceBOundary should return [textChangesStart, textChangeStart + MAX_SENTENCE_LENGTH) Fix: 188875278 Test: manual test Change-Id: I31847aed2d564f7bc1ff43c83adae3bb7c99c0d1
* | Fix a bug in SpellCheckSpan update logic.Qi Wang2021-05-211-6/+12
|/ | | | | | | | | | | | | | | The the text is changed, we need to remove all affected SpellCheckSpan. However, the previous check logic can not work correctly, and may leave some out-of-date SpellCheckSpan, which causes problem when the SpellChecker tries to apply suggestions on those spans later. Also fixed the bug that the offset is not calculated correctly when we validate spell checker suggestions. Fix: 188107864 Change-Id: I8dc806d96b6a75255277d6de013305557835cb6d Test: atest CtsInputMethodTestCases:SpellCheckerTest Test: atest android.widget.cts.TextViewTest
* Validate spell checker suggestions before applying.Qi Wang2021-04-261-1/+4
| | | | | | Fix: 185786752 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: Icf447fc3ab174bc17af0e823b830f5abef6071df
* Revert^2 "Introduce SpellCheckerSessionParams."Kohsuke Yatoh2021-04-201-3/+6
| | | | | | | Updated test added in commit 7000b5f89d8c43af5ccd116c1840ea89dd9f17dc Bug: 179804789 Change-Id: I48c744815662cabcbef8e823916b1e6bba9c9b17
* Revert "Introduce SpellCheckerSessionParams."Yi-yo Chiang2021-04-201-6/+3
| | | | | | | | | | | | | Revert "Use SpellCheckerSessionParams in CTS." Revert submission 14191185-ky-tsm Reason for revert: breaks build test_suites_x86_64 b/185855437 Reverted Changes: I724aaad15:Introduce SpellCheckerSessionParams. I510a4cfec:Use SpellCheckerSessionParams in CTS. Change-Id: I4173bd5bee62f02a248de69df77420c39326b9f0
* Introduce SpellCheckerSessionParams.Kohsuke Yatoh2021-04-171-3/+6
| | | | | | | | | SpellCheckerSessionParams encapsulates parameters for TextServicesManager#newSpellCheckerSession(). Bug: 179804789 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I724aaad15b0a4bd38f6a24585c4c45cfeee5b499
* Fix the SuggestionSpan overwrite logic.Qi Wang2021-03-251-27/+31
| | | | | | | | | | | | | | | | | | | | Previously, the SpellChecker use the start and end positions as the key to maintain the SuggestionSpan cache. However, the actual start/end position of the SuggestionSpan may changes when the text is changed. Hence we may not be able to find the corresponding SuggestonSpan for a new suggestion with the changed start/end positions. In this fix, we deprecated the cache and use Spanned#getSpans to find overlapped spans instead. Change-Id: I1e732f335ad745d85a7620e3ced6858551f18232 Fix: 182982338 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I327e5163499cfc978ff8480664a7e728b6ea7249
* Add Executor param to TSM#newSpellCheckerSession().Kohsuke Yatoh2021-03-151-6/+6
| | | | | | | | | | | SpellCheckerSessionListener callback methods will be called on the provided executor. This CL also adds more description for 'bundle' parameter. Bug: 179804789 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I43f9f04fc335ad45d2580f4711b19aee214bc7dd
* Respect sentence boundary when doing spell check.Qi Wang2021-03-111-56/+193
| | | | | | | | | | | | | Introduces SentenceIterator into android.widget.SpellChecker and uses it to detect the start/end of spell check range instead of using a fixed length. Fix: 179125303 Fix: 179124679 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: If6dd044e24dcaa58381949c221a5f9af57a4104f
* Clean up: Remove mIsSentenceSpellCheckSupported since it is always true.Chenxi Ni2021-02-031-198/+100
| | | | | | Bug: 179223118 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: Ic47a6aee5fb29a9549ecd72c5a5a6aea889ad74b
* Fix InputConnection#performSpellCheck logic:Chenxi Ni2021-02-011-23/+35
| | | | | | | | | | - Change to trigger full content spell check when calling InputConnection#performSpellCheck. - When calling InputConnection#performSpellCheck, forces to do spell check even user is editing the word. Bug: 177947314 Test: atest CtsInputMethodTestCases:SpellCheckerTest Test: Manually test the add to dictionary case with Gboard Change-Id: I4f7c2e638e517fe91776ef0a285ee20e4cdc9a92
* Add supportedAttributes param for spell checker.Kohsuke Yatoh2021-01-201-1/+5
| | | | | | Bug: 166304720 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I22f4a59a0c8ccb43f799351062f9fabca42403cd
* Add RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS.Kohsuke Yatoh2020-12-171-1/+6
| | | | | | Bug: 166304720 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I2f5796d899c79ea1cd6795c16f2011389ae7afea
* Add InputConnection#performSpellCheck().Kohsuke Yatoh2020-12-151-0/+21
| | | | | | | | | IME can use this method to redo spell checking after it has learned a new user dictionary word. Bug: 166304720 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I956cd46f25bb77b7e1a6a3e1478c0d7efa1a056a
* Add API to differentiate grammar suggestions.Kohsuke Yatoh2020-10-051-3/+13
| | | | | | | | | | The following attributes are added for grammar suggestions. - SuggestionSpan#FLAG_GRAMMAR_ERROR - SuggestionsInfo#RESULT_ATTR_LOOKS_LIKE_GRAMMAR_ERROR Bug: 166304720 Test: atest CtsInputMethodTestCases:SpellCheckerTest Change-Id: I0e5da3125d28bb881e513d0d69e0a2d336a9f286
* Introduce @hide TextView#setTextOperationUser()Yohei Yukawa2019-01-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | This CL introduces a unified way for framework developers to specify whose components should be interacting with the given TextView. An important use case is the direct-reply UI notification hosted in System UI, which always runs as user 0 no matter who is the current user. For instance, to let the given EditText interact with user 10's input methods and spell checkers, you can call setTextOperationUser() as follows. editText.setTextOperationUser(UserHandle.of(10)); In this way we can easily propergate the same user ID to other components such as autofill and text classifer as necessary in the future. No one calls TextView#setTextOperationUser() yet hence there should be no user-visible behavior change. Bug: 120744418 Bug: 123043618 Test: spell checker still works Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: I6d11e4d6a84570bc2991a8552349e8b216b0d139
* Lazily request spell checker sessionYohei Yukawa2018-06-111-2/+3
| | | | | | | | | | | | | | | | | | | Currently when an EditText is attached to a Window, one spell checker session will be immediately requested even when that EditText is empty. This is not efficient, especially for notification with direct reply. With this CL, EditText does not request spell checker session while it is empty. Basically this doesn't cause any user-visible behavior change. Bug: 109701487 Fix: 37434131 Test: Run 'adb shell dumpsys textservices' to make that a new spell checker session is established not when a notification with direct reply is posted but when the user actually starts replying on that notification. Change-Id: Iee04f4c0e2d248041d01c528344b191b9875d122
* Expand characters temporarily skipped in spellcheckingRoozbeh Pournader2016-12-191-8/+9
| | | | | | | | | | | | | | | An earlier patch (I4d09576a31df551c96f820242fd2cbc675506dae) special-cased apostrophe as a character to defer spellchecking on, since it could cause a word break which could later get removed. This patch updates that earlier patch to include all characters that could cause such a behavior according the Unicode word breaking algorithm defined in UAX #29. Bug: 17641350 Bug: 17673522 Test: manual Change-Id: I4029e3d91dfcf96665b003f6fdd30d1208b0ac7c
* Add a check for invalid spans being set by SpellChecker.Roozbeh Pournader2015-03-111-5/+1
| | | | | | | | | | | One of the exit conditions of the loop immediately above the code is when a BreakIterator finishes its input and emits BreakIterator.DONE, which we were then mistakenly then using as a parameter for setting spans. Bug: 12936072 Bug: 5555929 Change-Id: Ib4aba113f2e7838cd040076160c1dd0fb90adb1a
* Defer spelling correction with apostropheRaph Levien2014-09-261-2/+8
| | | | | | | | | | | | When typing a contraction (such as "doesn't") we don't want a spell right after the apostrophe, as this will create a false temporary red underline, and the span split also breaks a kern pair causing text to shift. This patch detects the case where the cursor is immediately after such a word and suppresses correction in that case. Bug: 17641350 Change-Id: I4d09576a31df551c96f820242fd2cbc675506dae
* Allow TextInfo to store ParcelableSpans for TextServiceYohei Yukawa2014-06-301-9/+6
| | | | | | | | | | This CL adds a new constructor of TextService so that spell parcelable spans can be preserved in TextInfo. The primary usage scenario is to provide locale information for spell checker service. BUG: 15869548 Change-Id: Ib58ece68dee4c6187d469049fca8c35a307c7a01
* Uses VMRuntime.newUnpaddedArray for ideal array sizesAdam Lesinski2014-03-271-14/+7
| | | | | | Bug:13028925 Change-Id: I0a9301248b10a339afbdc5e4ffe3310ac4fa1fb7
* Prevent SpellChecker from setting invalid rangeJay Shrauner2014-02-071-1/+5
| | | | | | | | Add check for invalid range before setting for further check at end of parse() loop. Bug:12936072 Change-Id: Ie0b33b8e69fe47e5d3371640be5681f13a4e4f6e
* Fix an issue where "SuggestionSpan"s are not removed properlySatoshi Kataoka2013-06-051-0/+35
| | | | | | | | Basically, the root cause of this issue is a lack of an expected implementation. This change completes the spec of the architecture to remove modified "SuggestionSpan"s. Bug: 9190860 Change-Id: I63f2ccf3407ae7c1bc28813e044b8703e2112f34
* Fix an issue on changing the keyboard locale between spellchecking supported ↵Satoshi Kataoka2012-12-061-6/+9
| | | | | | | language to non-supported language Bug: 7658675 Change-Id: Ia2353f299506b5871e0104594e4486b6ab1ffa82
* Merge "Minor changes in SpellCheckSpan pool management in SpellChecker" into ↵Gilles Debunne2012-05-151-8/+10
|\ | | | | | | jb-dev
| * Minor changes in SpellCheckSpan pool management in SpellCheckerGilles Debunne2012-05-091-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 6464190 The 'inProgress' flag is set to false when the SpellCheckSpan starts to get used (instead of a less intuitive when it is removed). Pool recycling in handled by onSpellCheckSpanRemoved, called from the TextView's SpanWatcher, when a SpellCheckSpan is removed for any reason (from the SC code or due to text editing). The other change is that Sentence SC now correctly removes the span from the text (and hence recycles it in the pool). Change-Id: If8b433fd5e41d4dc0304a127ebcc088ea1eecaa7
* | Allow the spell checker to remove existing misspelled spanssatok2012-05-111-0/+30
| | | | | | | | | | Bug: 6451163 Change-Id: If018533e8855e9dc21ab2a09ae31aa80ef260b72
* | Add a safety net to set range span in the spell checkersatok2012-05-111-2/+12
| | | | | | | | | | Bug: 6476578 Change-Id: I60ad82f80770dcb67fd9663dac64dc81634d7014
* | Merge "Spell checker underlines words even when there are no suggestions" ↵Gilles Debunne2012-05-091-10/+10
|\ \ | | | | | | | | | into jb-dev
| * | Spell checker underlines words even when there are no suggestionsGilles Debunne2012-05-081-10/+10
| |/ | | | | | | | | | | | | | | Bug 6222722 Also fixed a cast to Long warning. Change-Id: Ief299cc3cb952b83f774ca1be13dc69352015a3e
* / Not to add invalid spell check spanssatok2012-05-091-0/+3
|/ | | | | | Bug: 6464197 Change-Id: I6e9d359847b200e2afae61f85eb7cfe7f179b888
* DO NOT MERGE. Backport If36b8a69e7fa22e837c99d Fix the issue that the spell ↵satok2012-05-071-34/+110
| | | | | | check doesn't start when the user changes the cursor position by touch Change-Id: I1535eae23efc42660b9d1e6dbfba6c800b0302b2
* Fix the boundary of the sentence level spell checksatok2012-04-261-4/+11
| | | | | Bug: 6400290 Change-Id: Ifb3b2f4034a1717369c63206611e5b6c441fded5
* Merge "Editor uses a SpanWatcher to track EasyEditSpans"Gilles Debunne2012-04-241-2/+3
|\
| * Editor uses a SpanWatcher to track EasyEditSpansGilles Debunne2012-04-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Will also fix Bug 6344997 The previous TextWatcher mechanism was inneficient. It require an expensive getSpans() call to retrieve all the spans and then search for the one we're interested in in case it has been changed. The SpanWatcher is faster, it will broadcast the add/changed/removed events we're interested in. Now that we can rely on SpanWatcher, use it to directly track addition and removals of EasyEditSpans. No unit test for this feature which require an integration with the voice IME. Easy to test manually though. Change-Id: Idabcacc48c479bf9868d5204c0b0ca709207ede2
* | Fix the first boundary of the sentence level spell checksatok2012-04-231-2/+4
| | | | | | | | Change-Id: I7c7659c921103d31f9909c14850088aef0d2eb19
* | Optimize the timing to query sentence level spell checkingsatok2012-04-181-1/+23
| | | | | | | | | | Bug: 6354647 Change-Id: I52e6c21387c7f4d6fc05b4c50bbb0a5a6c75194b
* | Get rid of "isSentenceLevelSpellCheckSupported"satok2012-04-161-1/+1
|/ | | | | Bug: 6320351 Change-Id: I0e931b7248f8c65268b60af599c07432d58d2f1f
* Faster and simpler replace in SSB, take twoGilles Debunne2012-04-091-6/+7
| | | | | | | | | | | | | | | | This is a new version of CL 179343 which had to be reverted. This problem of the previous CL is that the ComposingSpan that was part of the replacement text was correctly added during the replace but was immediately removed because it had a zero-length size. Swapping the add and remove blocks solves the problem. The new non-zero length enforcement also revealed a bug in the spell checker where we were creating useless range spans. Change-Id: I59cebd4708af3becc7ab625ae41bc36837f1a1cf
* Merge "Optimization of the request of the sentence level spell check"satok2012-03-081-0/+4
|\
| * Optimization of the request of the sentence level spell checksatok2012-03-081-0/+4
| | | | | | | | Change-Id: Ic89b0dd027bf0af6e8f1877043ae40baed48b2a4
* | Merge "Fix spell checker framework"satok2012-03-081-2/+2
|\|
| * Fix spell checker frameworksatok2012-03-081-2/+2
| | | | | | | | Change-Id: I281d031259dd220936832668e7a4556473ccb2ce
* | Fix possible NPE in SpellCheckersatok2012-03-081-1/+7
|/ | | | Change-Id: Ib3c9fe7189c8f31a460149add857e9855919f386
* Handle sentence level spell checking hidden APIssatok2012-03-011-84/+165
| | | | Change-Id: Ia91f1771c0b8ef458dd5b023f4c372cc36a15657
* Refactor sentence level spell checking APIssatok2012-02-221-2/+3
| | | | | | Support sentence level spell checking APIs: Step 1 Change-Id: I31c0b88e7885f33a0694ab60b8f2dbceeffe42f1
* Minor typo fixesGilles Debunne2012-02-131-1/+2
| | | | Change-Id: I8cd9500cc50b7a484bf387e6a6a0c9b4ffb175a4