|
|
@ -218,20 +218,18 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
parseKeyboardAttributes(parser);
|
|
|
|
parseKeyboardAttributes(parser);
|
|
|
|
startKeyboard();
|
|
|
|
startKeyboard();
|
|
|
|
parseKeyboardContent(parser, false);
|
|
|
|
parseKeyboardContent(parser, false);
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_KEYBOARD);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_KEYBOARD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void parseKeyboardAttributes(final XmlPullParser parser) {
|
|
|
|
private void parseKeyboardAttributes(final XmlPullParser parser) {
|
|
|
|
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
|
|
|
|
final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
|
|
|
|
Xml.asAttributeSet(parser), R.styleable.Keyboard, R.attr.keyboardStyle,
|
|
|
|
attr, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
|
|
|
|
R.style.Keyboard);
|
|
|
|
final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
|
|
|
|
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
|
|
|
|
|
|
|
R.styleable.Keyboard_Key);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
final KeyboardParams params = mParams;
|
|
|
|
final KeyboardParams params = mParams;
|
|
|
|
final int height = params.mId.mHeight;
|
|
|
|
final int height = params.mId.mHeight;
|
|
|
@ -328,31 +326,30 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
if (DEBUG) endTag("</%s>", tag);
|
|
|
|
if (DEBUG) endTag("</%s>", tag);
|
|
|
|
if (TAG_KEYBOARD.equals(tag)) {
|
|
|
|
if (TAG_KEYBOARD.equals(tag)) {
|
|
|
|
endKeyboard();
|
|
|
|
endKeyboard();
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
} else if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag)
|
|
|
|
|
|
|
|
|| TAG_MERGE.equals(tag)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag) || TAG_MERGE.equals(tag)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
|
|
|
|
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
|
|
|
|
throws XmlPullParserException {
|
|
|
|
throws XmlPullParserException {
|
|
|
|
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
R.styleable.Keyboard);
|
|
|
|
final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (a.hasValue(R.styleable.Keyboard_horizontalGap)) {
|
|
|
|
if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
|
|
|
|
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
|
|
|
|
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (a.hasValue(R.styleable.Keyboard_verticalGap)) {
|
|
|
|
if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
|
|
|
|
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
|
|
|
|
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new KeyboardRow(mResources, mParams, parser, mCurrentY);
|
|
|
|
return new KeyboardRow(mResources, mParams, parser, mCurrentY);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
a.recycle();
|
|
|
|
keyboardAttr.recycle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -382,13 +379,12 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
if (!skip) {
|
|
|
|
if (!skip) {
|
|
|
|
endRow(row);
|
|
|
|
endRow(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
} else if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag)
|
|
|
|
|
|
|
|
|| TAG_MERGE.equals(tag)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag) || TAG_MERGE.equals(tag)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -397,33 +393,30 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
if (skip) {
|
|
|
|
if (skip) {
|
|
|
|
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
|
|
|
if (DEBUG) {
|
|
|
|
if (DEBUG) startEndTag("<%s /> skipped", TAG_KEY);
|
|
|
|
startEndTag("<%s /> skipped", TAG_KEY);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
final Key key = new Key(mResources, mParams, row, parser);
|
|
|
|
final Key key = new Key(mResources, mParams, row, parser);
|
|
|
|
if (DEBUG) {
|
|
|
|
if (DEBUG) {
|
|
|
|
startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY,
|
|
|
|
startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"),
|
|
|
|
(key.isEnabled() ? "" : " disabled"), key,
|
|
|
|
key, Arrays.toString(key.getMoreKeys()));
|
|
|
|
Arrays.toString(key.getMoreKeys()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
|
|
|
endKey(key);
|
|
|
|
endKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void parseSpacer(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
|
|
|
|
private void parseSpacer(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
if (skip) {
|
|
|
|
if (skip) {
|
|
|
|
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
|
|
|
if (DEBUG) startEndTag("<%s /> skipped", TAG_SPACER);
|
|
|
|
if (DEBUG) startEndTag("<%s /> skipped", TAG_SPACER);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
final Key.Spacer spacer = new Key.Spacer(mResources, mParams, row, parser);
|
|
|
|
final Key.Spacer spacer = new Key.Spacer(mResources, mParams, row, parser);
|
|
|
|
if (DEBUG) startEndTag("<%s />", TAG_SPACER);
|
|
|
|
if (DEBUG) startEndTag("<%s />", TAG_SPACER);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
|
|
|
endKey(spacer);
|
|
|
|
endKey(spacer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void parseIncludeKeyboardContent(final XmlPullParser parser, final boolean skip)
|
|
|
|
private void parseIncludeKeyboardContent(final XmlPullParser parser, final boolean skip)
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
@ -440,19 +433,19 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
if (skip) {
|
|
|
|
if (skip) {
|
|
|
|
XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
|
|
|
|
XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
|
|
|
|
if (DEBUG) startEndTag("</%s> skipped", TAG_INCLUDE);
|
|
|
|
if (DEBUG) startEndTag("</%s> skipped", TAG_INCLUDE);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
final TypedArray keyboardAttr = mResources.obtainAttributes(attr,
|
|
|
|
final TypedArray keyboardAttr = mResources.obtainAttributes(
|
|
|
|
R.styleable.Keyboard_Include);
|
|
|
|
attr, R.styleable.Keyboard_Include);
|
|
|
|
final TypedArray keyAttr = mResources.obtainAttributes(attr,
|
|
|
|
final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
|
|
|
|
R.styleable.Keyboard_Key);
|
|
|
|
|
|
|
|
int keyboardLayout = 0;
|
|
|
|
int keyboardLayout = 0;
|
|
|
|
float savedDefaultKeyWidth = 0;
|
|
|
|
float savedDefaultKeyWidth = 0;
|
|
|
|
int savedDefaultKeyLabelFlags = 0;
|
|
|
|
int savedDefaultKeyLabelFlags = 0;
|
|
|
|
int savedDefaultBackgroundType = Key.BACKGROUND_TYPE_NORMAL;
|
|
|
|
int savedDefaultBackgroundType = Key.BACKGROUND_TYPE_NORMAL;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
XmlParseUtils.checkAttributeExists(keyboardAttr,
|
|
|
|
XmlParseUtils.checkAttributeExists(
|
|
|
|
R.styleable.Keyboard_Include_keyboardLayout, "keyboardLayout",
|
|
|
|
keyboardAttr, R.styleable.Keyboard_Include_keyboardLayout, "keyboardLayout",
|
|
|
|
TAG_INCLUDE, parser);
|
|
|
|
TAG_INCLUDE, parser);
|
|
|
|
keyboardLayout = keyboardAttr.getResourceId(
|
|
|
|
keyboardLayout = keyboardAttr.getResourceId(
|
|
|
|
R.styleable.Keyboard_Include_keyboardLayout, 0);
|
|
|
|
R.styleable.Keyboard_Include_keyboardLayout, 0);
|
|
|
@ -470,13 +463,11 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
|
|
|
|
savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
|
|
|
|
// Bitwise-or default keyLabelFlag if exists.
|
|
|
|
// Bitwise-or default keyLabelFlag if exists.
|
|
|
|
row.setDefaultKeyLabelFlags(keyAttr.getInt(
|
|
|
|
row.setDefaultKeyLabelFlags(keyAttr.getInt(
|
|
|
|
R.styleable.Keyboard_Key_keyLabelFlags, 0)
|
|
|
|
R.styleable.Keyboard_Key_keyLabelFlags, 0) | savedDefaultKeyLabelFlags);
|
|
|
|
| savedDefaultKeyLabelFlags);
|
|
|
|
|
|
|
|
savedDefaultBackgroundType = row.getDefaultBackgroundType();
|
|
|
|
savedDefaultBackgroundType = row.getDefaultBackgroundType();
|
|
|
|
// Override default backgroundType if exists.
|
|
|
|
// Override default backgroundType if exists.
|
|
|
|
row.setDefaultBackgroundType(keyAttr.getInt(
|
|
|
|
row.setDefaultBackgroundType(keyAttr.getInt(
|
|
|
|
R.styleable.Keyboard_Key_backgroundType,
|
|
|
|
R.styleable.Keyboard_Key_backgroundType, savedDefaultBackgroundType));
|
|
|
|
savedDefaultBackgroundType));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
keyboardAttr.recycle();
|
|
|
|
keyboardAttr.recycle();
|
|
|
@ -501,7 +492,6 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
parserForInclude.close();
|
|
|
|
parserForInclude.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void parseMerge(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
|
|
|
|
private void parseMerge(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
@ -516,14 +506,13 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
parseRowContent(parser, row, skip);
|
|
|
|
parseRowContent(parser, row, skip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
throw new XmlParseUtils.ParseException(
|
|
|
|
throw new XmlParseUtils.ParseException(
|
|
|
|
"Included keyboard layout must have <merge> root element", parser);
|
|
|
|
"Included keyboard layout must have <merge> root element", parser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void parseSwitchKeyboardContent(final XmlPullParser parser, final boolean skip)
|
|
|
|
private void parseSwitchKeyboardContent(final XmlPullParser parser, final boolean skip)
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
@ -554,10 +543,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
final String tag = parser.getName();
|
|
|
|
final String tag = parser.getName();
|
|
|
|
if (TAG_SWITCH.equals(tag)) {
|
|
|
|
if (TAG_SWITCH.equals(tag)) {
|
|
|
|
if (DEBUG) endTag("</%s>", TAG_SWITCH);
|
|
|
|
if (DEBUG) endTag("</%s>", TAG_SWITCH);
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_SWITCH);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_SWITCH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -580,40 +568,40 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
if (id == null) {
|
|
|
|
if (id == null) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
R.styleable.Keyboard_Case);
|
|
|
|
final TypedArray caseAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Case);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
final boolean keyboardLayoutSetElementMatched = matchTypedValue(a,
|
|
|
|
final boolean keyboardLayoutSetElementMatched = matchTypedValue(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_keyboardLayoutSetElement, id.mElementId,
|
|
|
|
R.styleable.Keyboard_Case_keyboardLayoutSetElement, id.mElementId,
|
|
|
|
KeyboardId.elementIdToName(id.mElementId));
|
|
|
|
KeyboardId.elementIdToName(id.mElementId));
|
|
|
|
final boolean modeMatched = matchTypedValue(a,
|
|
|
|
final boolean modeMatched = matchTypedValue(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
|
|
|
|
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
|
|
|
|
final boolean navigateNextMatched = matchBoolean(a,
|
|
|
|
final boolean navigateNextMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_navigateNext, id.navigateNext());
|
|
|
|
R.styleable.Keyboard_Case_navigateNext, id.navigateNext());
|
|
|
|
final boolean navigatePreviousMatched = matchBoolean(a,
|
|
|
|
final boolean navigatePreviousMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_navigatePrevious, id.navigatePrevious());
|
|
|
|
R.styleable.Keyboard_Case_navigatePrevious, id.navigatePrevious());
|
|
|
|
final boolean passwordInputMatched = matchBoolean(a,
|
|
|
|
final boolean passwordInputMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
|
|
|
|
R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
|
|
|
|
final boolean clobberSettingsKeyMatched = matchBoolean(a,
|
|
|
|
final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
|
|
|
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
|
|
|
final boolean shortcutKeyEnabledMatched = matchBoolean(a,
|
|
|
|
final boolean shortcutKeyEnabledMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled);
|
|
|
|
R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled);
|
|
|
|
final boolean shortcutKeyOnSymbolsMatched = matchBoolean(a,
|
|
|
|
final boolean shortcutKeyOnSymbolsMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_shortcutKeyOnSymbols, id.mShortcutKeyOnSymbols);
|
|
|
|
R.styleable.Keyboard_Case_shortcutKeyOnSymbols, id.mShortcutKeyOnSymbols);
|
|
|
|
final boolean hasShortcutKeyMatched = matchBoolean(a,
|
|
|
|
final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
|
|
|
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
|
|
|
final boolean languageSwitchKeyEnabledMatched = matchBoolean(a,
|
|
|
|
final boolean languageSwitchKeyEnabledMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
|
|
|
R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
|
|
|
id.mLanguageSwitchKeyEnabled);
|
|
|
|
id.mLanguageSwitchKeyEnabled);
|
|
|
|
final boolean isMultiLineMatched = matchBoolean(a,
|
|
|
|
final boolean isMultiLineMatched = matchBoolean(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_isMultiLine, id.isMultiLine());
|
|
|
|
R.styleable.Keyboard_Case_isMultiLine, id.isMultiLine());
|
|
|
|
final boolean imeActionMatched = matchInteger(a,
|
|
|
|
final boolean imeActionMatched = matchInteger(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_imeAction, id.imeAction());
|
|
|
|
R.styleable.Keyboard_Case_imeAction, id.imeAction());
|
|
|
|
final boolean localeCodeMatched = matchString(a,
|
|
|
|
final boolean localeCodeMatched = matchString(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
|
|
|
|
R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
|
|
|
|
final boolean languageCodeMatched = matchString(a,
|
|
|
|
final boolean languageCodeMatched = matchString(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
|
|
|
|
R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
|
|
|
|
final boolean countryCodeMatched = matchString(a,
|
|
|
|
final boolean countryCodeMatched = matchString(caseAttr,
|
|
|
|
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
|
|
|
|
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
|
|
|
|
final boolean selected = keyboardLayoutSetElementMatched && modeMatched
|
|
|
|
final boolean selected = keyboardLayoutSetElementMatched && modeMatched
|
|
|
|
&& navigateNextMatched && navigatePreviousMatched && passwordInputMatched
|
|
|
|
&& navigateNextMatched && navigatePreviousMatched && passwordInputMatched
|
|
|
@ -624,42 +612,42 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
|
|
|
|
|
|
|
|
if (DEBUG) {
|
|
|
|
if (DEBUG) {
|
|
|
|
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
|
|
|
|
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
|
|
|
|
textAttr(a.getString(
|
|
|
|
textAttr(caseAttr.getString(
|
|
|
|
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
|
|
|
|
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
|
|
|
|
"keyboardLayoutSetElement"),
|
|
|
|
"keyboardLayoutSetElement"),
|
|
|
|
textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"),
|
|
|
|
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_mode), "mode"),
|
|
|
|
textAttr(a.getString(R.styleable.Keyboard_Case_imeAction),
|
|
|
|
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_imeAction),
|
|
|
|
"imeAction"),
|
|
|
|
"imeAction"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_navigateNext,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_navigateNext,
|
|
|
|
"navigateNext"),
|
|
|
|
"navigateNext"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_navigatePrevious,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_navigatePrevious,
|
|
|
|
"navigatePrevious"),
|
|
|
|
"navigatePrevious"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_clobberSettingsKey,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_clobberSettingsKey,
|
|
|
|
"clobberSettingsKey"),
|
|
|
|
"clobberSettingsKey"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_passwordInput,
|
|
|
|
"passwordInput"),
|
|
|
|
"passwordInput"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyEnabled,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_shortcutKeyEnabled,
|
|
|
|
"shortcutKeyEnabled"),
|
|
|
|
"shortcutKeyEnabled"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyOnSymbols,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_shortcutKeyOnSymbols,
|
|
|
|
"shortcutKeyOnSymbols"),
|
|
|
|
"shortcutKeyOnSymbols"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_hasShortcutKey,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_hasShortcutKey,
|
|
|
|
"hasShortcutKey"),
|
|
|
|
"hasShortcutKey"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
|
|
|
"languageSwitchKeyEnabled"),
|
|
|
|
"languageSwitchKeyEnabled"),
|
|
|
|
booleanAttr(a, R.styleable.Keyboard_Case_isMultiLine,
|
|
|
|
booleanAttr(caseAttr, R.styleable.Keyboard_Case_isMultiLine,
|
|
|
|
"isMultiLine"),
|
|
|
|
"isMultiLine"),
|
|
|
|
textAttr(a.getString(R.styleable.Keyboard_Case_localeCode),
|
|
|
|
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_localeCode),
|
|
|
|
"localeCode"),
|
|
|
|
"localeCode"),
|
|
|
|
textAttr(a.getString(R.styleable.Keyboard_Case_languageCode),
|
|
|
|
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_languageCode),
|
|
|
|
"languageCode"),
|
|
|
|
"languageCode"),
|
|
|
|
textAttr(a.getString(R.styleable.Keyboard_Case_countryCode),
|
|
|
|
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_countryCode),
|
|
|
|
"countryCode"),
|
|
|
|
"countryCode"),
|
|
|
|
selected ? "" : " skipped");
|
|
|
|
selected ? "" : " skipped");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return selected;
|
|
|
|
return selected;
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
a.recycle();
|
|
|
|
caseAttr.recycle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -692,7 +680,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ResourceUtils.isIntegerValue(v)) {
|
|
|
|
if (ResourceUtils.isIntegerValue(v)) {
|
|
|
|
return intValue == a.getInt(index, 0);
|
|
|
|
return intValue == a.getInt(index, 0);
|
|
|
|
} else if (ResourceUtils.isStringValue(v)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ResourceUtils.isStringValue(v)) {
|
|
|
|
return StringUtils.containsInArray(strValue, a.getString(index).split("\\|"));
|
|
|
|
return StringUtils.containsInArray(strValue, a.getString(index).split("\\|"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -711,10 +700,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|
|
|
|
|
|
|
|
|
|
|
private void parseKeyStyle(final XmlPullParser parser, final boolean skip)
|
|
|
|
private void parseKeyStyle(final XmlPullParser parser, final boolean skip)
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
throws XmlPullParserException, IOException {
|
|
|
|
TypedArray keyStyleAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
|
|
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
|
|
|
R.styleable.Keyboard_KeyStyle);
|
|
|
|
final TypedArray keyStyleAttr = mResources.obtainAttributes(
|
|
|
|
TypedArray keyAttrs = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
|
|
|
attr, R.styleable.Keyboard_KeyStyle);
|
|
|
|
R.styleable.Keyboard_Key);
|
|
|
|
final TypedArray keyAttrs = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_styleName)) {
|
|
|
|
if (!keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_styleName)) {
|
|
|
|
throw new XmlParseUtils.ParseException("<" + TAG_KEY_STYLE
|
|
|
|
throw new XmlParseUtils.ParseException("<" + TAG_KEY_STYLE
|
|
|
|