Fix RuntiomeException when no custom input style is defined

Bug: 6524480
Change-Id: I6bceea9fe07095b9ff3ed25c5677a82fa5d4086a
main
Tadashi G. Takaoka 2012-05-23 14:48:16 +09:00
parent 37f81cd6e9
commit d6e238fc33
1 changed files with 6 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOAR
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
import android.os.Build; import android.os.Build;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList; import java.util.ArrayList;
@ -84,11 +85,14 @@ public class AdditionalSubtype {
} }
public static InputMethodSubtype[] createAdditionalSubtypesArray(String prefSubtypes) { public static InputMethodSubtype[] createAdditionalSubtypesArray(String prefSubtypes) {
if (TextUtils.isEmpty(prefSubtypes)) {
return null;
}
final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR); final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
final ArrayList<InputMethodSubtype> subtypesList = final ArrayList<InputMethodSubtype> subtypesList =
new ArrayList<InputMethodSubtype>(prefSubtypeArray.length); new ArrayList<InputMethodSubtype>(prefSubtypeArray.length);
for (int i = 0; i < prefSubtypeArray.length; i++) { for (final String prefSubtype : prefSubtypeArray) {
final InputMethodSubtype subtype = createAdditionalSubtype(prefSubtypeArray[i]); final InputMethodSubtype subtype = createAdditionalSubtype(prefSubtype);
if (subtype.getNameResId() == SubtypeLocale.UNKNOWN_KEYBOARD_LAYOUT) { if (subtype.getNameResId() == SubtypeLocale.UNKNOWN_KEYBOARD_LAYOUT) {
// Skip unknown keyboard layout subtype. This may happen when predefined keyboard // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
// layout has been removed. // layout has been removed.