am b87ed461: Merge "Fix many small nits."

* commit 'b87ed46118c4bdf34c764a1e93c2cf0d4655f63b':
  Fix many small nits.
main
Jean Chalard 2013-11-12 22:13:47 -08:00 committed by Android Git Automerger
commit ecb46157c6
2 changed files with 15 additions and 4 deletions

View File

@ -908,6 +908,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
false /* shouldFinishComposition */)) {
// We try resetting the caches up to 5 times before giving up.
mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
// mLastSelection{Start,End} are reset later in this method, don't need to do it here
canReachInputConnection = false;
} else {
if (isDifferentTextField) {
@ -987,10 +988,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (textLength > mLastSelectionStart
|| (textLength < Constants.EDITOR_CONTENTS_CACHE_SIZE
&& mLastSelectionStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
// It should not be possible to have only one of those variables be
// NOT_A_CURSOR_POSITION, so if they are equal, either the selection is zero-sized
// (simple cursor, no selection) or there is no cursor/we don't know its pos
final boolean wasEqual = mLastSelectionStart == mLastSelectionEnd;
mLastSelectionStart = textLength;
// We can't figure out the value of mLastSelectionEnd :(
// But at least if it's smaller than mLastSelectionStart something is wrong
if (mLastSelectionStart > mLastSelectionEnd) {
// But at least if it's smaller than mLastSelectionStart something is wrong,
// and if they used to be equal we also don't want to make it look like there is a
// selection.
if (wasEqual || mLastSelectionStart > mLastSelectionEnd) {
mLastSelectionEnd = mLastSelectionStart;
}
}

View File

@ -292,7 +292,11 @@ public final class RichInputConnection {
mCommittedTextBeforeComposingText.length() + mComposingText.length();
// If we have enough characters to satisfy the request, or if we have all characters in
// the text field, then we can return the cached version right away.
if (cachedLength >= n || cachedLength >= mExpectedCursorPosition) {
// However, if we don't have an expected cursor position, then we should always
// go fetch the cache again (as it happens, INVALID_CURSOR_POSITION < 0, so we need to
// test for this explicitly)
if (INVALID_CURSOR_POSITION != mExpectedCursorPosition
&& (cachedLength >= n || cachedLength >= mExpectedCursorPosition)) {
final StringBuilder s = new StringBuilder(mCommittedTextBeforeComposingText);
// We call #toString() here to create a temporary object.
// In some situations, this method is called on a worker thread, and it's possible