Refine InputMethodInfo API

bug: 3370297
Change-Id: Ifaaad399586ee5b842f9b7762281d76e7969d24c
This commit is contained in:
Ken Wakasa
2011-01-20 22:29:34 +09:00
parent 9f7320132b
commit 5a813ba7f9
3 changed files with 15 additions and 8 deletions

View File

@@ -181,7 +181,8 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
for (int i = 0; i < N; ++i) { for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = mInputMethodProperties.get(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(); final String imiId = imi.getId();
// Add this subtype to the list when no IME is specified or when the IME of this // Add this subtype to the list when no IME is specified or when the IME of this
// subtype is the specified IME. // subtype is the specified IME.
@@ -205,10 +206,10 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes); activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
root.addPreference(activeInputMethodsCategory); root.addPreference(activeInputMethodsCategory);
ArrayList<InputMethodSubtype> subtypes = imi.getSubtypes();
ArrayList<Preference> subtypePreferences = new ArrayList<Preference>(); ArrayList<Preference> subtypePreferences = new ArrayList<Preference>();
if (subtypes.size() > 0) { if (subtypeCount > 0) {
for (InputMethodSubtype subtype: subtypes) { for (int j = 0; j < subtypeCount; ++j) {
InputMethodSubtype subtype = imi.getSubtypeAt(j);
CharSequence subtypeLabel; CharSequence subtypeLabel;
int nameResId = subtype.getNameResId(); int nameResId = subtype.getNameResId();
if (nameResId != 0) { if (nameResId != 0) {

View File

@@ -179,7 +179,9 @@ public class InputMethodAndSubtypeUtil {
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId); HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
boolean subtypeCleared = false; 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()); final String subtypeHashCodeStr = String.valueOf(subtype.hashCode());
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference( CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
imiId + subtypeHashCodeStr); imiId + subtypeHashCodeStr);
@@ -293,7 +295,9 @@ public class InputMethodAndSubtypeUtil {
PreferenceScreen preferenceScreen = context.getPreferenceScreen(); PreferenceScreen preferenceScreen = context.getPreferenceScreen();
for (InputMethodInfo imi : inputMethodProperties) { for (InputMethodInfo imi : inputMethodProperties) {
if (id.equals(imi.getId())) { 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( CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference(
id + subtype.hashCode()); id + subtype.hashCode());
if (pref != null) { if (pref != null) {
@@ -311,7 +315,9 @@ public class InputMethodAndSubtypeUtil {
for (InputMethodInfo imi : inputMethodProperties) { for (InputMethodInfo imi : inputMethodProperties) {
String id = imi.getId(); String id = imi.getId();
HashSet<String> enabledSubtypesSet = enabledSubtypes.get(id); 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()); String hashCode = String.valueOf(subtype.hashCode());
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", " Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", "

View File

@@ -218,7 +218,7 @@ public class InputMethodConfig extends SettingsPreferenceFragment {
// Add subtype settings when this IME has two or more subtypes. // Add subtype settings when this IME has two or more subtypes.
PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null); PreferenceScreen prefScreen = new PreferenceScreen(getActivity(), null);
prefScreen.setTitle(R.string.active_input_method_subtypes); 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 = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED