Make horigontalGap and verticalGap attributes of Row obsolete

Bug: 5023981
Change-Id: Ifb07b54a68cfdd32ff2ea79812188fb6158bd073
This commit is contained in:
Tadashi G. Takaoka 2011-08-01 17:02:47 -07:00
parent 723dd753e9
commit 4d8eb2e888
3 changed files with 17 additions and 11 deletions

View file

@ -237,10 +237,10 @@ public class Key {
try { try {
mHeight = KeyboardParser.getDimensionOrFraction(keyboardAttr, mHeight = KeyboardParser.getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_rowHeight, R.styleable.Keyboard_rowHeight,
keyboard.getKeyboardHeight(), row.mDefaultHeight) - row.mVerticalGap; keyboard.getKeyboardHeight(), row.mDefaultHeight) - keyboard.getVerticalGap();
mHorizontalGap = KeyboardParser.getDimensionOrFraction(keyboardAttr, mHorizontalGap = KeyboardParser.getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_horizontalGap, R.styleable.Keyboard_horizontalGap,
keyboard.getDisplayWidth(), row.mDefaultHorizontalGap); keyboard.getDisplayWidth(), keyboard.getHorizontalGap());
mVerticalGap = keyboard.getVerticalGap(); mVerticalGap = keyboard.getVerticalGap();
keyWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr, keyWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_keyWidth, R.styleable.Keyboard_keyWidth,

View file

@ -256,7 +256,7 @@ public class KeyboardParser {
if (event == XmlPullParser.START_TAG) { if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName(); final String tag = parser.getName();
if (TAG_ROW.equals(tag)) { if (TAG_ROW.equals(tag)) {
Row row = new Row(mResources, mKeyboard, parser); Row row = parseRowAttributes(parser);
if (DEBUG) Log.d(TAG, String.format("<%s>", TAG_ROW)); if (DEBUG) Log.d(TAG, String.format("<%s>", TAG_ROW));
if (keys != null) if (keys != null)
startRow(row); startRow(row);
@ -288,6 +288,20 @@ public class KeyboardParser {
} }
} }
private Row parseRowAttributes(XmlResourceParser parser) {
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);
try {
if (a.hasValue(R.styleable.Keyboard_horizontalGap))
throw new IllegalAttribute(parser, "horizontalGap");
if (a.hasValue(R.styleable.Keyboard_verticalGap))
throw new IllegalAttribute(parser, "verticalGap");
return new Row(mResources, mKeyboard, parser);
} finally {
a.recycle();
}
}
private void parseRowContent(XmlResourceParser parser, Row row, List<Key> keys) private void parseRowContent(XmlResourceParser parser, Row row, List<Key> keys)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
int event; int event;

View file

@ -34,10 +34,6 @@ public class Row {
public final int mDefaultWidth; public final int mDefaultWidth;
/** Default height of a key in this row. */ /** Default height of a key in this row. */
public final int mDefaultHeight; public final int mDefaultHeight;
/** Default horizontal gap between keys in this row. */
public final int mDefaultHorizontalGap;
/** Vertical gap following this row. */
public final int mVerticalGap;
private final Keyboard mKeyboard; private final Keyboard mKeyboard;
@ -51,10 +47,6 @@ public class Row {
R.styleable.Keyboard_keyWidth, keyboardWidth, keyboard.getKeyWidth()); R.styleable.Keyboard_keyWidth, keyboardWidth, keyboard.getKeyWidth());
mDefaultHeight = KeyboardParser.getDimensionOrFraction(a, mDefaultHeight = KeyboardParser.getDimensionOrFraction(a,
R.styleable.Keyboard_rowHeight, keyboardHeight, keyboard.getRowHeight()); R.styleable.Keyboard_rowHeight, keyboardHeight, keyboard.getRowHeight());
mDefaultHorizontalGap = KeyboardParser.getDimensionOrFraction(a,
R.styleable.Keyboard_horizontalGap, keyboardWidth, keyboard.getHorizontalGap());
mVerticalGap = KeyboardParser.getDimensionOrFraction(a,
R.styleable.Keyboard_verticalGap, keyboardHeight, keyboard.getVerticalGap());
a.recycle(); a.recycle();
} }