diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/res/xml-sw600dp/rows_greek.xml | 5 | ||||
-rw-r--r-- | java/res/xml-sw768dp/rows_greek.xml | 5 | ||||
-rw-r--r-- | java/res/xml/rows_greek.xml | 22 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/AutoCorrection.java | 19 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 3 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 19 |
6 files changed, 43 insertions, 30 deletions
diff --git a/java/res/xml-sw600dp/rows_greek.xml b/java/res/xml-sw600dp/rows_greek.xml index c77627e59..dab7f907e 100644 --- a/java/res/xml-sw600dp/rows_greek.xml +++ b/java/res/xml-sw600dp/rows_greek.xml @@ -27,7 +27,10 @@ latin:keyWidth="9.0%p" > <Key - latin:keyLabel=";" /> + latin:keyLabel=";" + latin:keyHintLabel=":" + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. --> <!-- <switch> diff --git a/java/res/xml-sw768dp/rows_greek.xml b/java/res/xml-sw768dp/rows_greek.xml index e9a76a588..7c9072410 100644 --- a/java/res/xml-sw768dp/rows_greek.xml +++ b/java/res/xml-sw768dp/rows_greek.xml @@ -31,7 +31,10 @@ latin:keyLabelFlags="alignLeft" latin:keyWidth="7.969%p" /> <Key - latin:keyLabel=";" /> + latin:keyLabel=";" + latin:keyHintLabel=":" + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. --> <!-- <switch> diff --git a/java/res/xml/rows_greek.xml b/java/res/xml/rows_greek.xml index 1602c507e..24b5c1838 100644 --- a/java/res/xml/rows_greek.xml +++ b/java/res/xml/rows_greek.xml @@ -26,10 +26,24 @@ <Row latin:keyWidth="10%p" > - <Key - latin:keyLabel=";" - latin:keyHintLabel="1" - latin:additionalMoreKeys="1" /> + <switch> + <case + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + > + <Key + latin:keyLabel=":" + latin:keyHintLabel="1" + latin:moreKeys=";" + latin:additionalMoreKeys="1" /> + </case> + <default> + <Key + latin:keyLabel=";" + latin:keyHintLabel="1" + latin:moreKeys=":" + latin:additionalMoreKeys="1" /> + </default> + </switch> <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. --> <!-- <switch> diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index c4c944635..9754d1517 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -25,30 +25,25 @@ import java.util.Map; public class AutoCorrection { private static final boolean DBG = LatinImeLogger.sDBG; private static final String TAG = AutoCorrection.class.getSimpleName(); - private CharSequence mAutoCorrectionWord; - public void init() { - mAutoCorrectionWord = null; + private AutoCorrection() { + // Purely static class: can't instantiate. } - public boolean hasAutoCorrection() { - return null != mAutoCorrectionWord; - } - - public CharSequence updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries, + public static CharSequence computeAutoCorrectionWord(Map<String, Dictionary> dictionaries, WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores, CharSequence typedWord, double autoCorrectionThreshold, int correctionMode, CharSequence whitelistedWord) { if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { - mAutoCorrectionWord = whitelistedWord; + return whitelistedWord; } else if (hasAutoCorrectionForTypedWord( dictionaries, wordComposer, suggestions, typedWord, correctionMode)) { - mAutoCorrectionWord = typedWord; + return typedWord; } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode, sortedScores, typedWord, autoCorrectionThreshold)) { - mAutoCorrectionWord = suggestions.get(0); + return suggestions.get(0); } - return mAutoCorrectionWord; + return null; } public static boolean isValidWord( diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 73a96895f..e1ca854b5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1869,7 +1869,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar builder.addTypedWordAndPreviousSuggestions(typedWord, previousSuggestions); } } - if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest)) { + if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest, + mSettingsValues.mAutoCorrectionThreshold)) { builder.setShouldBlockAutoCorrectionBySafetyNet(); } showSuggestions(builder.build(), typedWord); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 19655f27d..a2131605d 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -83,7 +83,7 @@ public class Suggest implements Dictionary.WordCallback { private static final boolean DBG = LatinImeLogger.sDBG; - private AutoCorrection mAutoCorrection; + private boolean mHasAutoCorrection; private Dictionary mMainDict; private ContactsDictionary mContactsDict; @@ -124,7 +124,6 @@ public class Suggest implements Dictionary.WordCallback { private void initWhitelistAndAutocorrectAndPool(final Context context, final Locale locale) { mWhiteListDictionary = new WhitelistDictionary(context, locale); addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_WHITELIST, mWhiteListDictionary); - mAutoCorrection = new AutoCorrection(); StringBuilderPool.ensureCapacity(mPrefMaxSuggestions, getApproxMaxWordLength()); } @@ -219,10 +218,6 @@ public class Suggest implements Dictionary.WordCallback { mAutoCorrectionThreshold = threshold; } - public boolean isAggressiveAutoCorrectionMode() { - return (mAutoCorrectionThreshold == 0); - } - /** * Number of suggestions to generate from the input key sequence. This has * to be a number between 1 and 100 (inclusive). @@ -272,7 +267,6 @@ public class Suggest implements Dictionary.WordCallback { final WordComposer wordComposer, CharSequence prevWordForBigram, final ProximityInfo proximityInfo, final int correctionMode) { LatinImeLogger.onStartSuggestion(prevWordForBigram); - mAutoCorrection.init(); mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized(); mIsAllUpperCase = wordComposer.isAllUpperCase(); mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount(); @@ -352,9 +346,11 @@ public class Suggest implements Dictionary.WordCallback { CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWordString)); - mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer, + final CharSequence autoCorrection = + AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer, mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode, whitelistedWord); + mHasAutoCorrection = (null != autoCorrection); if (whitelistedWord != null) { if (mTrailingSingleQuotesCount > 0) { @@ -403,7 +399,7 @@ public class Suggest implements Dictionary.WordCallback { } public boolean hasAutoCorrection() { - return mAutoCorrection.hasAutoCorrection(); + return mHasAutoCorrection; } @Override @@ -554,7 +550,8 @@ public class Suggest implements Dictionary.WordCallback { // TODO: Resolve the inconsistencies between the native auto correction algorithms and // this safety net public static boolean shouldBlockAutoCorrectionBySafetyNet( - SuggestedWords.Builder suggestedWordsBuilder, Suggest suggest) { + final SuggestedWords.Builder suggestedWordsBuilder, final Suggest suggest, + final double autoCorrectionThreshold) { // Safety net for auto correction. // Actually if we hit this safety net, it's actually a bug. if (suggestedWordsBuilder.size() <= 1 || suggestedWordsBuilder.isTypedWordValid()) { @@ -562,7 +559,7 @@ public class Suggest implements Dictionary.WordCallback { } // If user selected aggressive auto correction mode, there is no need to use the safety // net. - if (suggest.isAggressiveAutoCorrectionMode()) { + if (0 == autoCorrectionThreshold) { return false; } final CharSequence typedWord = suggestedWordsBuilder.getWord(0); |