Commit Graph

100 Commits (e07a777ed6f97549c7816265b1df98e6611719ca)

Author SHA1 Message Date
Jean Chalard f19745728e Never pass negative values to setSelection.
Bug: 13136079
Change-Id: Ieae6bafbd5339a033f0f342ba9af7dcc4ce209fa
2014-02-24 16:52:55 +09:00
Jean Chalard 3b4c1d3056 Change a heuristic and add a log.
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
2014-02-20 23:49:20 +09:00
Jean Chalard 3c84eb8822 Don't distrust the cursor pos so much as to bug on IPC delay
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
2014-02-20 23:13:14 +09:00
Jean Chalard be8ad77ebb Comments improvements
Typo fixes and clarifications

Change-Id: I0f7e0b6e665232bb995172fff10521c7f17599eb
2014-02-20 13:29:43 +09:00
Jean Chalard fe92c174ea Fix a bug where the cache would be out of sync
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
2014-02-18 19:55:54 +09:00
Jean Chalard 7a7aeffcdc Don't resume suggestion on links.
Bug: 11447084
Change-Id: I5bd558b9dd85d1505aa918f44e8ac3e52ec42d97
2014-02-17 20:36:16 +09:00
Jean Chalard c7ef305bbc Try to figure out whether d.quotes open or close.
Bug: 8911672
Change-Id: I5d5635949530a67f95e5208986907251b7bce903
2014-01-27 18:17:33 +09:00
Tadashi G. Takaoka c93cf1c398 Use sorted int[] to represent word separators
Change-Id: I4103541d99fe59bfcf12379a1298a0a690497846
2014-01-20 19:40:02 +09:00
Tadashi G. Takaoka 6a18af634e Refactor RichInputConnection a bit
Change-Id: I866488a47ca04ca587e805663dfd597bb7b1ebce
2014-01-17 13:14:29 +09:00
Jean Chalard ecf46df226 [IL54] Add a mirror method to fix the cursor pos estimate
This just mirrors what InputLogic#tryFixLyingCursorPosition
is doing. That method will go away in the next change.

Change-Id: Ifa2827dbc1f1d20e2c642d6f2d23514a01ed9203
2014-01-10 16:05:02 +09:00
Jean Chalard 6fbe83be7a [IL53] Fix a wrong test.
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
2014-01-10 15:21:20 +09:00
Tadashi G. Takaoka 494e2d6c17 Passing SpacingAndPunctuations to RichInputConnection.getNthPreviousWords
Change-Id: I174c50f509ed6998b755e1a712e7f6c0f82f4425
2014-01-09 18:33:25 +09:00
Tadashi G. Takaoka 0a75cf51af Passing SpacingAndPunctuations to CapsModeUtils.getCapsMode
Change-Id: I0b06e8cc75a403f7061864c5b7f3f6a2cacd60eb
2014-01-09 18:19:17 +09:00
Jean Chalard e5cdcaff65 Fix a race condition, take 2.
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
2014-01-08 18:04:44 +09:00
Jean Chalard a247264dc6 Revert "Fix a race condition, take 2."
Conflicts prevent this to be cherry-picked.

This reverts commit dd3d697a6e.

Change-Id: Ib97fae2234633b4bb27d611f48a79060db9ab16f
2014-01-08 08:59:26 +00:00
Jean Chalard dd3d697a6e Fix a race condition, take 2.
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
2014-01-08 17:19:29 +09:00
Jean Chalard 1e50c681af [IL52] Remove a useless method.
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
2013-12-27 22:40:19 +09:00
Ken Wakasa 2fa3693c26 Reset to 9bd6dac470
The bulk merge from -bayo to klp-dev should not have been merged to master.

Change-Id: I527a03a76f5247e4939a672f27c314dc11cbb854
2013-12-13 17:13:32 +09:00
Jean Chalard 3a9b2430a5 Fix many small nits.
...the interaction of which results in a very bad bug.

Bug: 11648854
Change-Id: I774489e384388f187e72b9ac091ab387c5e1a79a
2013-11-12 22:44:59 -08:00
Jean Chalard 8a1675379e Stopgap solution for a crash.
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
2013-10-22 05:23:48 -07:00
Jean Chalard 10581e68af Make the sentence separator a resource.
This will help handing correctly the armenian full stop.

Bug: 10082781
Change-Id: Id7bb219ebd89daba203216eab362d1cc26a65a36
2013-10-08 15:28:43 +09:00
Ken Wakasa f56b82f809 Fix the offdevice regression test build
Followup to If4e44eca3cdc5bb02cf2e0c8c44ecd4bf27fae57

bug: 10622489
Change-Id: If98b2c75725f8692f0c2b41c33e448086404479b
2013-09-25 19:13:47 +09:00
Jean Chalard 3d68b06662 Copy only the spans we are interested in.
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
2013-09-24 19:04:51 +09:00
Jean Chalard f1d8aa46f9 Detect cases where rotation messes with initialization
...and do a best effort to fix it.

Bug: 10323080
Bug: 10252066
Change-Id: Icb3c9fe85005406bdfce0b7bb143ba0a910a0ddb
2013-09-20 22:21:28 +09:00
Jean Chalard 8f02f1a118 Fix a bug where null would be converted to "null"
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
2013-09-20 15:45:51 +09:00
Kurt Partridge 6c94a18a28 Fix cursor state bug
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
2013-08-21 17:55:35 -07:00
Jean Chalard 522d13c302 Have double-space-to-period cancel leave a single space
Bug: 8911898
Change-Id: Ifb4bb63c14dc960d0a53f1511908830093cca012
2013-08-08 11:49:27 +09:00
Jean Chalard aa108f1d7f Clarify the expected cursor position in RichInputConnection.
Change-Id: I4d36a23567415c3a293a588b51b46006256c148f
2013-07-31 12:22:15 +09:00
Jean Chalard 0a064a5d88 Small optimization
Bug: 8864306
Change-Id: Ic8eecd64eff6a1150a90b9f5ec9ebbc5f1d2a6a9
2013-07-26 20:17:55 +09:00
Jean Chalard 8c6537edbd Use cached data for getTextBeforeCursor.
Bug: 8864306
Change-Id: Ia146f711f1de4336d7e3363208ab92eba856f5e1
2013-07-26 20:17:52 +09:00
Jean Chalard 38e9802690 Merge "Revert "Very simple refactoring"" 2013-07-26 06:58:44 +00:00
Jean Chalard c6a07e16a5 Revert "Very simple refactoring"
This reverts commit f712dc9a4f.
It turns out this refactoring is not useful after all.

Change-Id: I0145c907b3cc5ac9a30a59abcd719cb546c9bd3a
2013-07-26 06:46:56 +00:00
Jean Chalard 0dd23544ff Merge "Very simple refactoring" 2013-07-26 05:30:47 +00:00
Satoshi Kataoka ffcbbaf127 Refactor on UserHistoryDictionary
Bug: 9429906
Change-Id: I576a91643bdaf5017cc826ac2e07a74a9a275d60
2013-07-26 13:00:19 +09:00
Jean Chalard f712dc9a4f Very simple refactoring
Bug: 8864306
Change-Id: I5c9b118cb6a8eb59efc52d5534b10fcab93182d6
2013-07-26 12:57:12 +09:00
Ken Wakasa a7d2fc6bef Move settings related classes to "settings"
Change-Id: Id170dbfe2dcfc93130b7be4a84615940403ec37f
2013-07-22 16:35:44 +09:00
Tadashi G. Takaoka f87e8f7ec1 Handling key repeat by emulating key press and code input
This change also eliminates a reference of
AudioAndHapticFeedbackManager from KeyboardSwitcher and MainKeyboard.

Bug: 6522943
Change-Id: Iac42ec8ff00c66deb76a660ffc07477923a58959
2013-07-02 19:50:34 +09:00
Jean Chalard 675bcf191c Move Range out of RichInputConnection and rename it.
Range has grown a bit too big to stay an internal class.

Change-Id: Ic3fbc48a5d10776eedd7559c4d696e5926b88288
2013-07-01 15:41:13 +09:00
Jean Chalard 2f7f6257b6 Ignore spans that are not the right size.
Bug: 8839763
Bug: 8862327
Change-Id: I5d49c86edcbc0fc1b2b147856437cfbadd678377
2013-06-26 23:02:50 +09:00
Jean Chalard 7fcf304c97 Fixing follow-up to I548d899b
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
2013-06-26 15:28:42 +09:00
Ken Wakasa 03118a2760 Cleanup under the utils package
Change-Id: If2f7bd1346cc5085bf57645830f0faac44d017e4
2013-06-25 17:09:12 +09:00
Jean Chalard 10585620bd Merge "Fix a bug in the cached cursor pos, and simplify selection handling" 2013-06-25 05:00:11 +00:00
Ken Wakasa bc1813186d Merge "Move util classes to the latin/utils directory" 2013-06-24 08:49:06 +00:00
Ken Wakasa e28eba5074 Move util classes to the latin/utils directory
Change-Id: I1c5b27c8edf231680edb8d96f63b9d04cfc6a6fa
2013-06-24 17:04:40 +09:00
Jean Chalard e8c4b99e56 Refactor text range to be able to get spans larger than the word
This changes how the Range class stores its data, but not its
functionality. It also improves encapsulation a bit.

Bug: 8839763
Bug: 8862327
Change-Id: I5bd583b3fc96a99b93a2632882d8fd587c03ab76
2013-06-24 12:31:14 +09:00
Jean Chalard e5dee0af4a Fix a bug in the cached cursor pos, and simplify selection handling
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
2013-06-21 18:15:07 +09:00
Jean Chalard 9f9cc03277 Optimizations and safeguards.
- Don't call finishComposingText when useless.
- Add safeguards against calling setComposingRegion when the
  data returned by the editor is inconsistent.
- Cancel pending recorrection messages when new messages arrive.

Bug: 8842941
Bug: 8845001
Change-Id: I939701033cf5c2bbd85871ecf83e329021ddeb91
2013-05-08 18:47:10 +09:00
Jean Chalard 73ec85b8ad Don't insert automatic spaces when text looks like a URL
This is about as ad-hoc as it gets, but then again, what we want
is probably as ad-hoc as it gets.
All URL boxes I know of double as search bars, and not adding
automatic spaces there sucks (e.g. in Chrome URL bar).
And in other boxes actually you don't want to add a space if
it looks like a URL. QSB isn't even a search box, and it behaves
like this.

So I think this is actually the right answer to the problem.

Bug: 7062925
Change-Id: Ib09472b34644fd5bf2dc84bb97cedeeba28bcd02
2013-04-16 18:03:49 +09:00
Jean Chalard 2995abe7aa Have Latin IME re-capitalize a selected string
Upon pressing Shift, if there is currently a selected string, have
Latin IME change its capitalization.
This does not yet have the keyboard mode follow the mode - the change
is complicated enough as is.

Bug: 7657025
Change-Id: I54fe8485f44e04efd72c71ac9feee5ce21ba06f2
2013-04-15 20:23:01 +09:00
Jean Chalard 91bcf5eb5d Merge "Restart suggestions when the cursor moves." 2013-04-12 12:27:50 +00:00