Refine InputMethodInfo API

bug: 3370297
Change-Id: I16073e6b8b90a06a20e506dac66e3ca25b4712d0
main
Ken Wakasa 2011-01-20 23:29:53 +09:00
parent 6845da8d7b
commit fefda4e6df
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;
}
}