am 5fbd356a: am 85607c59: Merge "Fix the subtype id of the additional subtypes"

* commit '5fbd356a735ae02a671ca7db6dd57050e9fb0b17':
  Fix the subtype id of the additional subtypes
main
Satoshi Kataoka 2013-10-09 17:55:33 -07:00 committed by Android Git Automerger
commit 37da650b75
1 changed files with 25 additions and 4 deletions

View File

@ -61,10 +61,8 @@ public final class AdditionalSubtypeUtils {
StringUtils.appendToCommaSplittableTextIfNotExists( StringUtils.appendToCommaSplittableTextIfNotExists(
IS_ADDITIONAL_SUBTYPE, layoutDisplayNameExtraValue); IS_ADDITIONAL_SUBTYPE, layoutDisplayNameExtraValue);
final int nameId = SubtypeLocaleUtils.getSubtypeNameId(localeString, keyboardLayoutSetName); final int nameId = SubtypeLocaleUtils.getSubtypeNameId(localeString, keyboardLayoutSetName);
return new InputMethodSubtype(nameId, R.drawable.ic_ime_switcher_dark, return buildInputMethodSubtype(
localeString, KEYBOARD_MODE, layoutExtraValue + "," + additionalSubtypeExtraValue nameId, localeString, layoutExtraValue, additionalSubtypeExtraValue);
+ "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE, false, false);
} }
public static String getPrefSubtype(final InputMethodSubtype subtype) { public static String getPrefSubtype(final InputMethodSubtype subtype) {
@ -137,4 +135,27 @@ public final class AdditionalSubtypeUtils {
} }
return sb.toString(); return sb.toString();
} }
private static InputMethodSubtype buildInputMethodSubtype(int nameId, String localeString,
String layoutExtraValue, String additionalSubtypeExtraValue) {
// CAVEAT! If you want to change subtypeId after changing the extra values,
// you must change "getInputMethodSubtypeId". But it will remove the additional keyboard
// from the current users. So, you should be really careful to change it.
final int subtypeId = getInputMethodSubtypeId(nameId, localeString, layoutExtraValue,
additionalSubtypeExtraValue);
// TODO: Use InputMethodSubtypeBuilder once we use SDK version 19.
return new InputMethodSubtype(nameId, R.drawable.ic_ime_switcher_dark,
localeString, KEYBOARD_MODE, layoutExtraValue + "," + additionalSubtypeExtraValue
+ "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE, false, false,
subtypeId);
}
private static int getInputMethodSubtypeId(int nameId, String localeString,
String layoutExtraValue, String additionalSubtypeExtraValue) {
// TODO: Use InputMethodSubtypeBuilder once we use SDK version 19.
return (new InputMethodSubtype(nameId, R.drawable.ic_ime_switcher_dark,
localeString, KEYBOARD_MODE, layoutExtraValue + "," + additionalSubtypeExtraValue,
false, false)).hashCode();
}
} }