aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2010-11-01 20:25:07 +0900
committerKen Wakasa <kwakasa@google.com>2010-11-01 20:25:07 +0900
commit200ece79070750ba702a071908d990f8d1c41f02 (patch)
tree9c560bfbf9c504c3e899155b7fe98fca001dc93a /java/src
parentb325e811b6f5bf7a63cdd3ab1e819a3017aeb234 (diff)
downloadlatinime-200ece79070750ba702a071908d990f8d1c41f02.tar.gz
latinime-200ece79070750ba702a071908d990f8d1c41f02.tar.xz
latinime-200ece79070750ba702a071908d990f8d1c41f02.zip
Capitalization for "Quick Fixes" words doesn't work
bug: 3151706 Change-Id: I7770a1d26edb1ea72ee93396181953a724dcc4bf
Diffstat (limited to 'java/src')
-rwxr-xr-xjava/src/com/android/inputmethod/latin/Suggest.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 01782339f..29c3eea5f 100755
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -337,8 +337,25 @@ public class Suggest implements Dictionary.WordCallback {
String suggestedWord = mSuggestions.get(i).toString().toLowerCase();
CharSequence autoText =
AutoText.get(suggestedWord, 0, suggestedWord.length(), view);
- // Is there an AutoText correction?
+ // Is there an AutoText (also known as Quick Fixes) correction?
boolean canAdd = autoText != null;
+ // Capitalize as needed
+ final int autoTextLength = autoText != null ? autoText.length() : 0;
+ if (autoTextLength > 0 && (mIsAllUpperCase || mIsFirstCharCapitalized)) {
+ int poolSize = mStringPool.size();
+ StringBuilder sb = poolSize > 0 ? (StringBuilder) mStringPool.remove(
+ poolSize - 1) : new StringBuilder(getApproxMaxWordLength());
+ sb.setLength(0);
+ if (mIsAllUpperCase) {
+ sb.append(autoText.toString().toUpperCase());
+ } else if (mIsFirstCharCapitalized) {
+ sb.append(Character.toUpperCase(autoText.charAt(0)));
+ if (autoTextLength > 1) {
+ sb.append(autoText.subSequence(1, autoTextLength));
+ }
+ }
+ autoText = sb.toString();
+ }
// Is that correction already the current prediction (or original word)?
canAdd &= !TextUtils.equals(autoText, mSuggestions.get(i));
// Is that correction already the next predicted word?
@@ -461,8 +478,7 @@ public class Suggest implements Dictionary.WordCallback {
return true;
}
- System.arraycopy(priorities, pos, priorities, pos + 1,
- prefMaxSuggestions - pos - 1);
+ System.arraycopy(priorities, pos, priorities, pos + 1, prefMaxSuggestions - pos - 1);
priorities[pos] = freq;
int poolSize = mStringPool.size();
StringBuilder sb = poolSize > 0 ? (StringBuilder) mStringPool.remove(poolSize - 1)