aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorEric Fischer <enf@google.com>2009-07-28 16:48:47 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-08-13 17:27:30 -0700
commit2bed1531c2c9bd48096bfa97dd1a39e04bd15e7b (patch)
tree0f95c3c055888f56e1ef911e3ea3b7cd1288df1d /src/com/android/inputmethod/latin/Suggest.java
parentd67fe0e7583f1be18b35b33b7658e4427f1e3ded (diff)
downloadlatinime-2bed1531c2c9bd48096bfa97dd1a39e04bd15e7b.tar.gz
latinime-2bed1531c2c9bd48096bfa97dd1a39e04bd15e7b.tar.xz
latinime-2bed1531c2c9bd48096bfa97dd1a39e04bd15e7b.zip
Have the Latin IME also use the names of your contacts as suggestions.
Bug 1597304
Diffstat (limited to 'src/com/android/inputmethod/latin/Suggest.java')
-rwxr-xr-xsrc/com/android/inputmethod/latin/Suggest.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/com/android/inputmethod/latin/Suggest.java b/src/com/android/inputmethod/latin/Suggest.java
index 9926c2c1c..077d76aba 100755
--- a/src/com/android/inputmethod/latin/Suggest.java
+++ b/src/com/android/inputmethod/latin/Suggest.java
@@ -43,6 +43,8 @@ public class Suggest implements Dictionary.WordCallback {
private Dictionary mAutoDictionary;
+ private Dictionary mContactsDictionary;
+
private int mPrefMaxSuggestions = 12;
private int[] mPriorities = new int[mPrefMaxSuggestions];
@@ -81,6 +83,13 @@ public class Suggest implements Dictionary.WordCallback {
public void setUserDictionary(Dictionary userDictionary) {
mUserDictionary = userDictionary;
}
+
+ /**
+ * Sets an optional contacts dictionary resource to be loaded.
+ */
+ public void setContactsDictionary(Dictionary userDictionary) {
+ mContactsDictionary = userDictionary;
+ }
public void setAutoDictionary(Dictionary autoDictionary) {
mAutoDictionary = autoDictionary;
@@ -110,8 +119,8 @@ public class Suggest implements Dictionary.WordCallback {
if (len <= 2) return true;
int matching = 0;
for (int i = 0; i < len; i++) {
- if (UserDictionary.toLowerCase(original.charAt(i))
- == UserDictionary.toLowerCase(suggestion.charAt(i))) {
+ if (ExpandableDictionary.toLowerCase(original.charAt(i))
+ == ExpandableDictionary.toLowerCase(suggestion.charAt(i))) {
matching++;
}
}
@@ -148,8 +157,14 @@ public class Suggest implements Dictionary.WordCallback {
}
// Search the dictionary only if there are at least 2 characters
if (wordComposer.size() > 1) {
- if (mUserDictionary != null) {
- mUserDictionary.getWords(wordComposer, this);
+ if (mUserDictionary != null || mContactsDictionary != null) {
+ if (mUserDictionary != null) {
+ mUserDictionary.getWords(wordComposer, this);
+ }
+ if (mContactsDictionary != null) {
+ mContactsDictionary.getWords(wordComposer, this);
+ }
+
if (mSuggestions.size() > 0 && isValidWord(mOriginalWord)) {
mHaveCorrection = true;
}
@@ -263,7 +278,8 @@ public class Suggest implements Dictionary.WordCallback {
return (mCorrectionMode == CORRECTION_FULL && mMainDict.isValidWord(word))
|| (mCorrectionMode > CORRECTION_NONE &&
((mUserDictionary != null && mUserDictionary.isValidWord(word)))
- || (mAutoDictionary != null && mAutoDictionary.isValidWord(word)));
+ || (mAutoDictionary != null && mAutoDictionary.isValidWord(word))
+ || (mContactsDictionary != null && mContactsDictionary.isValidWord(word)));
}
private void collectGarbage() {