Merge "Use getDisplayName for the name of InputMethodSubtype"

This commit is contained in:
satok
2011-06-08 04:09:14 -07:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 20 deletions

View File

@@ -188,7 +188,8 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
private PreferenceScreen createPreferenceHierarchy() {
// Root
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
final Context context = getActivity();
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
@@ -202,7 +203,7 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
if (!TextUtils.isEmpty(mInputMethodId) && !mInputMethodId.equals(imiId)) {
continue;
}
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(context);
root.addPreference(keyboardSettingsCategory);
PackageManager pm = getPackageManager();
CharSequence label = imi.loadLabel(pm);
@@ -210,31 +211,22 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
keyboardSettingsCategory.setTitle(label);
keyboardSettingsCategory.setKey(imiId);
// TODO: Use toggle Preference if images are ready.
CheckBoxPreference autoCB = new CheckBoxPreference(getActivity());
CheckBoxPreference autoCB = new CheckBoxPreference(context);
autoCB.setTitle(R.string.use_system_language_to_select_input_method_subtypes);
mSubtypeAutoSelectionCBMap.put(imiId, autoCB);
keyboardSettingsCategory.addPreference(autoCB);
PreferenceCategory activeInputMethodsCategory = new PreferenceCategory(getActivity());
PreferenceCategory activeInputMethodsCategory = new PreferenceCategory(context);
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
root.addPreference(activeInputMethodsCategory);
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
if (subtypeCount > 0) {
for (int j = 0; j < subtypeCount; ++j) {
InputMethodSubtype subtype = imi.getSubtypeAt(j);
CharSequence subtypeLabel;
int nameResId = subtype.getNameResId();
if (nameResId != 0) {
subtypeLabel = pm.getText(imi.getPackageName(), nameResId,
imi.getServiceInfo().applicationInfo);
} else {
String mode = subtype.getMode();
CharSequence language = subtype.getLocale();
subtypeLabel = (mode == null ? "" : mode) + ","
+ (language == null ? "" : language);
}
CheckBoxPreference chkbxPref = new CheckBoxPreference(getActivity());
final InputMethodSubtype subtype = imi.getSubtypeAt(j);
final CharSequence subtypeLabel = subtype.getDisplayName(context,
imi.getPackageName(), imi.getServiceInfo().applicationInfo);
final CheckBoxPreference chkbxPref = new CheckBoxPreference(context);
chkbxPref.setKey(imiId + subtype.hashCode());
chkbxPref.setTitle(subtypeLabel);
activeInputMethodsCategory.addPreference(chkbxPref);

View File

@@ -266,7 +266,6 @@ public class InputMethodConfig extends SettingsPreferenceFragment {
private void updateActiveInputMethodsSummary() {
final InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
final PackageManager pm = getPackageManager();
for (InputMethodInfo imi: mActiveInputMethodsPrefMap.keySet()) {
Preference pref = mActiveInputMethodsPrefMap.get(imi);
List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
@@ -276,8 +275,9 @@ public class InputMethodConfig extends SettingsPreferenceFragment {
if (subtypeAdded) {
summary.append(", ");
}
summary.append(pm.getText(imi.getPackageName(), subtype.getNameResId(),
imi.getServiceInfo().applicationInfo));
final CharSequence subtypeLabel = subtype.getDisplayName(getActivity(),
imi.getPackageName(), imi.getServiceInfo().applicationInfo);
summary.append(subtypeLabel);
subtypeAdded = true;
}
pref.setSummary(summary.toString());