Addressed bug: 3058217 "-" key not working at beginning of line

Also fixed related issues below:
* Punc suggestions list was sometimes not displayed after cursor move which follows re-correction
* Punc suggestions list was disappearing with words which contains certain punc chars (but not word separator) such as ' and -

Change-Id: I36faf679321782fa8eaf318411308a4a6b89cc25
main
Ken Wakasa 2010-10-05 22:51:59 +09:00
parent 47383758fc
commit 55b1079652
1 changed files with 17 additions and 8 deletions

View File

@ -699,7 +699,9 @@ public class LatinIME extends InputMethodService
mLastSelectionEnd = et.startOffset + et.selectionEnd; mLastSelectionEnd = et.startOffset + et.selectionEnd;
// Then look for possible corrections in a delayed fashion // Then look for possible corrections in a delayed fashion
if (!TextUtils.isEmpty(et.text)) postUpdateOldSuggestions(); if (!TextUtils.isEmpty(et.text) && isCursorTouchingWord()) {
postUpdateOldSuggestions();
}
} }
} }
@ -805,6 +807,10 @@ public class LatinIME extends InputMethodService
postUpdateOldSuggestions(); postUpdateOldSuggestions();
} else { } else {
abortCorrection(false); abortCorrection(false);
// Show the punctuation suggestions list if the current one is not
if (!mSuggestPuncList.equals(mCandidateView.getSuggestions())) {
setNextSuggestions();
}
} }
} }
} }
@ -1315,7 +1321,7 @@ public class LatinIME extends InputMethodService
} else if (deleteChar) { } else if (deleteChar) {
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) { if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
// Go back to the suggestion mode if the user canceled the // Go back to the suggestion mode if the user canceled the
// "Tap again to save". // "Touch again to save".
// NOTE: In gerenal, we don't revert the word when backspacing // NOTE: In gerenal, we don't revert the word when backspacing
// from a manual suggestion pick. We deliberately chose a // from a manual suggestion pick. We deliberately chose a
// different behavior only in the case of picking the first // different behavior only in the case of picking the first
@ -1444,7 +1450,7 @@ public class LatinIME extends InputMethodService
mVoiceInput.incrementTextModificationInsertPunctuationCount(1); mVoiceInput.incrementTextModificationInsertPunctuationCount(1);
} }
// Should dismiss the "Tap again to save" message when handling separator // Should dismiss the "Touch again to save" message when handling separator
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) { if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
postUpdateSuggestions(); postUpdateSuggestions();
} }
@ -1887,7 +1893,8 @@ public class LatinIME extends InputMethodService
// So, LatinImeLogger logs "" as a user's input. // So, LatinImeLogger logs "" as a user's input.
LatinImeLogger.logOnManualSuggestion( LatinImeLogger.logOnManualSuggestion(
"", suggestion.toString(), index, suggestions); "", suggestion.toString(), index, suggestions);
onKey(suggestion.charAt(0), null, LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE, final char primaryCode = suggestion.charAt(0);
onKey(primaryCode, new int[]{primaryCode}, LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE,
LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE); LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE);
if (ic != null) { if (ic != null) {
ic.endBatchEdit(); ic.endBatchEdit();
@ -1922,7 +1929,7 @@ public class LatinIME extends InputMethodService
TextEntryState.typedCharacter((char) KEYCODE_SPACE, true); TextEntryState.typedCharacter((char) KEYCODE_SPACE, true);
setNextSuggestions(); setNextSuggestions();
} else if (!showingAddToDictionaryHint) { } else if (!showingAddToDictionaryHint) {
// If we're not showing the "Tap again to save hint", then show corrections again. // If we're not showing the "Touch again to save hint", then show corrections again.
// In case the cursor position doesn't change, make sure we show the suggestions again. // In case the cursor position doesn't change, make sure we show the suggestions again.
clearSuggestions(); clearSuggestions();
postUpdateOldSuggestions(); postUpdateOldSuggestions();
@ -2094,7 +2101,7 @@ public class LatinIME extends InputMethodService
ic.endBatchEdit(); ic.endBatchEdit();
} else { } else {
abortCorrection(true); abortCorrection(true);
setNextSuggestions(); setNextSuggestions(); // Show the punctuation suggestions list
} }
} else { } else {
abortCorrection(true); abortCorrection(true);
@ -2150,11 +2157,13 @@ public class LatinIME extends InputMethodService
CharSequence toLeft = ic.getTextBeforeCursor(1, 0); CharSequence toLeft = ic.getTextBeforeCursor(1, 0);
CharSequence toRight = ic.getTextAfterCursor(1, 0); CharSequence toRight = ic.getTextAfterCursor(1, 0);
if (!TextUtils.isEmpty(toLeft) if (!TextUtils.isEmpty(toLeft)
&& !isWordSeparator(toLeft.charAt(0))) { && !isWordSeparator(toLeft.charAt(0))
&& !isSuggestedPunctuation(toLeft.charAt(0))) {
return true; return true;
} }
if (!TextUtils.isEmpty(toRight) if (!TextUtils.isEmpty(toRight)
&& !isWordSeparator(toRight.charAt(0))) { && !isWordSeparator(toRight.charAt(0))
&& !isSuggestedPunctuation(toRight.charAt(0))) {
return true; return true;
} }
return false; return false;