Refine InputMethodInfo API
bug: 3370297
Change-Id: Ifaaad399586ee5b842f9b7762281d76e7969d24c
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
index 3ba0625..0e5be20 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
@@ -181,7 +181,8 @@
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = mInputMethodProperties.get(i);
- if (imi.getSubtypes().size() <= 1) continue;
+ final int subtypeCount = imi.getSubtypeCount();
+ if (subtypeCount <= 1) continue;
final String imiId = imi.getId();
// Add this subtype to the list when no IME is specified or when the IME of this
// subtype is the specified IME.
@@ -205,10 +206,10 @@
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
root.addPreference(activeInputMethodsCategory);
- ArrayList<InputMethodSubtype> subtypes = imi.getSubtypes();
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
- if (subtypes.size() > 0) {
- for (InputMethodSubtype subtype: subtypes) {
+ if (subtypeCount > 0) {
+ for (int j = 0; j < subtypeCount; ++j) {
+ InputMethodSubtype subtype = imi.getSubtypeAt(j);
CharSequence subtypeLabel;
int nameResId = subtype.getNameResId();
if (nameResId != 0) {
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
index bc347fa..8003041 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
@@ -179,7 +179,9 @@
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
boolean subtypeCleared = false;
- for (InputMethodSubtype subtype : imi.getSubtypes()) {
+ final int subtypeCount = imi.getSubtypeCount();
+ for (int i = 0; i < subtypeCount; ++i) {
+ InputMethodSubtype subtype = imi.getSubtypeAt(i);
final String subtypeHashCodeStr = String.valueOf(subtype.hashCode());
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
imiId + subtypeHashCodeStr);
@@ -293,7 +295,9 @@
PreferenceScreen preferenceScreen = context.getPreferenceScreen();
for (InputMethodInfo imi : inputMethodProperties) {
if (id.equals(imi.getId())) {
- for (InputMethodSubtype subtype : imi.getSubtypes()) {
+ final int subtypeCount = imi.getSubtypeCount();
+ for (int i = 0; i < subtypeCount; ++i) {
+ InputMethodSubtype subtype = imi.getSubtypeAt(i);
CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference(
id + subtype.hashCode());
if (pref != null) {
@@ -311,7 +315,9 @@
for (InputMethodInfo imi : inputMethodProperties) {
String id = imi.getId();
HashSet<String> enabledSubtypesSet = enabledSubtypes.get(id);
- for (InputMethodSubtype subtype : imi.getSubtypes()) {
+ final int subtypeCount = imi.getSubtypeCount();
+ for (int i = 0; i < subtypeCount; ++i) {
+ InputMethodSubtype subtype = imi.getSubtypeAt(i);
String hashCode = String.valueOf(subtype.hashCode());
if (DEBUG) {
Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", "
diff --git a/src/com/android/settings/inputmethod/InputMethodConfig.java b/src/com/android/settings/inputmethod/InputMethodConfig.java
index 908fa05..22d4411 100644
--- a/src/com/android/settings/inputmethod/InputMethodConfig.java
+++ b/src/com/android/settings/inputmethod/InputMethodConfig.java
@@ -218,7 +218,7 @@
// 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) {
+ if (imi.getSubtypeCount() > 1) {
intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED