aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-04-28 16:21:27 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2014-04-28 16:21:27 +0900
commita8c4731eab4aa4dd5ad3811b1fb991bf5d37b082 (patch)
treec0b48b7758f3d1fcaeea2179cc821b78ac5f724c /java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
parent2cc7c3321d9e1dea462cbcd78a6ee1a99985b73b (diff)
downloadlatinime-a8c4731eab4aa4dd5ad3811b1fb991bf5d37b082.tar.gz
latinime-a8c4731eab4aa4dd5ad3811b1fb991bf5d37b082.tar.xz
latinime-a8c4731eab4aa4dd5ad3811b1fb991bf5d37b082.zip
Fix: Typed word is not included in more suggestions.
Happened when top suggestion is long and auto-corrected. Bug: 13738879 Change-Id: I47c2dfb34cfc92b54cfe54c432ee2f646fe454e5
Diffstat (limited to 'java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java')
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
index a104baa08..5a325ea82 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
@@ -74,7 +74,13 @@ public final class MoreSuggestions extends Keyboard {
int rowStartIndex = fromIndex;
final int size = Math.min(suggestedWords.size(), SuggestedWords.MAX_SUGGESTIONS);
while (index < size) {
- final String word = suggestedWords.getLabel(index);
+ final String word;
+ if (isIndexSubjectToAutoCorrection(suggestedWords, index)) {
+ // INDEX_OF_AUTO_CORRECTION and INDEX_OF_TYPED_WORD got swapped.
+ word = suggestedWords.getLabel(SuggestedWords.INDEX_OF_TYPED_WORD);
+ } else {
+ word = suggestedWords.getLabel(index);
+ }
// TODO: Should take care of text x-scaling.
mWidths[index] = (int)(TypefaceUtils.getStringWidth(word, paint) + padding);
final int numColumn = index - rowStartIndex + 1;
@@ -172,6 +178,11 @@ public final class MoreSuggestions extends Keyboard {
}
}
+ private static boolean isIndexSubjectToAutoCorrection(final SuggestedWords suggestedWords,
+ final int index) {
+ return suggestedWords.mWillAutoCorrect && index == SuggestedWords.INDEX_OF_AUTO_CORRECTION;
+ }
+
public static final class Builder extends KeyboardBuilder<MoreSuggestionsParam> {
private final MoreSuggestionsView mPaneView;
private SuggestedWords mSuggestedWords;
@@ -189,7 +200,6 @@ public final class MoreSuggestions extends Keyboard {
final int xmlId = R.xml.kbd_suggestions_pane_template;
load(xmlId, parentKeyboard.mId);
mParams.mVerticalGap = mParams.mTopPadding = parentKeyboard.mVerticalGap / 2;
-
mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight);
final int count = mParams.layout(suggestedWords, fromIndex, maxWidth, minWidth, maxRow,
mPaneView.newLabelPaint(null /* key */), mResources);
@@ -206,8 +216,16 @@ public final class MoreSuggestions extends Keyboard {
final int x = params.getX(index);
final int y = params.getY(index);
final int width = params.getWidth(index);
- final String word = mSuggestedWords.getLabel(index);
- final String info = mSuggestedWords.getDebugString(index);
+ final String word;
+ final String info;
+ if (isIndexSubjectToAutoCorrection(mSuggestedWords, index)) {
+ // INDEX_OF_AUTO_CORRECTION and INDEX_OF_TYPED_WORD got swapped.
+ word = mSuggestedWords.getLabel(SuggestedWords.INDEX_OF_TYPED_WORD);
+ info = mSuggestedWords.getDebugString(SuggestedWords.INDEX_OF_TYPED_WORD);
+ } else {
+ word = mSuggestedWords.getLabel(index);
+ info = mSuggestedWords.getDebugString(index);
+ }
final int indexInMoreSuggestions = index + SUGGESTION_CODE_BASE;
final Key key = new Key(word, KeyboardIconsSet.ICON_UNDEFINED,
indexInMoreSuggestions, null /* outputText */, info, 0 /* labelFlags */,