From 4f2535398a627e82509a996f616d03aa7f4a75c7 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 15 Apr 2013 18:46:57 +0900 Subject: [PATCH] Add edit personal dictionary settings menu Bug: 8600958 Change-Id: I303adfbe25a56cc9b5ee9f3b5169a5bca0ad6c4a --- java/res/values/strings.xml | 3 +++ java/res/xml/prefs.xml | 5 +++++ .../com/android/inputmethod/latin/Settings.java | 1 + .../inputmethod/latin/SettingsFragment.java | 15 +++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 10cfc786b..673e9dd5a 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -107,6 +107,9 @@ Capitalize the first word of each sentence + + Personal dictionary + Add-on dictionaries diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 1581e5fa1..6de95f48e 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -53,6 +53,11 @@ + + + diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 72e08700a..f5155d10b 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -36,6 +36,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static final String PREF_POPUP_ON = "popup_on"; public static final String PREF_VOICE_MODE = "voice_mode"; public static final String PREF_CORRECTION_SETTINGS = "correction_settings"; + public static final String PREF_EDIT_PERSONAL_DICTIONARY = "edit_personal_dictionary"; public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key"; public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold"; public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting"; diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java index 79036c276..6c856ba7e 100644 --- a/java/src/com/android/inputmethod/latin/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java @@ -20,6 +20,8 @@ import android.app.backup.BackupManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.media.AudioManager; import android.os.Bundle; @@ -29,6 +31,7 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; +import android.util.Log; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.dictionarypack.DictionarySettingsActivity; @@ -38,6 +41,8 @@ import com.android.inputmethodcommon.InputMethodSettingsFragment; public final class SettingsFragment extends InputMethodSettingsFragment implements SharedPreferences.OnSharedPreferenceChangeListener { + private static final String TAG = SettingsFragment.class.getSimpleName(); + private ListPreference mVoicePreference; private ListPreference mShowCorrectionSuggestionsPreference; private ListPreference mAutoCorrectionThresholdPreference; @@ -183,6 +188,16 @@ public final class SettingsFragment extends InputMethodSettingsFragment textCorrectionGroup.removePreference(dictionaryLink); } + final Preference editPersonalDictionary = + findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY); + final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent(); + final ResolveInfo ri = context.getPackageManager().resolveActivity( + editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY); + if (ri == null) { + // TODO: Set a intent that invokes our own edit personal dictionary activity. + Log.w(TAG, "No activity that responds to " + editPersonalDictionaryIntent.getAction()); + } + if (!Settings.readFromBuildConfigIfGestureInputEnabled(res)) { removePreference(Settings.PREF_GESTURE_SETTINGS, getPreferenceScreen()); }