Merge "Fix cosmetic source code formatting"
commit
623e3f9d58
|
@ -162,7 +162,8 @@ public final class KeyboardLayoutSet {
|
||||||
final KeyboardId id = new KeyboardId(keyboardLayoutSetElementId, mParams);
|
final KeyboardId id = new KeyboardId(keyboardLayoutSetElementId, mParams);
|
||||||
try {
|
try {
|
||||||
return getKeyboard(elementParams, id);
|
return getKeyboard(elementParams, id);
|
||||||
} catch (RuntimeException e) {
|
} catch (final RuntimeException e) {
|
||||||
|
Log.e(TAG, "Can't create keyboard: " + id, e);
|
||||||
throw new KeyboardLayoutSetException(e, id);
|
throw new KeyboardLayoutSetException(e, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -638,7 +638,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mKeyPreviewLingerTimeout = delay;
|
mKeyPreviewLingerTimeout = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void locatePreviewPlacerView() {
|
private void locatePreviewPlacerView() {
|
||||||
if (mPreviewPlacerView.getParent() != null) {
|
if (mPreviewPlacerView.getParent() != null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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,19 +393,16 @@ 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);
|
|
||||||
if (DEBUG) {
|
|
||||||
startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY,
|
|
||||||
(key.isEnabled() ? "" : " disabled"), key,
|
|
||||||
Arrays.toString(key.getMoreKeys()));
|
|
||||||
}
|
|
||||||
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
|
||||||
endKey(key);
|
|
||||||
}
|
}
|
||||||
|
final Key key = new Key(mResources, mParams, row, parser);
|
||||||
|
if (DEBUG) {
|
||||||
|
startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"),
|
||||||
|
key, Arrays.toString(key.getMoreKeys()));
|
||||||
|
}
|
||||||
|
XmlParseUtils.checkEndTag(TAG_KEY, parser);
|
||||||
|
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)
|
||||||
|
@ -417,12 +410,12 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
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);
|
|
||||||
if (DEBUG) startEndTag("<%s />", TAG_SPACER);
|
|
||||||
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
|
||||||
endKey(spacer);
|
|
||||||
}
|
}
|
||||||
|
final Key.Spacer spacer = new Key.Spacer(mResources, mParams, row, parser);
|
||||||
|
if (DEBUG) startEndTag("<%s />", TAG_SPACER);
|
||||||
|
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
|
||||||
|
endKey(spacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseIncludeKeyboardContent(final XmlPullParser parser, final boolean skip)
|
private void parseIncludeKeyboardContent(final XmlPullParser parser, final boolean skip)
|
||||||
|
@ -440,66 +433,63 @@ 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 TypedArray keyboardAttr = mResources.obtainAttributes(attr,
|
final AttributeSet attr = Xml.asAttributeSet(parser);
|
||||||
R.styleable.Keyboard_Include);
|
final TypedArray keyboardAttr = mResources.obtainAttributes(
|
||||||
final TypedArray keyAttr = mResources.obtainAttributes(attr,
|
attr, R.styleable.Keyboard_Include);
|
||||||
R.styleable.Keyboard_Key);
|
final TypedArray keyAttr = mResources.obtainAttributes(attr, 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);
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
|
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
|
||||||
// Override current x coordinate.
|
// Override current x coordinate.
|
||||||
row.setXPos(row.getKeyX(keyAttr));
|
row.setXPos(row.getKeyX(keyAttr));
|
||||||
}
|
|
||||||
// TODO: Remove this if-clause and do the same as backgroundType below.
|
|
||||||
savedDefaultKeyWidth = row.getDefaultKeyWidth();
|
|
||||||
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyWidth)) {
|
|
||||||
// Override default key width.
|
|
||||||
row.setDefaultKeyWidth(row.getKeyWidth(keyAttr));
|
|
||||||
}
|
|
||||||
savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
|
|
||||||
// Bitwise-or default keyLabelFlag if exists.
|
|
||||||
row.setDefaultKeyLabelFlags(keyAttr.getInt(
|
|
||||||
R.styleable.Keyboard_Key_keyLabelFlags, 0)
|
|
||||||
| savedDefaultKeyLabelFlags);
|
|
||||||
savedDefaultBackgroundType = row.getDefaultBackgroundType();
|
|
||||||
// Override default backgroundType if exists.
|
|
||||||
row.setDefaultBackgroundType(keyAttr.getInt(
|
|
||||||
R.styleable.Keyboard_Key_backgroundType,
|
|
||||||
savedDefaultBackgroundType));
|
|
||||||
}
|
}
|
||||||
} finally {
|
// TODO: Remove this if-clause and do the same as backgroundType below.
|
||||||
keyboardAttr.recycle();
|
savedDefaultKeyWidth = row.getDefaultKeyWidth();
|
||||||
keyAttr.recycle();
|
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyWidth)) {
|
||||||
|
// Override default key width.
|
||||||
|
row.setDefaultKeyWidth(row.getKeyWidth(keyAttr));
|
||||||
|
}
|
||||||
|
savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
|
||||||
|
// Bitwise-or default keyLabelFlag if exists.
|
||||||
|
row.setDefaultKeyLabelFlags(keyAttr.getInt(
|
||||||
|
R.styleable.Keyboard_Key_keyLabelFlags, 0) | savedDefaultKeyLabelFlags);
|
||||||
|
savedDefaultBackgroundType = row.getDefaultBackgroundType();
|
||||||
|
// Override default backgroundType if exists.
|
||||||
|
row.setDefaultBackgroundType(keyAttr.getInt(
|
||||||
|
R.styleable.Keyboard_Key_backgroundType, savedDefaultBackgroundType));
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
keyboardAttr.recycle();
|
||||||
|
keyAttr.recycle();
|
||||||
|
}
|
||||||
|
|
||||||
XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
|
XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
startEndTag("<%s keyboardLayout=%s />",TAG_INCLUDE,
|
startEndTag("<%s keyboardLayout=%s />",TAG_INCLUDE,
|
||||||
mResources.getResourceEntryName(keyboardLayout));
|
mResources.getResourceEntryName(keyboardLayout));
|
||||||
}
|
}
|
||||||
final XmlResourceParser parserForInclude = mResources.getXml(keyboardLayout);
|
final XmlResourceParser parserForInclude = mResources.getXml(keyboardLayout);
|
||||||
try {
|
try {
|
||||||
parseMerge(parserForInclude, row, skip);
|
parseMerge(parserForInclude, row, skip);
|
||||||
} finally {
|
} finally {
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
// Restore default keyWidth, keyLabelFlags, and backgroundType.
|
// Restore default keyWidth, keyLabelFlags, and backgroundType.
|
||||||
row.setDefaultKeyWidth(savedDefaultKeyWidth);
|
row.setDefaultKeyWidth(savedDefaultKeyWidth);
|
||||||
row.setDefaultKeyLabelFlags(savedDefaultKeyLabelFlags);
|
row.setDefaultKeyLabelFlags(savedDefaultKeyLabelFlags);
|
||||||
row.setDefaultBackgroundType(savedDefaultBackgroundType);
|
row.setDefaultBackgroundType(savedDefaultBackgroundType);
|
||||||
}
|
|
||||||
parserForInclude.close();
|
|
||||||
}
|
}
|
||||||
|
parserForInclude.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,11 +506,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
} else {
|
} else {
|
||||||
parseRowContent(parser, row, skip);
|
parseRowContent(parser, row, skip);
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
} else {
|
|
||||||
throw new XmlParseUtils.ParseException(
|
|
||||||
"Included keyboard layout must have <merge> root element", parser);
|
|
||||||
}
|
}
|
||||||
|
throw new XmlParseUtils.ParseException(
|
||||||
|
"Included keyboard layout must have <merge> root element", parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -111,22 +111,21 @@ public final class KeyboardRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getKeyX(final TypedArray keyAttr) {
|
public float getKeyX(final TypedArray keyAttr) {
|
||||||
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
|
if (keyAttr == null || !keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
|
||||||
final float keyXPos = keyAttr.getFraction(R.styleable.Keyboard_Key_keyXPos,
|
return mCurrentX;
|
||||||
mParams.mBaseWidth, mParams.mBaseWidth, 0);
|
|
||||||
if (keyXPos < 0) {
|
|
||||||
// If keyXPos is negative, the actual x-coordinate will be
|
|
||||||
// keyboardWidth + keyXPos.
|
|
||||||
// keyXPos shouldn't be less than mCurrentX because drawable area for this
|
|
||||||
// key starts at mCurrentX. Or, this key will overlaps the adjacent key on
|
|
||||||
// its left hand side.
|
|
||||||
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
|
|
||||||
return Math.max(keyXPos + keyboardRightEdge, mCurrentX);
|
|
||||||
} else {
|
|
||||||
return keyXPos + mParams.mLeftPadding;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mCurrentX;
|
final float keyXPos = keyAttr.getFraction(R.styleable.Keyboard_Key_keyXPos,
|
||||||
|
mParams.mBaseWidth, mParams.mBaseWidth, 0);
|
||||||
|
if (keyXPos >= 0) {
|
||||||
|
return keyXPos + mParams.mLeftPadding;
|
||||||
|
}
|
||||||
|
// If keyXPos is negative, the actual x-coordinate will be
|
||||||
|
// keyboardWidth + keyXPos.
|
||||||
|
// keyXPos shouldn't be less than mCurrentX because drawable area for this
|
||||||
|
// key starts at mCurrentX. Or, this key will overlaps the adjacent key on
|
||||||
|
// its left hand side.
|
||||||
|
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
|
||||||
|
return Math.max(keyXPos + keyboardRightEdge, mCurrentX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getKeyWidth(final TypedArray keyAttr) {
|
public float getKeyWidth(final TypedArray keyAttr) {
|
||||||
|
@ -134,6 +133,9 @@ public final class KeyboardRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getKeyWidth(final TypedArray keyAttr, final float keyXPos) {
|
public float getKeyWidth(final TypedArray keyAttr, final float keyXPos) {
|
||||||
|
if (keyAttr == null) {
|
||||||
|
return mDefaultKeyWidth;
|
||||||
|
}
|
||||||
final int widthType = ResourceUtils.getEnumValue(keyAttr,
|
final int widthType = ResourceUtils.getEnumValue(keyAttr,
|
||||||
R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
|
R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
|
||||||
switch (widthType) {
|
switch (widthType) {
|
||||||
|
|
Loading…
Reference in New Issue