diff options
author | 2011-07-21 22:32:36 -0700 | |
---|---|---|
committer | 2011-07-22 01:32:53 -0700 | |
commit | ada26bb383f5b9de4717a980a3aa8f53d267df93 (patch) | |
tree | f5972b75f9dffd391ca300225b12293a4d329873 /java/src/com/android/inputmethod/latin/UserDictionary.java | |
parent | 68ff3a0a8b1f78c081f53c1d3cc3d966e228089e (diff) | |
download | latinime-ada26bb383f5b9de4717a980a3aa8f53d267df93.tar.gz latinime-ada26bb383f5b9de4717a980a3aa8f53d267df93.tar.xz latinime-ada26bb383f5b9de4717a980a3aa8f53d267df93.zip |
Check user dictionary is enabled before showing touch-to-save
Bug: 5024127
Change-Id: If4d691a4a59c43579d1f977e9a0545495f30bafb
Diffstat (limited to '')
-rw-r--r-- | java/src/com/android/inputmethod/latin/UserDictionary.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java index 2aaa26c8d..f93d24fe6 100644 --- a/java/src/com/android/inputmethod/latin/UserDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserDictionary.java @@ -38,23 +38,24 @@ public class UserDictionary extends ExpandableDictionary { Words.FREQUENCY, Words.LOCALE, }; - + private ContentObserver mObserver; private String mLocale; public UserDictionary(Context context, String locale) { super(context, Suggest.DIC_USER); mLocale = locale; - // Perform a managed query. The Activity will handle closing and requerying the cursor + // Perform a managed query. The Activity will handle closing and re-querying the cursor // when needed. ContentResolver cres = context.getContentResolver(); - - cres.registerContentObserver(Words.CONTENT_URI, true, mObserver = new ContentObserver(null) { + + mObserver = new ContentObserver(null) { @Override public void onChange(boolean self) { setRequiresReload(true); } - }); + }; + cres.registerContentObserver(Words.CONTENT_URI, true, mObserver); loadDictionary(); } @@ -76,6 +77,17 @@ public class UserDictionary extends ExpandableDictionary { addWords(cursor); } + public boolean isEnabled() { + final ContentResolver cr = getContext().getContentResolver(); + final ContentProviderClient client = cr.acquireContentProviderClient(Words.CONTENT_URI); + if (client != null) { + client.release(); + return true; + } else { + return false; + } + } + /** * Adds a word to the dictionary and makes it persistent. * @param word the word to add. If the word is capitalized, then the dictionary will |