diff options
Diffstat (limited to 'java')
4 files changed, 29 insertions, 14 deletions
diff --git a/java/res/layout/user_dictionary_add_word_fullscreen.xml b/java/res/layout/user_dictionary_add_word_fullscreen.xml index 75e86c509..219485b66 100644 --- a/java/res/layout/user_dictionary_add_word_fullscreen.xml +++ b/java/res/layout/user_dictionary_add_word_fullscreen.xml @@ -19,12 +19,6 @@ android:layout_height="wrap_content" android:orientation="vertical" > - <TextView - style="?android:attr/listSeparatorTextViewStyle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/user_dict_settings_add_screen_title" /> - <EditText android:id="@+id/user_dictionary_add_word_text" android:layout_width="match_parent" diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java index fb75d6dc0..618322357 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java @@ -66,6 +66,8 @@ public final class DictionarySettingsFragment extends PreferenceFragment private boolean mChangedSettings; private DictionaryListInterfaceState mDictionaryListInterfaceState = new DictionaryListInterfaceState(); + private TreeMap<String, WordListPreference> mCurrentPreferenceMap = + new TreeMap<String, WordListPreference>(); // never null private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() { @Override @@ -278,7 +280,7 @@ public final class DictionarySettingsFragment extends PreferenceFragment return result; } else { final String systemLocaleString = Locale.getDefault().toString(); - final TreeMap<String, WordListPreference> prefList = + final TreeMap<String, WordListPreference> prefMap = new TreeMap<String, WordListPreference>(); final int idIndex = cursor.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN); final int versionIndex = cursor.getColumnIndex(MetadataDbHelper.VERSION_COLUMN); @@ -299,16 +301,31 @@ public final class DictionarySettingsFragment extends PreferenceFragment // The key is sorted in lexicographic order, according to the match level, then // the description. final String key = matchLevelString + "." + description + "." + wordlistId; - final WordListPreference existingPref = prefList.get(key); + final WordListPreference existingPref = prefMap.get(key); if (null == existingPref || hasPriority(status, existingPref.mStatus)) { - final WordListPreference pref = new WordListPreference(activity, - mDictionaryListInterfaceState, mClientId, wordlistId, version, locale, - description, status, filesize); - prefList.put(key, pref); + final WordListPreference oldPreference = mCurrentPreferenceMap.get(key); + final WordListPreference pref; + if (null != oldPreference + && oldPreference.mVersion == version + && oldPreference.mLocale.equals(locale)) { + // If the old preference has all the new attributes, reuse it. We test + // for version and locale because although attributes other than status + // need to be the same, others have been tested through the key of the + // map. Also, status may differ so we don't want to use #equals() here. + pref = oldPreference; + pref.mStatus = status; + } else { + // Otherwise, discard it and create a new one instead. + pref = new WordListPreference(activity, mDictionaryListInterfaceState, + mClientId, wordlistId, version, locale, description, status, + filesize); + } + prefMap.put(key, pref); } } while (cursor.moveToNext()); cursor.close(); - return prefList.values(); + mCurrentPreferenceMap = prefMap; + return prefMap.values(); } } diff --git a/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java b/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java index 29015d61b..451a0fb82 100644 --- a/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java +++ b/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java @@ -58,6 +58,8 @@ public final class WordListPreference extends Preference { // The metadata word list id and version of this word list. public final String mWordlistId; public final int mVersion; + public final Locale mLocale; + public final String mDescription; // The status public int mStatus; // The size of the dictionary file @@ -80,6 +82,8 @@ public final class WordListPreference extends Preference { mVersion = version; mWordlistId = wordlistId; mFilesize = filesize; + mLocale = locale; + mDescription = description; setLayoutResource(R.layout.dictionary_line); diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java index 93ff26466..70363e602 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java @@ -145,7 +145,7 @@ public class GestureStroke { public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) { mKeyWidth = keyWidth; mMinYCoordinate = -(int)(keyboardHeight * EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO); - mMaxYCoordinate = keyboardHeight - 1; + mMaxYCoordinate = keyboardHeight; // TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key? mDetectFastMoveSpeedThreshold = (int)(keyWidth * mParams.mDetectFastMoveSpeedThreshold); mGestureDynamicDistanceThresholdFrom = |