am 522e1266: Cosmetic fixes

* commit '522e12660a8541a5e98b4737d55e40bd6c49ee00':
  Cosmetic fixes
main
Ken Wakasa 2012-08-18 09:33:50 -07:00 committed by Android Git Automerger
commit 13cc1dbaa3
1 changed files with 28 additions and 17 deletions

View File

@ -283,9 +283,10 @@ public class Keyboard {
public void load(String[] data) { public void load(String[] data) {
final int dataLength = data.length; final int dataLength = data.length;
if (dataLength % TOUCH_POSITION_CORRECTION_RECORD_SIZE != 0) { if (dataLength % TOUCH_POSITION_CORRECTION_RECORD_SIZE != 0) {
if (LatinImeLogger.sDBG) if (LatinImeLogger.sDBG) {
throw new RuntimeException( throw new RuntimeException(
"the size of touch position correction data is invalid"); "the size of touch position correction data is invalid");
}
return; return;
} }
@ -324,7 +325,7 @@ public class Keyboard {
public boolean isValid() { public boolean isValid() {
return mEnabled && mXs != null && mYs != null && mRadii != null return mEnabled && mXs != null && mYs != null && mRadii != null
&& mXs.length > 0 && mYs.length > 0 && mRadii.length > 0; && mXs.length > 0 && mYs.length > 0 && mRadii.length > 0;
} }
} }
@ -870,10 +871,12 @@ public class Keyboard {
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser), final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard); R.styleable.Keyboard);
try { try {
if (a.hasValue(R.styleable.Keyboard_horizontalGap)) if (a.hasValue(R.styleable.Keyboard_horizontalGap)) {
throw new XmlParseUtils.IllegalAttribute(parser, "horizontalGap"); throw new XmlParseUtils.IllegalAttribute(parser, "horizontalGap");
if (a.hasValue(R.styleable.Keyboard_verticalGap)) }
if (a.hasValue(R.styleable.Keyboard_verticalGap)) {
throw new XmlParseUtils.IllegalAttribute(parser, "verticalGap"); throw new XmlParseUtils.IllegalAttribute(parser, "verticalGap");
}
return new Row(mResources, mParams, parser, mCurrentY); return new Row(mResources, mParams, parser, mCurrentY);
} finally { } finally {
a.recycle(); a.recycle();
@ -921,7 +924,9 @@ public class Keyboard {
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
if (skip) { if (skip) {
XmlParseUtils.checkEndTag(TAG_KEY, parser); XmlParseUtils.checkEndTag(TAG_KEY, parser);
if (DEBUG) startEndTag("<%s /> skipped", TAG_KEY); if (DEBUG) {
startEndTag("<%s /> skipped", TAG_KEY);
}
} else { } else {
final Key key = new Key(mResources, mParams, row, parser); final Key key = new Key(mResources, mParams, row, parser);
if (DEBUG) { if (DEBUG) {
@ -1099,9 +1104,9 @@ public class Keyboard {
private boolean parseCaseCondition(XmlPullParser parser) { private boolean parseCaseCondition(XmlPullParser parser) {
final KeyboardId id = mParams.mId; final KeyboardId id = mParams.mId;
if (id == null) if (id == null) {
return true; return true;
}
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser), final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Case); R.styleable.Keyboard_Case);
try { try {
@ -1205,9 +1210,9 @@ public class Keyboard {
// If <case> does not have "index" attribute, that means this <case> is wild-card for // If <case> does not have "index" attribute, that means this <case> is wild-card for
// the attribute. // the attribute.
final TypedValue v = a.peekValue(index); final TypedValue v = a.peekValue(index);
if (v == null) if (v == null) {
return true; return true;
}
if (isIntegerValue(v)) { if (isIntegerValue(v)) {
return intValue == a.getInt(index, 0); return intValue == a.getInt(index, 0);
} else if (isStringValue(v)) { } else if (isStringValue(v)) {
@ -1218,8 +1223,9 @@ public class Keyboard {
private static boolean stringArrayContains(String[] array, String value) { private static boolean stringArrayContains(String[] array, String value) {
for (final String elem : array) { for (final String elem : array) {
if (elem.equals(value)) if (elem.equals(value)) {
return true; return true;
}
} }
return false; return false;
} }
@ -1242,16 +1248,18 @@ public class Keyboard {
TypedArray keyAttrs = mResources.obtainAttributes(Xml.asAttributeSet(parser), TypedArray keyAttrs = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Key); 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
+ "/> needs styleName attribute", parser); + "/> needs styleName attribute", parser);
}
if (DEBUG) { if (DEBUG) {
startEndTag("<%s styleName=%s />%s", TAG_KEY_STYLE, startEndTag("<%s styleName=%s />%s", TAG_KEY_STYLE,
keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName), keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName),
skip ? " skipped" : ""); skip ? " skipped" : "");
} }
if (!skip) if (!skip) {
mParams.mKeyStyles.parseKeyStyleAttributes(keyStyleAttr, keyAttrs, parser); mParams.mKeyStyles.parseKeyStyleAttributes(keyStyleAttr, keyAttrs, parser);
}
} finally { } finally {
keyStyleAttr.recycle(); keyStyleAttr.recycle();
keyAttrs.recycle(); keyAttrs.recycle();
@ -1272,8 +1280,9 @@ public class Keyboard {
} }
private void endRow(Row row) { private void endRow(Row row) {
if (mCurrentRow == null) if (mCurrentRow == null) {
throw new InflateException("orphan end row tag"); throw new InflateException("orphan end row tag");
}
if (mRightEdgeKey != null) { if (mRightEdgeKey != null) {
mRightEdgeKey.markAsRightEdge(mParams); mRightEdgeKey.markAsRightEdge(mParams);
mRightEdgeKey = null; mRightEdgeKey = null;
@ -1309,8 +1318,9 @@ public class Keyboard {
public static float getDimensionOrFraction(TypedArray a, int index, int base, public static float getDimensionOrFraction(TypedArray a, int index, int base,
float defValue) { float defValue) {
final TypedValue value = a.peekValue(index); final TypedValue value = a.peekValue(index);
if (value == null) if (value == null) {
return defValue; return defValue;
}
if (isFractionValue(value)) { if (isFractionValue(value)) {
return a.getFraction(index, base, base, defValue); return a.getFraction(index, base, base, defValue);
} else if (isDimensionValue(value)) { } else if (isDimensionValue(value)) {
@ -1321,8 +1331,9 @@ public class Keyboard {
public static int getEnumValue(TypedArray a, int index, int defValue) { public static int getEnumValue(TypedArray a, int index, int defValue) {
final TypedValue value = a.peekValue(index); final TypedValue value = a.peekValue(index);
if (value == null) if (value == null) {
return defValue; return defValue;
}
if (isIntegerValue(value)) { if (isIntegerValue(value)) {
return a.getInt(index, defValue); return a.getInt(index, defValue);
} }