Implement new design for settings of InputMethods

Change-Id: I82392e4a028abe2d588622a7e89fd035966f603a
This commit is contained in:
satok
2010-12-15 04:57:24 +09:00
parent 9be84b1596
commit c88a7ff1ef
9 changed files with 547 additions and 259 deletions

View File

@@ -332,7 +332,6 @@
android:clearTaskOnLaunch="true"> android:clearTaskOnLaunch="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.INPUT_METHOD_SETTINGS" />
<action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" /> <action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" />
<category android:name="android.intent.category.VOICE_LAUNCH" /> <category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -365,6 +364,23 @@
android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" /> android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" />
</activity> </activity>
<activity android:name="Settings$InputMethodConfigActivity"
android:theme="@android:style/Theme.Holo"
android:label="@string/configure_input_method"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.INPUT_METHOD_SETTINGS" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.inputmethod.InputMethodConfig" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/language_settings" />
</activity>
<activity android:name="PhysicalKeyboardSettings" <activity android:name="PhysicalKeyboardSettings"
android:label="@string/builtin_keyboard_settings_title" android:label="@string/builtin_keyboard_settings_title"
android:theme="@android:style/Theme.Holo.DialogWhenLarge"> android:theme="@android:style/Theme.Holo.DialogWhenLarge">

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="input_method_selector_titles">
<item>@string/input_method_selector_show_automatically_title</item>
<item>@string/input_method_selector_always_show_title</item>
<item>@string/input_method_selector_always_hide_title</item>
</string-array>
<!-- values for input method selector should be corresponding to the array index of titles -->
<string name="input_method_selector_show_automatically_value">0</string>
<string name="input_method_selector_always_show_value">1</string>
<string name="input_method_selector_always_hide_value">2</string>
<string name="input_method_selector_visibility_default_value">0</string>
<string-array name="input_method_selector_values">
<item>@string/input_method_selector_show_automatically_value</item>
<item>@string/input_method_selector_always_show_value</item>
<item>@string/input_method_selector_always_hide_value</item>
</string-array>
</resources>

View File

@@ -2254,13 +2254,30 @@ found in the list of installed applications.</string>
<string name="input_methods_settings_title">Text input</string> <string name="input_methods_settings_title">Text input</string>
<!-- Setting name for Input Method chooser --> <!-- Setting name for Input Method chooser -->
<string name="input_method">Input method</string> <string name="input_method">Input method</string>
<!-- Title for selecting the current input method -->
<string name="current_input_method">Current input method</string>
<!-- Title for setting the visibility of input method selector-->
<string name="input_method_selector">Input method selector</string>
<!-- An option to always show input method selector automatically when needed -->
<string name="input_method_selector_show_automatically_title">Automatic</string>
<!-- An option to always show input method selector -->
<string name="input_method_selector_always_show_title">Always show</string>
<!-- An option to always hide input method selector -->
<string name="input_method_selector_always_hide_title">Always hide</string>
<!-- Title for configuring input method settings -->
<string name="configure_input_method">Configure input methods</string>
<!-- Title for settings of each IME -->
<string name="input_method_settings">Settings</string>
<!-- Title for settings of active input methods in each IME -->
<string name="active_input_method_subtypes">Active input methods</string>
<string name="input_methods_settings_summary">Manage text input options</string> <string name="input_methods_settings_summary">Manage text input options</string>
<!-- Input Methods Settings localized format string for generating the appropriate "Foo settings" menu label for the Input Method named "Foo" --> <!-- Input Methods Settings localized format string for generating the appropriate "Foo settings" menu label for the Input Method named "Foo" -->
<string name="input_methods_settings_label_format"><xliff:g id="ime_name">%1$s</xliff:g> settings</string> <string name="input_methods_settings_label_format"><xliff:g id="ime_name">%1$s</xliff:g> settings</string>
<!-- The title for the item to manage the settings of enabled the input methods and subtypes. --> <!-- Title for the settings of selecting active input methods of an IME -->
<string name="input_methods_and_subtype_enabler_title">Manage Input Methods</string> <string name="input_methods_and_subtype_enabler_title">Select active input methods</string>
<!-- Label for selecting the input methods and subtypes to use --> <!-- Title format for active input methods. "Active input methods in Foo" menu label for the IME named "Foo" -->
<string name="input_methods_and_subtype_enabler_title_format">Manage input methods in <xliff:g id="ime_application_name">%1$s</xliff:g></string> <string name="input_methods_and_subtype_enabler_title_format">Active input methods in <xliff:g id="ime_application_name">%1$s</xliff:g></string>
<!-- Summary for on-screen keyboard settings --> <!-- Summary for on-screen keyboard settings -->
<string name="onscreen_keyboard_settings_summary">Onscreen keyboard settings</string> <string name="onscreen_keyboard_settings_summary">Onscreen keyboard settings</string>
<!-- Title for built-in keyboard settings --> <!-- Title for built-in keyboard settings -->

View File

@@ -57,18 +57,20 @@
<PreferenceCategory android:key="keyboard_settings_category" <PreferenceCategory android:key="keyboard_settings_category"
android:title="@string/keyboard_settings_category"> android:title="@string/keyboard_settings_category">
<PreferenceScreen android:key="current_input_method"
<PreferenceScreen android:key="input_method" android:title="@string/current_input_method"
android:title="@string/input_method"
android:widgetLayout="@*android:layout/preference_dialog" /> android:widgetLayout="@*android:layout/preference_dialog" />
<ListPreference android:key="input_method_selector"
android:title="@string/input_method_selector"
android:persistent="true"
android:entryValues="@array/input_method_selector_values"
android:entries="@array/input_method_selector_titles"
android:defaultValue="@string/input_method_selector_visibility_default_value"/>
<PreferenceScreen android:key="configure_input_method"
android:title="@string/configure_input_method">
<intent android:action="android.settings.INPUT_METHOD_SETTINGS"/>
</PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceScreen
android:fragment="com.android.settings.PhysicalKeyboardSettings"
android:key="hardkeyboard_category"
android:title="@string/builtin_keyboard_settings_title"
android:summary="@string/builtin_keyboard_settings_summary">
</PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -302,6 +302,7 @@ public class Settings extends PreferenceActivity {
public static class StorageSettingsActivity extends Settings { } public static class StorageSettingsActivity extends Settings { }
public static class WifiSettingsActivity extends Settings { } public static class WifiSettingsActivity extends Settings { }
public static class InputMethodAndLanguageSettingsActivity extends Settings { } public static class InputMethodAndLanguageSettingsActivity extends Settings { }
public static class InputMethodConfigActivity extends Settings { }
public static class InputMethodAndSubtypeEnablerActivity extends Settings { } public static class InputMethodAndSubtypeEnablerActivity extends Settings { }
public static class LocalePickerActivity extends Settings { } public static class LocalePickerActivity extends Settings { }
public static class UserDictionarySettingsActivity extends Settings { } public static class UserDictionarySettingsActivity extends Settings { }

View File

@@ -26,127 +26,74 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment { public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener{
private static final String KEY_PHONE_LANGUAGE = "phone_language"; private static final String KEY_PHONE_LANGUAGE = "phone_language";
private static final String KEY_INPUT_METHOD = "input_method"; private static final String KEY_CURRENT_INPUT_METHOD = "current_input_method";
private static final String KEY_KEYBOARD_SETTINGS_CATEGORY = "keyboard_settings_category"; private static final String KEY_INPUT_METHOD_SELECTOR = "input_method_selector";
private static final String KEY_HARDKEYBOARD_CATEGORY = "hardkeyboard_category";
private boolean mHaveHardKeyboard;
private List<InputMethodInfo> mInputMethodProperties; private int mDefaultInputMethodSelectorVisibility = 0;
private List<CheckBoxPreference> mCheckboxes; private ListPreference mShowInputMethodSelectorPref;
private Preference mLanguagePref; private Preference mLanguagePref;
final TextUtils.SimpleStringSplitter mStringColonSplitter
= new TextUtils.SimpleStringSplitter(':');
private AlertDialog mDialog = null;
static public String getInputMethodIdFromKey(String key) {
return key;
}
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
addPreferencesFromResource(R.xml.language_settings); addPreferencesFromResource(R.xml.language_settings);
try {
mDefaultInputMethodSelectorVisibility = Integer.valueOf(
getString(R.string.input_method_selector_visibility_default_value));
} catch (NumberFormatException e) {
}
if (getActivity().getAssets().getLocales().length == 1) { if (getActivity().getAssets().getLocales().length == 1) {
getPreferenceScreen(). // No "Select language" pref if there's only one system locale available.
removePreference(findPreference(KEY_PHONE_LANGUAGE)); getPreferenceScreen().removePreference(findPreference(KEY_PHONE_LANGUAGE));
} else { } else {
mLanguagePref = findPreference(KEY_PHONE_LANGUAGE); mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
} }
mShowInputMethodSelectorPref = (ListPreference)findPreference(
Configuration config = getResources().getConfiguration(); KEY_INPUT_METHOD_SELECTOR);
if (config.keyboard != Configuration.KEYBOARD_QWERTY) { mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
getPreferenceScreen().removePreference( // TODO: Update current input method name on summary
getPreferenceScreen().findPreference(KEY_HARDKEYBOARD_CATEGORY)); updateInputMethodSelectorSummary(loadInputMethodSelectorVisibility());
} else {
mHaveHardKeyboard = true;
}
mCheckboxes = new ArrayList<CheckBoxPreference>();
onCreateIMM();
new VoiceInputOutputSettings(this).onCreate(); new VoiceInputOutputSettings(this).onCreate();
} }
private boolean isSystemIme(InputMethodInfo property) { private void updateInputMethodSelectorSummary(int value) {
return (property.getServiceInfo().applicationInfo.flags String[] inputMethodSelectorTitles = getResources().getStringArray(
& ApplicationInfo.FLAG_SYSTEM) != 0; R.array.input_method_selector_titles);
} if (inputMethodSelectorTitles.length > value) {
mShowInputMethodSelectorPref.setSummary(inputMethodSelectorTitles[value]);
private void onCreateIMM() { mShowInputMethodSelectorPref.setValue(String.valueOf(value));
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
mInputMethodProperties = imm.getInputMethodList();
PreferenceGroup keyboardSettingsCategory = (PreferenceGroup) findPreference(
KEY_KEYBOARD_SETTINGS_CATEGORY);
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties
.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getActivity().getPackageManager());
boolean systemIME = isSystemIme(property);
// Add a check box.
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
mCheckboxes.add(chkbxPref);
}
// If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label);
if (N == 1) {
prefScreen.setSummary(getResources().getString(
R.string.onscreen_keyboard_settings_summary));
} else {
CharSequence settingsLabel = getResources().getString(
R.string.input_methods_settings_label_format, label);
prefScreen.setSummary(settingsLabel);
}
keyboardSettingsCategory.addPreference(prefScreen);
}
} }
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties);
if (mLanguagePref != null) { if (mLanguagePref != null) {
Configuration conf = getResources().getConfiguration(); Configuration conf = getResources().getConfiguration();
String locale = conf.locale.getDisplayName(conf.locale); String locale = conf.locale.getDisplayName(conf.locale);
@@ -155,107 +102,58 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
mLanguagePref.setSummary(locale); mLanguagePref.setSummary(locale);
} }
} }
mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), mShowInputMethodSelectorPref.setOnPreferenceChangeListener(null);
mInputMethodProperties, mHaveHardKeyboard);
} }
@Override @Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
// Input Method stuff // Input Method stuff
if (Utils.isMonkeyRunning()) { if (Utils.isMonkeyRunning()) {
return false; return false;
} }
if (preference instanceof PreferenceScreen) {
if (preference instanceof CheckBoxPreference) {
final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
final String id = getInputMethodIdFromKey(chkPref.getKey());
if (chkPref.isChecked()) {
InputMethodInfo selImi = null;
final int N = mInputMethodProperties.size();
for (int i=0; i<N; i++) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (id.equals(imi.getId())) {
selImi = imi;
if (isSystemIme(imi)) {
// This is a built-in IME, so no need to warn.
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
}
}
chkPref.setChecked(false);
if (selImi == null) {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
if (mDialog == null) {
// TODO: DialogFragment?
mDialog = (new AlertDialog.Builder(getActivity()))
.setTitle(android.R.string.dialog_alert_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true);
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
} else {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
mDialog.setMessage(getResources().getString(
R.string.ime_security_warning,
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show();
}
} else if (preference instanceof PreferenceScreen) {
if (preference.getFragment() != null) { if (preference.getFragment() != null) {
// Fragment will be handled correctly by the super class. // Fragment will be handled correctly by the super class.
} else if (KEY_INPUT_METHOD.equals(preference.getKey())) { } else if (KEY_CURRENT_INPUT_METHOD.equals(preference.getKey())) {
final InputMethodManager imm = (InputMethodManager) final InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE); getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showInputMethodPicker(); imm.showInputMethodPicker();
} else if (preference.getIntent() == null) {
PreferenceScreen pref = (PreferenceScreen) preference;
String activityName = pref.getKey();
String packageName = activityName.substring(0, activityName
.lastIndexOf("."));
int slash = activityName.indexOf("/");
if (slash > 0) {
packageName = activityName.substring(0, slash);
activityName = activityName.substring(slash + 1);
}
if (activityName.length() > 0) {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName(packageName, activityName);
startActivity(i);
}
} }
} }
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
@Override private void saveInputMethodSelectorVisibility(String value) {
public void onDestroy() { try {
super.onDestroy(); int intValue = Integer.valueOf(value);
if (mDialog != null) { Settings.Secure.putInt(getContentResolver(),
mDialog.dismiss(); Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, intValue);
mDialog = null; updateInputMethodSelectorSummary(intValue);
} catch(NumberFormatException e) {
} }
} }
private int loadInputMethodSelectorVisibility() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY,
mDefaultInputMethodSelectorVisibility);
}
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference == mShowInputMethodSelectorPref) {
if (value instanceof String) {
saveInputMethodSelectorVisibility((String)value);
}
}
return false;
}
} }

View File

@@ -29,26 +29,32 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment { public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
private boolean mHaveHardKeyboard; public static final String EXTRA_INPUT_METHOD_ID = "input_method_id";
private List<InputMethodInfo> mInputMethodProperties;
private AlertDialog mDialog = null; private AlertDialog mDialog = null;
private boolean mHaveHardKeyboard;
final private HashMap<String, List<Preference>> mInputMethodPrefsMap =
new HashMap<String, List<Preference>>();
private List<InputMethodInfo> mInputMethodProperties;
private String mInputMethodId;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
Configuration config = getResources().getConfiguration(); Configuration config = getResources().getConfiguration();
mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY); mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
mInputMethodId = getActivity().getIntent().getStringExtra(EXTRA_INPUT_METHOD_ID);
onCreateIMM(); onCreateIMM();
setPreferenceScreen(createPreferenceHierarchy()); setPreferenceScreen(createPreferenceHierarchy());
} }
@@ -57,7 +63,7 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties); this, getContentResolver(), mInputMethodProperties, mInputMethodPrefsMap);
} }
@Override @Override
@@ -156,53 +162,48 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity()); PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size()); int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
// TODO: Use iterator.
for (int i = 0; i < N; ++i) { for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = mInputMethodProperties.get(i);
if (imi.getSubtypes().size() <= 1) continue;
String imiId = imi.getId();
// Add to this subtype the list when no IME is specified or when the IME of this
// subtype is the specified IME.
if (!TextUtils.isEmpty(mInputMethodId) && !mInputMethodId.equals(imiId)) {
continue;
}
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity()); PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
root.addPreference(keyboardSettingsCategory); root.addPreference(keyboardSettingsCategory);
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
CharSequence label = property.loadLabel(pm); CharSequence label = imi.loadLabel(pm);
boolean systemIME = InputMethodAndSubtypeUtil.isSystemIme(property);
keyboardSettingsCategory.setTitle(label); keyboardSettingsCategory.setTitle(getResources().getString(
R.string.input_methods_and_subtype_enabler_title_format, label));
keyboardSettingsCategory.setKey(imiId);
// Add a check box. ArrayList<InputMethodSubtype> subtypes = imi.getSubtypes();
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME. ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
}
ArrayList<InputMethodSubtype> subtypes = property.getSubtypes();
if (subtypes.size() > 0) { if (subtypes.size() > 0) {
PreferenceCategory subtypesCategory = new PreferenceCategory(getActivity());
subtypesCategory.setTitle(getResources().getString(
R.string.input_methods_and_subtype_enabler_title_format, label));
root.addPreference(subtypesCategory);
for (InputMethodSubtype subtype: subtypes) { for (InputMethodSubtype subtype: subtypes) {
CharSequence subtypeLabel; CharSequence subtypeLabel;
int nameResId = subtype.getNameResId(); int nameResId = subtype.getNameResId();
if (nameResId != 0) { if (nameResId != 0) {
subtypeLabel = pm.getText(property.getPackageName(), nameResId, subtypeLabel = pm.getText(imi.getPackageName(), nameResId,
property.getServiceInfo().applicationInfo); imi.getServiceInfo().applicationInfo);
} else { } else {
String mode = subtype.getMode(); String mode = subtype.getMode();
CharSequence language = subtype.getLocale(); CharSequence language = subtype.getLocale();
// TODO: Use more friendly Title and UI
subtypeLabel = (mode == null ? "" : mode) + "," subtypeLabel = (mode == null ? "" : mode) + ","
+ (language == null ? "" : language); + (language == null ? "" : language);
} }
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity()); CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(prefKey + subtype.hashCode()); chkbxPref.setKey(imiId + subtype.hashCode());
chkbxPref.setTitle(subtypeLabel); chkbxPref.setTitle(subtypeLabel);
chkbxPref.setSummary(label); keyboardSettingsCategory.addPreference(chkbxPref);
subtypesCategory.addPreference(chkbxPref); subtypePreferences.add(chkbxPref);
} }
mInputMethodPrefsMap.put(imiId, subtypePreferences);
} }
} }
return root; return root;

View File

@@ -21,6 +21,7 @@ import com.android.settings.SettingsPreferenceFragment;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.provider.Settings; import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException; import android.provider.Settings.SettingNotFoundException;
@@ -32,6 +33,7 @@ import android.view.inputmethod.InputMethodSubtype;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
public class InputMethodAndSubtypeUtil { public class InputMethodAndSubtypeUtil {
@@ -48,6 +50,42 @@ public class InputMethodAndSubtypeUtil {
private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER); = new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER);
private static void buildEnabledInputMethodsString(
StringBuilder builder, String imi, HashSet<String> subtypes) {
builder.append(imi);
// Inputmethod and subtypes are saved in the settings as follows:
// ime0;subtype0;subtype1:ime1;subtype0:ime2:ime3;subtype0;subtype1
for (String subtypeId: subtypes) {
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtypeId);
}
}
public static void buildInputMethodsAndSubtypesString(
StringBuilder builder, HashMap<String, HashSet<String>> imsList) {
boolean needsAppendSeparator = false;
for (String imi: imsList.keySet()) {
if (needsAppendSeparator) {
builder.append(INPUT_METHOD_SEPARATER);
} else {
needsAppendSeparator = true;
}
buildEnabledInputMethodsString(builder, imi, imsList.get(imi));
}
}
public static void buildDisabledSystemInputMethods(
StringBuilder builder, HashSet<String> imes) {
boolean needsAppendSeparator = false;
for (String ime: imes) {
if (needsAppendSeparator) {
builder.append(INPUT_METHOD_SEPARATER);
} else {
needsAppendSeparator = true;
}
builder.append(ime);
}
}
private static int getInputMethodSubtypeSelected(ContentResolver resolver) { private static int getInputMethodSubtypeSelected(ContentResolver resolver) {
try { try {
return Settings.Secure.getInt(resolver, return Settings.Secure.getInt(resolver,
@@ -96,82 +134,117 @@ public class InputMethodAndSubtypeUtil {
return imsList; return imsList;
} }
public static void saveInputMethodSubtypeList( private static HashSet<String> getDisabledSystemIMEs(ContentResolver resolver) {
SettingsPreferenceFragment context, ContentResolver resolver, HashSet<String> set = new HashSet<String>();
List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) { String disabledIMEsStr = Settings.Secure.getString(
resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS);
sStringInputMethodSplitter.setString(disabledIMEsStr);
while(sStringInputMethodSplitter.hasNext()) {
set.add(sStringInputMethodSplitter.next());
}
return set;
}
public static void saveInputMethodSubtypeList(SettingsPreferenceFragment context,
ContentResolver resolver, List<InputMethodInfo> inputMethodInfos,
boolean hasHardKeyboard) {
String currentInputMethodId = Settings.Secure.getString(resolver, String currentInputMethodId = Settings.Secure.getString(resolver,
Settings.Secure.DEFAULT_INPUT_METHOD); Settings.Secure.DEFAULT_INPUT_METHOD);
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver); final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
HashMap<String, HashSet<String>> enabledIMEAndSubtypesMap =
getEnabledInputMethodsAndSubtypeList(resolver);
HashSet<String> disabledSystemIMEs = getDisabledSystemIMEs(resolver);
StringBuilder builder = new StringBuilder(); final boolean onlyOneIME = inputMethodInfos.size() == 1;
StringBuilder disabledSysImes = new StringBuilder(); boolean existsSelectedSubtype = false;
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID; for (InputMethodInfo imi : inputMethodInfos) {
final String imiId = imi.getId();
final boolean onlyOneIME = inputMethodProperties.size() == 1; Preference pref = context.findPreference(imiId);
boolean existsSelectedIME = false; if (pref == null) continue;
for (InputMethodInfo property : inputMethodProperties) { // In the Configure input method screen or in the subtype enabler screen.
final String id = property.getId(); // pref is instance of CheckBoxPreference in the Configure input method screen.
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id); final boolean isImeChecked = (pref instanceof CheckBoxPreference) ?
boolean isCurrentInputMethod = id.equals(currentInputMethodId); ((CheckBoxPreference) pref).isChecked()
boolean systemIme = isSystemIme(property); : enabledIMEAndSubtypesMap.containsKey(imiId);
// TODO: Append subtypes by using the separator ";" boolean isCurrentInputMethod = imiId.equals(currentInputMethodId);
if (((onlyOneIME || systemIme) && !hasHardKeyboard) boolean systemIme = isSystemIme(imi);
|| (pref != null && pref.isChecked())) { if (((onlyOneIME || systemIme) && !hasHardKeyboard) || isImeChecked) {
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER); if (!enabledIMEAndSubtypesMap.containsKey(imiId)) {
builder.append(id); // imiId has just been enabled
for (InputMethodSubtype subtype : property.getSubtypes()) { enabledIMEAndSubtypesMap.put(imiId, new HashSet<String>());
}
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
for (InputMethodSubtype subtype : imi.getSubtypes()) {
final String subtypeHashCodeStr = String.valueOf(subtype.hashCode());
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference( CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
id + subtype.hashCode()); imiId + subtypeHashCodeStr);
if (subtypePref != null && subtypePref.isChecked()) { // In the Configure input method screen which does not have subtype preferences.
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode()); if (subtypePref == null) continue;
if (subtypePref.isChecked()) {
subtypesSet.add(subtypeHashCodeStr);
if (isCurrentInputMethod) { if (isCurrentInputMethod) {
if (selectedInputMethodSubtype == subtype.hashCode()) { if (selectedInputMethodSubtype == subtype.hashCode()) {
existsSelectedIME = true; existsSelectedSubtype = true;
} else if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) {
firstSubtypeHashCode = subtype.hashCode();
} }
} }
} else {
subtypesSet.remove(subtypeHashCodeStr);
} }
} }
} else if (isCurrentInputMethod) { } else {
// We are processing the current input method, but found that it's not enabled. enabledIMEAndSubtypesMap.remove(imiId);
// This means that the current input method has been uninstalled. if (isCurrentInputMethod) {
// If currentInputMethod is already uninstalled, InputMethodManagerService will // We are processing the current input method, but found that it's not enabled.
// find the applicable IME from the history and the system locale. // This means that the current input method has been uninstalled.
if (DEBUG) { // If currentInputMethod is already uninstalled, InputMethodManagerService will
Log.d(TAG, "Current IME was uninstalled or disabled."); // find the applicable IME from the history and the system locale.
if (DEBUG) {
Log.d(TAG, "Current IME was uninstalled or disabled.");
}
} }
} }
// If it's a disabled system ime, add it to the disabled list so that it // If it's a disabled system ime, add it to the disabled list so that it
// doesn't get enabled automatically on any changes to the package list // doesn't get enabled automatically on any changes to the package list
if (pref != null && !pref.isChecked() && systemIme && hasHardKeyboard) { if (systemIme && hasHardKeyboard) {
if (disabledSysImes.length() > 0) disabledSysImes.append(INPUT_METHOD_SEPARATER); if (disabledSystemIMEs.contains(imiId)) {
disabledSysImes.append(id); if (isImeChecked) {
disabledSystemIMEs.remove(imiId);
}
} else {
if (!isImeChecked) {
disabledSystemIMEs.add(imiId);
}
}
} }
} }
StringBuilder builder = new StringBuilder();
buildInputMethodsAndSubtypesString(builder, enabledIMEAndSubtypesMap);
StringBuilder disabledSysImesBuilder = new StringBuilder();
buildDisabledSystemInputMethods(disabledSysImesBuilder, disabledSystemIMEs);
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString()); Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
Log.d(TAG, "--- Save disable system inputmethod settings. :" Log.d(TAG, "--- Save disable system inputmethod settings. :"
+ disabledSysImes.toString()); + disabledSysImesBuilder.toString());
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId); Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
} }
// Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype // Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
// selected. And if the selected subtype of the current input method was disabled, // selected. And if the selected subtype of the current input method was disabled,
// We should reset the selected input method's subtype. // We should reset the selected input method's subtype.
if (!existsSelectedIME || !isInputMethodSubtypeSelected(resolver)) { if (!existsSelectedSubtype || !isInputMethodSubtypeSelected(resolver)) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "--- Set inputmethod subtype because it's not defined." Log.d(TAG, "--- Reset inputmethod subtype because it's not defined.");
+ firstSubtypeHashCode);
} }
putSelectedInputMethodSubtype(resolver, firstSubtypeHashCode); putSelectedInputMethodSubtype(resolver, NOT_A_SUBTYPE_ID);
} }
Settings.Secure.putString(resolver, Settings.Secure.putString(resolver,
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString()); Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Settings.Secure.putString(resolver, if (disabledSysImesBuilder.length() > 0) {
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString()); Settings.Secure.putString(resolver, Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
disabledSysImesBuilder.toString());
}
// If the current input method is unset, InputMethodManagerService will find the applicable // If the current input method is unset, InputMethodManagerService will find the applicable
// IME from the history and the system locale. // IME from the history and the system locale.
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
@@ -180,18 +253,25 @@ public class InputMethodAndSubtypeUtil {
public static void loadInputMethodSubtypeList( public static void loadInputMethodSubtypeList(
SettingsPreferenceFragment context, ContentResolver resolver, SettingsPreferenceFragment context, ContentResolver resolver,
List<InputMethodInfo> inputMethodProperties) { List<InputMethodInfo> inputMethodInfos,
final Map<String, List<Preference>> inputMethodPrefsMap) {
HashMap<String, HashSet<String>> enabledSubtypes = HashMap<String, HashSet<String>> enabledSubtypes =
getEnabledInputMethodsAndSubtypeList(resolver); getEnabledInputMethodsAndSubtypeList(resolver);
for (InputMethodInfo property : inputMethodProperties) { for (InputMethodInfo imi : inputMethodInfos) {
final String id = property.getId(); final String imiId = imi.getId();
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id); Preference pref = context.findPreference(imiId);
if (pref != null) { if (pref != null && pref instanceof CheckBoxPreference) {
boolean isEnabled = enabledSubtypes.containsKey(id); CheckBoxPreference checkBoxPreference = (CheckBoxPreference) pref;
pref.setChecked(isEnabled); boolean isEnabled = enabledSubtypes.containsKey(imiId);
setSubtypesPreferenceEnabled(context, inputMethodProperties, id, isEnabled); checkBoxPreference.setChecked(isEnabled);
updateSubtypesPreferenceChecked(context, inputMethodProperties, enabledSubtypes); if (inputMethodPrefsMap != null) {
for (Preference childPref: inputMethodPrefsMap.get(imiId)) {
childPref.setEnabled(isEnabled);
}
}
setSubtypesPreferenceEnabled(context, inputMethodInfos, imiId, isEnabled);
updateSubtypesPreferenceChecked(context, inputMethodInfos, enabledSubtypes);
} }
} }
} }

View File

@@ -0,0 +1,237 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class InputMethodConfig extends SettingsPreferenceFragment {
private static final String KEY_PHYSICALKEYBOARD_CATEGORY = "hardkeyboard_category";
private static final String PHYSICALKEYBOARD_SETTINGS_FRAGMENT
= "com.android.settings.PhysicalKeyboardSettings";
private AlertDialog mDialog = null;
private boolean mHaveHardKeyboard;
// Map of imi and its preferences
final private HashMap<String, List<Preference>> mInputMethodPrefsMap =
new HashMap<String, List<Preference>>();
private List<InputMethodInfo> mInputMethodProperties;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Configuration config = getResources().getConfiguration();
mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
// TODO: Change mInputMethodProperties to Map
mInputMethodProperties = imm.getInputMethodList();
setPreferenceScreen(createPreferenceHierarchy());
}
@Override
public void onResume() {
super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties, mInputMethodPrefsMap);
}
@Override
public void onPause() {
super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard);
}
private void showSecurityWarnDialog(InputMethodInfo imi, final CheckBoxPreference chkPref,
final String imiId) {
if (mDialog == null) {
mDialog = (new AlertDialog.Builder(getActivity()))
.setTitle(android.R.string.dialog_alert_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true);
for (Preference pref: mInputMethodPrefsMap.get(imiId)) {
pref.setEnabled(true);
}
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
} else {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
mDialog.setMessage(getResources().getString(R.string.ime_security_warning,
imi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show();
}
private InputMethodInfo getInputMethodInfoFromImiId(String imiId) {
final int N = mInputMethodProperties.size();
for (int i = 0; i < N; ++i) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (imiId.equals(imi.getId())) {
return imi;
}
}
return null;
}
@Override
public boolean onPreferenceTreeClick(
PreferenceScreen preferenceScreen, Preference preference) {
if (preference instanceof CheckBoxPreference) {
final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
final String imiId = chkPref.getKey();
if (chkPref.isChecked()) {
InputMethodInfo selImi = getInputMethodInfoFromImiId(imiId);
if (selImi != null) {
if (InputMethodAndSubtypeUtil.isSystemIme(selImi)) {
// This is a built-in IME, so no need to warn.
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
chkPref.setChecked(false);
showSecurityWarnDialog(selImi, chkPref, imiId);
} else {
for (Preference pref: mInputMethodPrefsMap.get(imiId)) {
pref.setEnabled(false);
}
}
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@Override
public void onDestroy() {
super.onDestroy();
if (mDialog != null) {
mDialog.dismiss();
mDialog = null;
}
}
private void addHardKeyboardPreference(PreferenceScreen root) {
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
keyboardSettingsCategory.setTitle(R.string.builtin_keyboard_settings_title);
root.addPreference(keyboardSettingsCategory);
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setKey(KEY_PHYSICALKEYBOARD_CATEGORY);
prefScreen.setTitle(R.string.builtin_keyboard_settings_title);
prefScreen.setSummary(R.string.builtin_keyboard_settings_summary);
prefScreen.setFragment(PHYSICALKEYBOARD_SETTINGS_FRAGMENT);
}
private void addInputMethodPreference(PreferenceScreen root, InputMethodInfo imi,
final int imiSize) {
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
root.addPreference(keyboardSettingsCategory);
final String imiId = imi.getId();
mInputMethodPrefsMap.put(imiId, new ArrayList<Preference>());
PackageManager pm = getPackageManager();
CharSequence label = imi.loadLabel(pm);
keyboardSettingsCategory.setTitle(label);
final boolean isSystemIME = InputMethodAndSubtypeUtil.isSystemIme(imi);
// Add a check box for enabling/disabling IME
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
chkbxPref.setKey(imiId);
chkbxPref.setTitle(label);
keyboardSettingsCategory.addPreference(chkbxPref);
// Disable the toggle if it's the only keyboard in the system, or it's a system IME.
if (!mHaveHardKeyboard && (imiSize <= 1 || isSystemIME)) {
chkbxPref.setEnabled(false);
}
Intent intent;
// Add subtype settings when this IME has two or more subtypes.
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setTitle(R.string.active_input_method_subtypes);
if (imi.getSubtypes().size() > 1) {
intent = new Intent(Settings.ACTION_INPUT_METHOD_AND_SUBTYPE_ENABLER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(InputMethodAndSubtypeEnabler.EXTRA_INPUT_METHOD_ID, imiId);
prefScreen.setIntent(intent);
keyboardSettingsCategory.addPreference(prefScreen);
mInputMethodPrefsMap.get(imiId).add(prefScreen);
}
// Add IME settings
String settingsActivity = imi.getSettingsActivity();
if (!TextUtils.isEmpty(settingsActivity)) {
prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setTitle(R.string.input_method_settings);
intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(imi.getPackageName(), settingsActivity);
prefScreen.setIntent(intent);
keyboardSettingsCategory.addPreference(prefScreen);
mInputMethodPrefsMap.get(imiId).add(prefScreen);
}
}
private PreferenceScreen createPreferenceHierarchy() {
// Root
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
if (mHaveHardKeyboard) {
addHardKeyboardPreference(root);
}
final int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
for (int i = 0; i < N; ++i) {
addInputMethodPreference(root, mInputMethodProperties.get(i), N);
}
return root;
}
}