Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0ae3297 authored by satok's avatar satok
Browse files

Use getDisplayName for the name of InputMethodSubtype

Change-Id: I9ad7790bc36ff2950e0238cae8ce3b785bb8eaa1
parent f41be790
Loading
Loading
Loading
Loading
+9 −17
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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());