aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a bug on rotation with selection.Jean Chalard2014-06-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The symptom : when text is selected and the device is rotated, sometimes the keyboard sets the word as being composed around the start of the selection. Upon the next rotation this ends up with the keyboard committing some text in place of the selection. The cause : another bug in the framework with rotation >.> The keyboard receives a call to startInput with a wrong cursor position, namely one that does not represent a selection. The keyboard sets a composition according to this wrong data. When the keyboard is rotated again, it commits the text, which takes the place of the selection. The solution : actually when restarting input the keyboard realizes that the cursor position is wrong. We cancel composition at that time. For robustness, this change also implements two other defensive changes : upon call to onUpdateSelection, we actually realize that the previous values were wrong, so we also fix it at that time, and in addition, when rotating, we finishComposingText() instead of commitText() which is less dangerous. Implementing this later change also allows us to let less internal variables from InputLogic escape to LatinIME, so it's also a good change for design. Bug: 14140799 Change-Id: Ib10de18e53e376ac1bbc8487e13d969828483346
* Make prevWord = null if the next word starts from a connector.Keisuke Kuroyanagi2014-05-301-1/+17
| | | | | | | | | | This fixes PunctuationTests# testAutoCorrectionWithSingleQuotesAround. Bug: 14119293 Bug: 15334309 Change-Id: I604c21a21e89a5fc431fd56ab7b6ad03f4736b01
* Remove researcher loggerTadashi G. Takaoka2014-05-291-32/+0
| | | | | | | This CL must be checked in together with I5cc76807e3. Bug: 15318007 Change-Id: I61423c3377ddc299fb332e742d6626c2e47145bb
* Introduce EMPTY_PREV_WORDS_INFO and BEGINNING_OF_SENTENCE.Keisuke Kuroyanagi2014-05-231-6/+6
| | | | | Bug: 14119293 Change-Id: I5020e5f0aa64bc3e97b3a3c2c07a60c8b765ed64
* Add beginning of sentence information in PrevWordsInfo.Keisuke Kuroyanagi2014-05-211-21/+34
| | | | | | Bug: 14119293 Bug: 14425059 Change-Id: I65320920e840082b0b697bb621676716d0933e0c
* Rework the logic that tells if the cursor touches wordsJean Chalard2014-03-201-7/+17
| | | | | Bug: 13312942 Change-Id: I6be6a558bbc6c88508150f9c25cadbd0240ff88e
* Don't reset the value needed before it's usedJean Chalard2014-03-101-2/+2
| | | | | | | Nice recipe for failure Bug: 13387534 Change-Id: Ida1978449c1997587b2ec0955c5c94fcef336121
* Never pass negative values to setSelection.Jean Chalard2014-02-241-2/+6
| | | | | Bug: 13136079 Change-Id: Ieae6bafbd5339a033f0f342ba9af7dcc4ce209fa
* Change a heuristic and add a log.Jean Chalard2014-02-201-3/+3
| | | | | | | | | | | | | | | | | | | The heuristic in RichInputConnection makes little sense when textLength > mExpectedSelStart but we have more than 1024 characters of text. If there are that many, it's about 100% sure that 1024 is not the correct cursor position. With no good guess, we'll just continue trusting the app, even though we know it's lying : at least it will make the problem visible to the app author. Also, there have been a lot of confusion about initialSelStart and initialSelEnd. The keyboard should log them so that it helps us and editor authors debug more easily these common problems. Issue #65170 in AOSP and Bug: 12772035 Change-Id: I6665a16c9f2832d33ee323f033bb38bcc092a3b4
* Don't distrust the cursor pos so much as to bug on IPC delayJean Chalard2014-02-201-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the cursor is moved by the user, the RichInputConnection is told about it. However, to work around a framework bug, it also looks at how many characters are in the buffer before the cursor, and if that's more than the value it's been passed, it deduces that's a framework bug and there are at least as many characters as seen before the cursor, so it puts the expected cursor position there. When you move the cursor, TextView calls onUpdateSelection, and when you move it fast, you'll get rapid-fire calls to onUpdateSelection. This is fine, the RIC is equipped to deal with that. However, these calls take some time to make it to the IME. In this instance, when the first call gets through and the IME calls TextView (synchronously) for text before the cursor, the cursor has already moved in the app, and TextView returns more characters than the cursor position was declared to be in this instance, so the RIC sets that as the expected cursor position. Sure enough, a split second later, the second call to onUpdateSelection arrives, with the new cursor position set where the RIC had found it too early. The RIC takes that as an "expected" cursor move, and the input does not get reset. Luckily, we have a way out. As far as we know, the framework bug only manifests itself upon rotation, which means we should only have to adjust for it in onStartInputView. Doing it in onUpdateSelection is too zealous (and probably too distrustful of the app to send the correct cursor positions). So we should just take care of the rotation case (by calling tryFixLyingCursorPosition in onStartInputView) and remove the compensating code in resetCachesUponCursorMoves. Bug: 12982502 Change-Id: Ic3c1408a1ec45deaea63b01d98376a79ae567d77
* Comments improvementsJean Chalard2014-02-201-2/+2
| | | | | | Typo fixes and clarifications Change-Id: I0f7e0b6e665232bb995172fff10521c7f17599eb
* Fix a bug where the cache would be out of syncJean Chalard2014-02-181-1/+17
| | | | | | | | | | | | | During recorrection, the cursor position when calling commitText is not necessarily at the end of the composing text. Besides, RichInputConnection assumes the cursor is always after any composing text. This is not correct, but in the practice, it seems all code paths work. We should fix this in the future. Bug: 13060691 Change-Id: I15f71fff62d36e80cf6e4a022c5e78af634b199d
* Don't resume suggestion on links.Jean Chalard2014-02-171-1/+5
| | | | | Bug: 11447084 Change-Id: I5bd558b9dd85d1505aa918f44e8ac3e52ec42d97
* Try to figure out whether d.quotes open or close.Jean Chalard2014-01-271-0/+11
| | | | | Bug: 8911672 Change-Id: I5d5635949530a67f95e5208986907251b7bce903
* Use sorted int[] to represent word separatorsTadashi G. Takaoka2014-01-201-10/+11
| | | | Change-Id: I4103541d99fe59bfcf12379a1298a0a690497846
* Refactor RichInputConnection a bitTadashi G. Takaoka2014-01-171-28/+27
| | | | Change-Id: I866488a47ca04ca587e805663dfd597bb7b1ebce
* [IL54] Add a mirror method to fix the cursor pos estimateJean Chalard2014-01-101-5/+55
| | | | | | | This just mirrors what InputLogic#tryFixLyingCursorPosition is doing. That method will go away in the next change. Change-Id: Ifa2827dbc1f1d20e2c642d6f2d23514a01ed9203
* [IL53] Fix a wrong test.Jean Chalard2014-01-101-5/+7
| | | | | | | | | | | | | | | | | | This test was intended only for cases without a selection, and as a safety net for cases where the app would pretend the cursor is at N but we can get P chars from the editor where P > N. When there is a selection, this is wrong. In the practice it works because these values are not used in this case, but it's still wrong. The case where P > N is arguable, but actually I see little reason to trust the getTextBeforeCursor() method more than the onUpdate selection method. Plus in the practice, I don't think we are aware of any app with this bug, and it's probably not a great idea to be too robust about this as it may encourage wrong values sent to onUpdateSelection. Change-Id: I42f2065d7aee668074e6b8e40b259da7e88e16e1
* Passing SpacingAndPunctuations to RichInputConnection.getNthPreviousWordsTadashi G. Takaoka2014-01-091-5/+7
| | | | Change-Id: I174c50f509ed6998b755e1a712e7f6c0f82f4425
* Passing SpacingAndPunctuations to CapsModeUtils.getCapsModeTadashi G. Takaoka2014-01-091-2/+1
| | | | Change-Id: I0b06e8cc75a403f7061864c5b7f3f6a2cacd60eb
* Fix a race condition, take 2.Jean Chalard2014-01-081-0/+4
| | | | | | | | | | Don't use absolute cursor positions when making edits, this leads to race conditions. This is a bit ugly and will need to be fixed soon. Plans are underway to clean this up. Bug: 12390573 Change-Id: I69c09fc41b979880d0800c55a710e39373287cff
* Revert "Fix a race condition, take 2."Jean Chalard2014-01-081-4/+0
| | | | | | | | Conflicts prevent this to be cherry-picked. This reverts commit dd3d697a6e6713d82020dd63cbf78e4f87664484. Change-Id: Ib97fae2234633b4bb27d611f48a79060db9ab16f
* Fix a race condition, take 2.Jean Chalard2014-01-081-0/+4
| | | | | | | | | | Don't use absolute cursor positions when making edits, this leads to race conditions. This is a bit ugly and will need to be fixed soon. Plans are underway to clean this up. Bug: 12390573 Change-Id: Ib42d4149343c642b1b5c1937b424e8afdbd4cc1f
* [IL52] Remove a useless method.Jean Chalard2013-12-271-39/+0
| | | | | | | | | | | | | | | This old method doesn't even re-read the old suggestions. It used to recompute them without the coordinates. Re-using the recorrection code, which is much more advanced, is the right thing to do here. Also, refining the test. It's no use trying to resume suggestion if we don't have a suggestion strip, since we aren't going to auto-correct anything anyway. Not the motivation for this change, but this also fixes Bug: 11620256 Change-Id: Id49efa32e293c49837c61fdc752c86bbac1d2c88
* Reset to 9bd6dac4708ad94fd0257c53e977df62b152e20cKen Wakasa2013-12-131-76/+137
| | | | | | The bulk merge from -bayo to klp-dev should not have been merged to master. Change-Id: I527a03a76f5247e4939a672f27c314dc11cbb854
* Fix many small nits.Jean Chalard2013-11-121-2/+6
| | | | | | | ...the interaction of which results in a very bad bug. Bug: 11648854 Change-Id: I774489e384388f187e72b9ac091ab387c5e1a79a
* Stopgap solution for a crash.Jean Chalard2013-10-221-1/+8
| | | | | | | | | This returns the wrong string, but since it's used for getting the previous word for bigrams, it only results in slightly worse suggestions quality. Bug: 11273655 Change-Id: I6ce5de2f76effc453ca691a654ab6bf17445b9e7
* Make the sentence separator a resource.Jean Chalard2013-10-081-4/+4
| | | | | | | This will help handing correctly the armenian full stop. Bug: 10082781 Change-Id: Id7bb219ebd89daba203216eab362d1cc26a65a36
* Fix the offdevice regression test buildKen Wakasa2013-09-251-2/+4
| | | | | | | Followup to If4e44eca3cdc5bb02cf2e0c8c44ecd4bf27fae57 bug: 10622489 Change-Id: If98b2c75725f8692f0c2b41c33e448086404479b
* Copy only the spans we are interested in.Jean Chalard2013-09-241-2/+5
| | | | | | | | | The PARAGRAPH type of span is dangerous, as concatenating CharSequences that contain it may crash. We also don't use other spans than SuggestionSpans, so we don't copy them. Bug: 10622489 Change-Id: If4e44eca3cdc5bb02cf2e0c8c44ecd4bf27fae57
* Detect cases where rotation messes with initializationJean Chalard2013-09-201-12/+49
| | | | | | | | ...and do a best effort to fix it. Bug: 10323080 Bug: 10252066 Change-Id: Icb3c9fe85005406bdfce0b7bb143ba0a910a0ddb
* Fix a bug where null would be converted to "null"Jean Chalard2013-09-201-2/+4
| | | | | | | | It's unclear what the concrete effects of this are, but they are not very strong. This only happens in corner cases, when the input connection is not active - while rotating, for example. Change-Id: I1d22459a6e94a8ecccb53cfcbc2d301b1d502204
* Fix cursor state bugKurt Partridge2013-08-211-1/+0
| | | | | | | InputConnection#finishComposingText() should not change the position of the cursor, so neither should it change its internal expectation of the cursor's position. Change-Id: Ib3d39a5743cd1e8e356f438b04a5c30279430b2a
* Have double-space-to-period cancel leave a single spaceJean Chalard2013-08-081-2/+4
| | | | | Bug: 8911898 Change-Id: Ifb4bb63c14dc960d0a53f1511908830093cca012
* Clarify the expected cursor position in RichInputConnection.Jean Chalard2013-07-311-26/+29
| | | | Change-Id: I4d36a23567415c3a293a588b51b46006256c148f
* Small optimizationJean Chalard2013-07-261-7/+7
| | | | | Bug: 8864306 Change-Id: Ic8eecd64eff6a1150a90b9f5ec9ebbc5f1d2a6a9
* Use cached data for getTextBeforeCursor.Jean Chalard2013-07-261-20/+33
| | | | | Bug: 8864306 Change-Id: Ia146f711f1de4336d7e3363208ab92eba856f5e1
* Merge "Revert "Very simple refactoring""Jean Chalard2013-07-261-7/+3
|\
| * Revert "Very simple refactoring"Jean Chalard2013-07-261-7/+3
| | | | | | | | | | | | | | This reverts commit f712dc9a4f17ee4a6916b0f477e89d1bc34a4d70. It turns out this refactoring is not useful after all. Change-Id: I0145c907b3cc5ac9a30a59abcd719cb546c9bd3a
* | Merge "Very simple refactoring"Jean Chalard2013-07-261-3/+7
|\|
| * Very simple refactoringJean Chalard2013-07-261-3/+7
| | | | | | | | | | Bug: 8864306 Change-Id: I5c9b118cb6a8eb59efc52d5534b10fcab93182d6
* | Refactor on UserHistoryDictionarySatoshi Kataoka2013-07-261-1/+1
|/ | | | | Bug: 9429906 Change-Id: I576a91643bdaf5017cc826ac2e07a74a9a275d60
* Move settings related classes to "settings"Ken Wakasa2013-07-221-0/+1
| | | | Change-Id: Id170dbfe2dcfc93130b7be4a84615940403ec37f
* Handling key repeat by emulating key press and code inputTadashi G. Takaoka2013-07-021-0/+4
| | | | | | | | This change also eliminates a reference of AudioAndHapticFeedbackManager from KeyboardSwitcher and MainKeyboard. Bug: 6522943 Change-Id: Iac42ec8ff00c66deb76a660ffc07477923a58959
* Move Range out of RichInputConnection and rename it.Jean Chalard2013-07-011-100/+5
| | | | | | Range has grown a bit too big to stay an internal class. Change-Id: Ic3fbc48a5d10776eedd7559c4d696e5926b88288
* Ignore spans that are not the right size.Jean Chalard2013-06-261-0/+63
| | | | | | Bug: 8839763 Bug: 8862327 Change-Id: I5d49c86edcbc0fc1b2b147856437cfbadd678377
* Fixing follow-up to I548d899bJean Chalard2013-06-261-8/+0
| | | | | | | | | | I548d899b introduced a new method to fix a sync miss between the cursor position and the cached cursor position, but did not take into account that it should also update the cached text before and after the cursor in this case and that there was already a method for doing this. Change-Id: I31bd741893207c822827304e77791b1159774e1a
* Cleanup under the utils packageKen Wakasa2013-06-251-3/+3
| | | | Change-Id: If2f7bd1346cc5085bf57645830f0faac44d017e4
* Merge "Fix a bug in the cached cursor pos, and simplify selection handling"Jean Chalard2013-06-251-1/+8
|\
| * Fix a bug in the cached cursor pos, and simplify selection handlingJean Chalard2013-06-211-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation for setComposingRegion states explicitly that it does not move the cursor. This is just a bug. This does not have any ill effects right now, but it will have in later changes if not fixed. As for the selection handling, the specific test that this code removes used to serve a purpose, but it does not any more because the code using the value has been much sanitized. Now the variable can just take the obvious value, and become so self-explanatory that the comments are unnecessary. Change-Id: I548d899b38776bd3ab5f5361aab0d89d98f12e73