From 2e8d536678c36282a902ec8c3cb4b5833f881792 Mon Sep 17 00:00:00 2001 From: Chieu Nguyen Date: Tue, 13 Jan 2015 13:16:23 -0800 Subject: [PATCH] Add a method for handling for words not found in dictionary. This is apparently called only once for every unique word, so repeated instances of the same word are not handled separately. Upon changing orientation of the device, however, all invalid words in the textbox are underlined again and this method is called for each unique instance in order. Change-Id: Ic57e4b9e5675bd7abd723644aa318d964f7f875f --- .../android/inputmethod/latin/utils/StatsUtils.java | 3 +++ .../AndroidWordLevelSpellCheckerSession.java | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java b/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java index 044970267..5a9258d51 100644 --- a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java +++ b/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java @@ -83,4 +83,7 @@ public final class StatsUtils { public static void onLoadSettings(SettingsValues settingsValues) { } + + public static void onInvalidWordIdentification(final String invalidWord) { + } } diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java index 4b8d2a3f9..832bfd066 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java @@ -39,6 +39,7 @@ import com.android.inputmethod.latin.common.LocaleUtils; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.utils.BinaryDictionaryUtils; import com.android.inputmethod.latin.utils.ScriptUtils; +import com.android.inputmethod.latin.utils.StatsUtils; import com.android.inputmethod.latin.utils.SuggestionResults; import java.util.ArrayList; @@ -297,6 +298,15 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { } } } + // Handle word not in dictionary. + // This is called only once per unique word, so entering multiple + // instances of the same word does not result in more than one call + // to this method. + // Also, upon changing the orientation of the device, this is called + // again for every unique invalid word in the text box. + if (!isInDict) { + StatsUtils.onInvalidWordIdentification(text); + } final int flags = (isInDict ? SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY