aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java7
-rw-r--r--java/src/com/android/inputmethod/latin/UserDictionary.java20
2 files changed, 25 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index b8590a76e..3f604a381 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -53,6 +53,7 @@ public class Settings extends PreferenceActivity
public static final String PREF_VOICE_SETTINGS_KEY = "voice_mode";
public static final String PREF_INPUT_LANGUAGE = "input_language";
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
+ public static final String PREF_SUBTYPES = "subtype_settings";
public static final String PREF_PREDICTION_SETTINGS_KEY = "prediction_settings";
public static final String PREF_QUICK_FIXES = "quick_fixes";
@@ -119,6 +120,12 @@ public class Settings extends PreferenceActivity
getPreferenceScreen().removePreference(
getPreferenceScreen().findPreference(PREF_VIBRATE_ON));
}
+
+ final boolean showSubtypeSettings = getResources().getBoolean(
+ R.bool.config_enable_show_subtype_settings);
+ if (!showSubtypeSettings) {
+ getPreferenceScreen().removePreference(findPreference(PREF_SUBTYPES));
+ }
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java
index 7a94ae480..e03f56498 100644
--- a/java/src/com/android/inputmethod/latin/UserDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserDictionary.java
@@ -21,6 +21,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
+import android.net.Uri;
import android.provider.UserDictionary.Words;
public class UserDictionary extends ExpandableDictionary {
@@ -80,7 +81,7 @@ public class UserDictionary extends ExpandableDictionary {
* @TODO use a higher or float range for frequency
*/
@Override
- public synchronized void addWord(String word, int frequency) {
+ public synchronized void addWord(final String word, final int frequency) {
// Force load the dictionary here synchronously
if (getRequiresReload()) loadDictionaryAsync();
// Safeguard against adding long words. Can cause stack overflow.
@@ -99,7 +100,22 @@ public class UserDictionary extends ExpandableDictionary {
new Thread("addWord") {
@Override
public void run() {
- contentResolver.insert(Words.CONTENT_URI, values);
+ Cursor cursor = contentResolver.query(Words.CONTENT_URI, PROJECTION,
+ "word=? and ((locale IS NULL) or (locale=?))",
+ new String[] { word, mLocale }, null);
+ if (cursor != null && cursor.moveToFirst()) {
+ String locale = cursor.getString(cursor.getColumnIndex(Words.LOCALE));
+ // If locale is null, we will not override the entry.
+ if (locale != null && locale.equals(mLocale.toString())) {
+ long id = cursor.getLong(cursor.getColumnIndex(Words._ID));
+ Uri uri = Uri.withAppendedPath(Words.CONTENT_URI, Long.toString(id));
+ // Update the entry with new frequency value.
+ contentResolver.update(uri, values, null, null);
+ }
+ } else {
+ // Insert new entry.
+ contentResolver.insert(Words.CONTENT_URI, values);
+ }
}
}.start();