diff options
author | 2013-04-12 12:33:23 +0000 | |
---|---|---|
committer | 2013-04-12 12:33:24 +0000 | |
commit | 2cd1136b8ebedc7cf939d7d7546ed753191f8677 (patch) | |
tree | 3cd530bbf0c7191c2143d27e5018148df8eb7adc /java/src/com/android/inputmethod/latin/UserBinaryDictionary.java | |
parent | 91bcf5eb5dcf1f2ff66cfda90832db21bce7e330 (diff) | |
parent | 1a51833828569d76cbbc4865ccef8cc7f529dd68 (diff) | |
download | latinime-2cd1136b8ebedc7cf939d7d7546ed753191f8677.tar.gz latinime-2cd1136b8ebedc7cf939d7d7546ed753191f8677.tar.xz latinime-2cd1136b8ebedc7cf939d7d7546ed753191f8677.zip |
Merge "Remove the dialog to insert words to the dictionary."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/UserBinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/UserBinaryDictionary.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java index 709dedd49..90f92972a 100644 --- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java @@ -20,7 +20,6 @@ import android.content.ContentProviderClient; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; -import android.content.Intent; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; @@ -28,7 +27,10 @@ import android.os.Build; import android.provider.UserDictionary.Words; import android.text.TextUtils; +import com.android.inputmethod.compat.UserDictionaryCompatUtils; + import java.util.Arrays; +import java.util.Locale; /** * An expandable dictionary that stores the words in the user dictionary provider into a binary @@ -61,10 +63,6 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { private static final String NAME = "userunigram"; - // This is not exported by the framework so we pretty much have to write it here verbatim - private static final String ACTION_USER_DICTIONARY_INSERT = - "com.android.settings.USER_DICTIONARY_INSERT"; - private ContentObserver mObserver; final private String mLocale; final private boolean mAlsoUseMoreRestrictiveLocales; @@ -211,23 +209,19 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { /** * Adds a word to the user dictionary and makes it persistent. * - * This will call upon the system interface to do the actual work through the intent readied by - * the system to this effect. - * * @param word the word to add. If the word is capitalized, then the dictionary will * recognize it as a capitalized word when searched. */ public synchronized void addWordToUserDictionary(final String word) { - // TODO: do something for the UI. With the following, any sufficiently long word will - // look like it will go to the user dictionary but it won't. - // Safeguard against adding long words. Can cause stack overflow. - if (word.length() >= MAX_WORD_LENGTH) return; - - Intent intent = new Intent(ACTION_USER_DICTIONARY_INSERT); - intent.putExtra(Words.WORD, word); - intent.putExtra(Words.LOCALE, mLocale); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(intent); + // Update the user dictionary provider + final Locale locale; + if (USER_DICTIONARY_ALL_LANGUAGES == mLocale) { + locale = null; + } else { + locale = LocaleUtils.constructLocaleFromString(mLocale); + } + UserDictionaryCompatUtils.addWord(mContext, word, + HISTORICAL_DEFAULT_USER_DICTIONARY_FREQUENCY, null, locale); } private int scaleFrequencyFromDefaultToLatinIme(final int defaultFrequency) { |