am 6a12b693: am fefda4e6: Refine InputMethodInfo API

* commit '6a12b693ee4916c70387a5c937c2e438ab0dafe4':
  Refine InputMethodInfo API
This commit is contained in:
Ken Wakasa 2011-01-20 08:16:13 -08:00 committed by Android Git Automerger
commit d9243baa81
2 changed files with 9 additions and 22 deletions

View file

@ -288,9 +288,9 @@ public class SubtypeSwitcher {
if (subtype != null) {
return pm.getDrawable(imiPackageName, subtype.getIconResId(),
imi.getServiceInfo().applicationInfo);
} else if (imi.getSubtypes().size() > 0 && imi.getSubtypes().get(0) != null) {
} else if (imi.getSubtypeCount() > 0 && imi.getSubtypeAt(0) != null) {
return pm.getDrawable(imiPackageName,
imi.getSubtypes().get(0).getIconResId(),
imi.getSubtypeAt(0).getIconResId(),
imi.getServiceInfo().applicationInfo);
} else {
try {

View file

@ -33,19 +33,6 @@ public class SubtypeLocaleTests extends AndroidTestCase {
private Resources mRes;
private List<InputMethodSubtype> mKeyboardSubtypes;
public interface Predicator<T> {
public boolean evaluate(T object);
}
private static <T> List<T> filter(List<T> source, Predicator<? super T> predicator) {
final ArrayList<T> filtered = new ArrayList<T>();
for (final T element : source) {
if (predicator.evaluate(element))
filtered.add(element);
}
return filtered;
}
@Override
protected void setUp() throws Exception {
super.setUp();
@ -59,13 +46,13 @@ public class SubtypeLocaleTests extends AndroidTestCase {
Context.INPUT_METHOD_SERVICE);
for (final InputMethodInfo imi : imm.getInputMethodList()) {
if (imi.getPackageName().equals(PACKAGE)) {
mKeyboardSubtypes = filter(imi.getSubtypes(),
new Predicator<InputMethodSubtype>() {
@Override
public boolean evaluate(InputMethodSubtype ims) {
return ims.getMode().equals("keyboard");
final int subtypeCount = imi.getSubtypeCount();
for (int i = 0; i < subtypeCount; ++i) {
InputMethodSubtype subtype = imi.getSubtypeAt(i);
if (subtype.getMode().equals("keyboard")) {
mKeyboardSubtypes.add(subtype);
}
}
});
break;
}
}