diff options
author | 2012-05-14 20:38:23 -0700 | |
---|---|---|
committer | 2012-05-14 20:38:23 -0700 | |
commit | 8dced70b062744a2c27e0cf6dcd0787cf598a97c (patch) | |
tree | 76097450249f6d73569307936dcf242b948afe96 /java/src/com/android/inputmethod/latin/UserDictionary.java | |
parent | 30236efee1bdac32d2c5b5c2875191a05e690865 (diff) | |
parent | 19ad9bf1457af47d98d6464392ca2e1c431f9d1f (diff) | |
download | latinime-8dced70b062744a2c27e0cf6dcd0787cf598a97c.tar.gz latinime-8dced70b062744a2c27e0cf6dcd0787cf598a97c.tar.xz latinime-8dced70b062744a2c27e0cf6dcd0787cf598a97c.zip |
Merge "Read and use user dictionary shortcuts." into jb-dev
Diffstat (limited to 'java/src/com/android/inputmethod/latin/UserDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/UserDictionary.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java index 6beeaace9..218bac72a 100644 --- a/java/src/com/android/inputmethod/latin/UserDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserDictionary.java @@ -31,8 +31,11 @@ import java.util.Arrays; public class UserDictionary extends ExpandableDictionary { + // TODO: use Words.SHORTCUT when it's public in the SDK + final static String SHORTCUT = "shortcut"; private static final String[] PROJECTION_QUERY = { Words.WORD, + SHORTCUT, Words.FREQUENCY, }; @@ -149,15 +152,18 @@ public class UserDictionary extends ExpandableDictionary { } /** - * Adds a word to the dictionary and makes it persistent. + * 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. * @param frequency the frequency of occurrence of the word. A frequency of 255 is considered * the highest. * @TODO use a higher or float range for frequency */ - @Override - public synchronized void addWord(final String word, final int frequency) { + public synchronized void addWordToUserDictionary(final String word, final int frequency) { // Force load the dictionary here synchronously if (getRequiresReload()) loadDictionaryAsync(); // TODO: do something for the UI. With the following, any sufficiently long word will @@ -191,14 +197,19 @@ public class UserDictionary extends ExpandableDictionary { final int maxWordLength = getMaxWordLength(); if (cursor.moveToFirst()) { final int indexWord = cursor.getColumnIndex(Words.WORD); + final int indexShortcut = cursor.getColumnIndex(SHORTCUT); final int indexFrequency = cursor.getColumnIndex(Words.FREQUENCY); while (!cursor.isAfterLast()) { String word = cursor.getString(indexWord); + String shortcut = cursor.getString(indexShortcut); int frequency = cursor.getInt(indexFrequency); // Safeguard against adding really long words. Stack may overflow due // to recursion if (word.length() < maxWordLength) { - super.addWord(word, frequency); + super.addWord(word, null, frequency); + } + if (null != shortcut && shortcut.length() < maxWordLength) { + super.addWord(shortcut, word, frequency); } cursor.moveToNext(); } |