Commit Graph

124 Commits (37beaf1529a61228d6240736937789e5622b29ed)

Author SHA1 Message Date
Yohei Yukawa 29200b0abe Set the text bgcolor only when CursorAnchorInfo is available
When CursorAnchorInfo is unavailable, we shouldn't try to show
the commit indicator and set the text highlight color.

With this CL, RichInputConnection can be used to track if the
application responded that it does support CursorAnchorInfo or
not.  This result will be taken into consideration when
InputLogic needs to determine whether the commit indicator
should be displayed or not.

Change-Id: I945d70eeb02a7a5f3d9b22459b23d7028508910f
2014-08-27 01:30:45 -07:00
Yohei Yukawa 4a71d2c480 Allow to add/remove background color to/from the committed text
This is a groundwork for subsequent CLs where we need to
add/remove background color to/from the commited text.

In this CL, we use Spanned#SPAN_COMPOSING so that we can easily
remove such a background color by calling
InputConnection#finishComposingText. To make this operation easy
and realiable, we need to track whether we have specified the
background color to the commited text or not at one place. Here
we use RichInputConnection for this purpose.

Change-Id: I5f9bc4425c5d1b80a719a20e5baf336729ec08d2
2014-08-24 20:28:24 -07:00
Jean Chalard 9273f3832b [HS3] Fix a bug on ICS
There is a bug in ICS where the input connection won't take
any writing commands after rotation until the cursor moves.
This fixes it by wiggling the cursor position once before trying
to do anything.

Bug: 16810766
Change-Id: Ib14c70bd0550420cecfa86dea501d13a1a91e296
2014-08-06 11:38:11 +09:00
Keisuke Kuroyanagi bb843eb223 Move getPrevWordsInfoFromNthPreviousWord to PrevWordsInfoUtils.
Bug: 14425059
Change-Id: Id37022ac6c1545d6845abfbcdb7ed47f0e250eec
2014-07-07 13:07:57 +09:00
Jean Chalard 292deb632c [SD7] Actually check for script.
...also implement the check for Hebrew and Arabic.

Bug: 15840116
Change-Id: Ia6433d7d98038ade64c171be4fe4b3f094111fac
2014-07-01 15:01:22 +09:00
Jean Chalard b6695867a5 [SD6] Inline a constant and remove logic become useless
Bug: 15840116
Change-Id: I545cc9083aa4e2fd7cbbd1fbc02e1e382482db7c
2014-07-01 14:34:53 +09:00
Jean Chalard 20c89b1cf5 [SD5(2)] Remove useless args
Bug: 15840116
Change-Id: I1123426fbd9d420c1be64ccc917a5f870e70e6fa
2014-07-01 13:34:25 +09:00
Ken Wakasa 7eef5d3ff4 Revert "[SD5] Remove useless args"
This reverts commit 1d30023961 that broke the build.

Bug: 15840116
Change-Id: I0a5fa7dea2b418d19df24b2b31ed96bf192d45c0
2014-07-01 03:23:14 +00:00
Jean Chalard 1d30023961 [SD5] Remove useless args
Bug: 15840116
Change-Id: Ib3380cfc9d343c6f8953bba03af3801142bc3bdb
2014-06-30 21:58:55 +09:00
Ken Wakasa 92223c04de Merge "Revert "Move getPrevWordsInfoFromNthPreviousWord to StringUtlis."" 2014-06-26 23:14:58 +00:00
Ken Wakasa 4569a734ad Revert "Move getPrevWordsInfoFromNthPreviousWord to StringUtlis."
This reverts commit ba463c9a66 that broke the dicttool build.

Bug: 14425059
Change-Id: Ie1685587104d26e4416624747c97f6087c13388a
2014-06-27 15:07:07 +00:00
Keisuke Kuroyanagi ba463c9a66 Move getPrevWordsInfoFromNthPreviousWord to StringUtlis.
Bug: 14425059
Change-Id: I3eb24e840c165e43f68c2a60fccf9974affb57a6
2014-06-27 18:08:17 +09:00
Keisuke Kuroyanagi 1c2f1ada83 Find multiple previous word information to support n-gram.
Bug: 14425059

Change-Id: Ieace636334a9b2a094527341d4fcfc05958296c5
2014-06-27 17:59:21 +09:00
Keisuke Kuroyanagi 1a2f3c4433 Merge "Move getPrevWordsInfoFromNthPreviousWord to StringUtlis." 2014-06-26 23:14:30 +00:00
Keisuke Kuroyanagi 17c5a388d6 Merge "Find multiple previous word information to support n-gram." 2014-06-26 23:14:58 +00:00
Jean Chalard e530fffc2c Add a relevant suggestion to period-checkable requests
Bug: 15412461
Change-Id: Ibf37df4d31141a7e43b54d6342e7861eedb1c03b
2014-06-27 12:52:23 +09:00
Keisuke Kuroyanagi e708b1bc2e Make PrevWordsInfo have multiple words' information.
Bug: 14425059
Change-Id: I2bd6a872904a44b80f638a13d91a97559217cc1a
2014-06-25 14:14:37 +09:00
Jean Chalard 9fd9a68d87 Fix a bug on rotation with selection.
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
2014-06-06 11:18:23 +09:00
Keisuke Kuroyanagi 8f71fab2ed Make prevWord = null if the next word starts from a connector.
This fixes PunctuationTests#
testAutoCorrectionWithSingleQuotesAround.

Bug: 14119293
Bug: 15334309

Change-Id: I604c21a21e89a5fc431fd56ab7b6ad03f4736b01
2014-05-30 20:30:17 +09:00
Tadashi G. Takaoka bbf556e8e1 Remove researcher logger
This CL must be checked in together with I5cc76807e3.

Bug: 15318007
Change-Id: I61423c3377ddc299fb332e742d6626c2e47145bb
2014-05-29 15:10:28 +09:00
Keisuke Kuroyanagi a790c5b683 Introduce EMPTY_PREV_WORDS_INFO and BEGINNING_OF_SENTENCE.
Bug: 14119293
Change-Id: I5020e5f0aa64bc3e97b3a3c2c07a60c8b765ed64
2014-05-23 23:19:33 +09:00
Keisuke Kuroyanagi 17f326b745 Add beginning of sentence information in PrevWordsInfo.
Bug: 14119293
Bug: 14425059
Change-Id: I65320920e840082b0b697bb621676716d0933e0c
2014-05-21 15:40:08 +09:00
Jean Chalard 72b67f6541 Rework the logic that tells if the cursor touches words
Bug: 13312942
Change-Id: I6be6a558bbc6c88508150f9c25cadbd0240ff88e
2014-03-20 23:16:53 +09:00
Jean Chalard e93a7232d1 Don't reset the value needed before it's used
Nice recipe for failure

Bug: 13387534
Change-Id: Ida1978449c1997587b2ec0955c5c94fcef336121
2014-03-10 15:55:15 +09:00
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