am f36da2fd: Merge "Make dump dictionary settings easily extensible."

* commit 'f36da2fdba7d3a3359e664302b977c8dc12c0fa4':
  Make dump dictionary settings easily extensible.
main
Keisuke Kuroyanagi 2014-06-10 11:10:47 +00:00 committed by Android Git Automerger
commit e25f23d2a3
4 changed files with 23 additions and 45 deletions

View File

@ -349,14 +349,8 @@ mobile devices. [CHAR LIMIT=25] -->
<string name="read_external_dictionary_confirm_install_message">Really install this file for <xliff:g id="LANGUAGE_NAME" example="English">%s</xliff:g>?</string>
<!-- Title for an error dialog that contains the details of the error in the body [CHAR LIMIT=80] -->
<string name="error">There was an error</string>
<!-- Title of the settings for dumpping contacts dictionary file [CHAR LIMIT=35] -->
<string name="prefs_dump_contacts_dict">Dump contacts dictionary</string>
<!-- Title of the settings for dumpping personal dictionary file [CHAR LIMIT=35] -->
<string name="prefs_dump_user_dict">Dump personal dictionary</string>
<!-- Title of the settings for dumpping user history dictionary file [CHAR LIMIT=35] -->
<string name="prefs_dump_user_history_dict">Dump user history dictionary</string>
<!-- Title of the settings for dumpping personalization dictionary file [CHAR LIMIT=35] -->
<string name="prefs_dump_personalization_dict">Dump personalization dictionary</string>
<!-- Title of the settings group for dumpping dictionary files that have been created on the device [CHAR LIMIT=35] -->
<string name="prefs_dump_dynamic_dicts" translatable="false">Dump dictionary</string>
<!-- Title of the button to revert to the default value of the device in the settings dialog [CHAR LIMIT=15] -->
<string name="button_default">Default</string>

View File

@ -61,16 +61,8 @@
<PreferenceScreen
android:key="read_external_dictionary"
android:title="@string/prefs_read_external_dictionary" />
<PreferenceScreen
android:key="dump_contacts_dict"
android:title="@string/prefs_dump_contacts_dict" />
<PreferenceScreen
android:key="dump_user_dict"
android:title="@string/prefs_dump_user_dict" />
<PreferenceScreen
android:key="dump_user_history_dict"
android:title="@string/prefs_dump_user_history_dict" />
<PreferenceScreen
android:key="dump_personalization_dict"
android:title="@string/prefs_dump_personalization_dict" />
<PreferenceCategory
android:key="pref_key_dump_dictionaries"
android:title="@string/prefs_dump_dynamic_dicts">
</PreferenceCategory>
</PreferenceScreen>

View File

@ -74,7 +74,7 @@ public class DictionaryFacilitator {
Dictionary.TYPE_CONTEXTUAL
};
private static final Map<String, Class<? extends ExpandableBinaryDictionary>>
public static final Map<String, Class<? extends ExpandableBinaryDictionary>>
DICT_TYPE_TO_CLASS = new HashMap<>();
static {

View File

@ -25,10 +25,12 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.DictionaryDumpBroadcastReceiver;
import com.android.inputmethod.latin.DictionaryFacilitator;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.debug.ExternalDictionaryGetterForDebug;
import com.android.inputmethod.latin.utils.ApplicationUtils;
@ -48,10 +50,9 @@ public final class DebugSettings extends PreferenceFragment
public static final String PREF_KEY_PREVIEW_DISMISS_DURATION =
"pref_key_preview_dismiss_duration";
private static final String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
private static final String PREF_DUMP_CONTACTS_DICT = "dump_contacts_dict";
private static final String PREF_DUMP_USER_DICT = "dump_user_dict";
private static final String PREF_DUMP_USER_HISTORY_DICT = "dump_user_history_dict";
private static final String PREF_DUMP_PERSONALIZATION_DICT = "dump_personalization_dict";
private static final String PREF_KEY_DUMP_DICTS = "pref_key_dump_dictionaries";
private static final String PREF_KEY_DUMP_DICT_PREFIX = "pref_key_dump_dictionaries";
private static final String DICT_NAME_KEY_FOR_EXTRAS = "dict_name";
public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "pref_sliding_key_input_preview";
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
@ -80,16 +81,18 @@ public final class DebugSettings extends PreferenceFragment
});
}
final PreferenceGroup dictDumpPreferenceGroup =
(PreferenceGroup)findPreference(PREF_KEY_DUMP_DICTS);
final OnPreferenceClickListener dictDumpPrefClickListener =
new DictDumpPrefClickListener(this);
findPreference(PREF_DUMP_CONTACTS_DICT).setOnPreferenceClickListener(
dictDumpPrefClickListener);
findPreference(PREF_DUMP_USER_DICT).setOnPreferenceClickListener(
dictDumpPrefClickListener);
findPreference(PREF_DUMP_USER_HISTORY_DICT).setOnPreferenceClickListener(
dictDumpPrefClickListener);
findPreference(PREF_DUMP_PERSONALIZATION_DICT).setOnPreferenceClickListener(
dictDumpPrefClickListener);
for (final String dictName : DictionaryFacilitator.DICT_TYPE_TO_CLASS.keySet()) {
final Preference preference = new Preference(getActivity());
preference.setKey(PREF_KEY_DUMP_DICT_PREFIX + dictName);
preference.setTitle("Dump " + dictName + " dictionary");
preference.setOnPreferenceClickListener(dictDumpPrefClickListener);
preference.getExtras().putString(DICT_NAME_KEY_FOR_EXTRAS, dictName);
dictDumpPreferenceGroup.addPreference(preference);
}
final Resources res = getResources();
setupKeyLongpressTimeoutSettings(prefs, res);
setupKeyPreviewAnimationDuration(prefs, res, PREF_KEY_PREVIEW_SHOW_UP_DURATION,
@ -117,18 +120,7 @@ public final class DebugSettings extends PreferenceFragment
@Override
public boolean onPreferenceClick(final Preference arg0) {
final String dictName;
if (arg0.getKey().equals(PREF_DUMP_CONTACTS_DICT)) {
dictName = Dictionary.TYPE_CONTACTS;
} else if (arg0.getKey().equals(PREF_DUMP_USER_DICT)) {
dictName = Dictionary.TYPE_USER;
} else if (arg0.getKey().equals(PREF_DUMP_USER_HISTORY_DICT)) {
dictName = Dictionary.TYPE_USER_HISTORY;
} else if (arg0.getKey().equals(PREF_DUMP_PERSONALIZATION_DICT)) {
dictName = Dictionary.TYPE_PERSONALIZATION;
} else {
dictName = null;
}
final String dictName = arg0.getExtras().getString(DICT_NAME_KEY_FOR_EXTRAS);
if (dictName != null) {
final Intent intent =
new Intent(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);