Merge "Use getDisplayName for the name of InputMethodSubtype"
This commit is contained in:
@@ -188,7 +188,8 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private PreferenceScreen createPreferenceHierarchy() {
|
private PreferenceScreen createPreferenceHierarchy() {
|
||||||
// Root
|
// Root
|
||||||
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
|
final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
|
||||||
|
final Context context = getActivity();
|
||||||
|
|
||||||
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
|
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
|
||||||
|
|
||||||
@@ -202,7 +203,7 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
|||||||
if (!TextUtils.isEmpty(mInputMethodId) && !mInputMethodId.equals(imiId)) {
|
if (!TextUtils.isEmpty(mInputMethodId) && !mInputMethodId.equals(imiId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getActivity());
|
PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(context);
|
||||||
root.addPreference(keyboardSettingsCategory);
|
root.addPreference(keyboardSettingsCategory);
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
CharSequence label = imi.loadLabel(pm);
|
CharSequence label = imi.loadLabel(pm);
|
||||||
@@ -210,31 +211,22 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
|||||||
keyboardSettingsCategory.setTitle(label);
|
keyboardSettingsCategory.setTitle(label);
|
||||||
keyboardSettingsCategory.setKey(imiId);
|
keyboardSettingsCategory.setKey(imiId);
|
||||||
// TODO: Use toggle Preference if images are ready.
|
// 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);
|
autoCB.setTitle(R.string.use_system_language_to_select_input_method_subtypes);
|
||||||
mSubtypeAutoSelectionCBMap.put(imiId, autoCB);
|
mSubtypeAutoSelectionCBMap.put(imiId, autoCB);
|
||||||
keyboardSettingsCategory.addPreference(autoCB);
|
keyboardSettingsCategory.addPreference(autoCB);
|
||||||
|
|
||||||
PreferenceCategory activeInputMethodsCategory = new PreferenceCategory(getActivity());
|
PreferenceCategory activeInputMethodsCategory = new PreferenceCategory(context);
|
||||||
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
|
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
|
||||||
root.addPreference(activeInputMethodsCategory);
|
root.addPreference(activeInputMethodsCategory);
|
||||||
|
|
||||||
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
|
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
|
||||||
if (subtypeCount > 0) {
|
if (subtypeCount > 0) {
|
||||||
for (int j = 0; j < subtypeCount; ++j) {
|
for (int j = 0; j < subtypeCount; ++j) {
|
||||||
InputMethodSubtype subtype = imi.getSubtypeAt(j);
|
final InputMethodSubtype subtype = imi.getSubtypeAt(j);
|
||||||
CharSequence subtypeLabel;
|
final CharSequence subtypeLabel = subtype.getDisplayName(context,
|
||||||
int nameResId = subtype.getNameResId();
|
imi.getPackageName(), imi.getServiceInfo().applicationInfo);
|
||||||
if (nameResId != 0) {
|
final CheckBoxPreference chkbxPref = new CheckBoxPreference(context);
|
||||||
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());
|
|
||||||
chkbxPref.setKey(imiId + subtype.hashCode());
|
chkbxPref.setKey(imiId + subtype.hashCode());
|
||||||
chkbxPref.setTitle(subtypeLabel);
|
chkbxPref.setTitle(subtypeLabel);
|
||||||
activeInputMethodsCategory.addPreference(chkbxPref);
|
activeInputMethodsCategory.addPreference(chkbxPref);
|
||||||
|
@@ -266,7 +266,6 @@ public class InputMethodConfig extends SettingsPreferenceFragment {
|
|||||||
private void updateActiveInputMethodsSummary() {
|
private void updateActiveInputMethodsSummary() {
|
||||||
final InputMethodManager imm =
|
final InputMethodManager imm =
|
||||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
final PackageManager pm = getPackageManager();
|
|
||||||
for (InputMethodInfo imi: mActiveInputMethodsPrefMap.keySet()) {
|
for (InputMethodInfo imi: mActiveInputMethodsPrefMap.keySet()) {
|
||||||
Preference pref = mActiveInputMethodsPrefMap.get(imi);
|
Preference pref = mActiveInputMethodsPrefMap.get(imi);
|
||||||
List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
|
List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
|
||||||
@@ -276,8 +275,9 @@ public class InputMethodConfig extends SettingsPreferenceFragment {
|
|||||||
if (subtypeAdded) {
|
if (subtypeAdded) {
|
||||||
summary.append(", ");
|
summary.append(", ");
|
||||||
}
|
}
|
||||||
summary.append(pm.getText(imi.getPackageName(), subtype.getNameResId(),
|
final CharSequence subtypeLabel = subtype.getDisplayName(getActivity(),
|
||||||
imi.getServiceInfo().applicationInfo));
|
imi.getPackageName(), imi.getServiceInfo().applicationInfo);
|
||||||
|
summary.append(subtypeLabel);
|
||||||
subtypeAdded = true;
|
subtypeAdded = true;
|
||||||
}
|
}
|
||||||
pref.setSummary(summary.toString());
|
pref.setSummary(summary.toString());
|
||||||
|
Reference in New Issue
Block a user