Remove Keyboard reference from Key object
Bug: 5023981 Change-Id: Ib0b9debf2018a0a9e9efe9323738e85174589e71main
parent
30479de9e5
commit
723dd753e9
|
@ -73,7 +73,9 @@ public class Key {
|
||||||
/** Height of the key, not including the gap */
|
/** Height of the key, not including the gap */
|
||||||
public final int mHeight;
|
public final int mHeight;
|
||||||
/** The horizontal gap around this key */
|
/** The horizontal gap around this key */
|
||||||
public final int mGap;
|
public final int mHorizontalGap;
|
||||||
|
/** The vertical gap below this key */
|
||||||
|
public final int mVerticalGap;
|
||||||
/** The visual insets */
|
/** The visual insets */
|
||||||
public final int mVisualInsetsLeft;
|
public final int mVisualInsetsLeft;
|
||||||
public final int mVisualInsetsRight;
|
public final int mVisualInsetsRight;
|
||||||
|
@ -102,9 +104,6 @@ public class Key {
|
||||||
/** Whether this key repeats itself when held down */
|
/** Whether this key repeats itself when held down */
|
||||||
public final boolean mRepeatable;
|
public final boolean mRepeatable;
|
||||||
|
|
||||||
/** The Keyboard that this key belongs to */
|
|
||||||
private final Keyboard mKeyboard;
|
|
||||||
|
|
||||||
/** The current pressed state of this key */
|
/** The current pressed state of this key */
|
||||||
private boolean mPressed;
|
private boolean mPressed;
|
||||||
/** If this is a sticky key, is its highlight on? */
|
/** If this is a sticky key, is its highlight on? */
|
||||||
|
@ -193,11 +192,11 @@ public class Key {
|
||||||
*/
|
*/
|
||||||
public Key(Resources res, Keyboard keyboard, CharSequence popupCharacter, int x, int y,
|
public Key(Resources res, Keyboard keyboard, CharSequence popupCharacter, int x, int y,
|
||||||
int width, int height, int edgeFlags) {
|
int width, int height, int edgeFlags) {
|
||||||
mKeyboard = keyboard;
|
|
||||||
mHeight = height - keyboard.getVerticalGap();
|
mHeight = height - keyboard.getVerticalGap();
|
||||||
mGap = keyboard.getHorizontalGap();
|
mHorizontalGap = keyboard.getHorizontalGap();
|
||||||
|
mVerticalGap = keyboard.getVerticalGap();
|
||||||
mVisualInsetsLeft = mVisualInsetsRight = 0;
|
mVisualInsetsLeft = mVisualInsetsRight = 0;
|
||||||
mWidth = width - mGap;
|
mWidth = width - mHorizontalGap;
|
||||||
mEdgeFlags = edgeFlags;
|
mEdgeFlags = edgeFlags;
|
||||||
mHintLabel = null;
|
mHintLabel = null;
|
||||||
mLabelOption = 0;
|
mLabelOption = 0;
|
||||||
|
@ -213,7 +212,7 @@ public class Key {
|
||||||
mCode = keyboard.isRtlKeyboard() ? getRtlParenthesisCode(code) : code;
|
mCode = keyboard.isRtlKeyboard() ? getRtlParenthesisCode(code) : code;
|
||||||
mIcon = keyboard.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification));
|
mIcon = keyboard.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification));
|
||||||
// Horizontal gap is divided equally to both sides of the key.
|
// Horizontal gap is divided equally to both sides of the key.
|
||||||
mX = x + mGap / 2;
|
mX = x + mHorizontalGap / 2;
|
||||||
mY = y;
|
mY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ public class Key {
|
||||||
*/
|
*/
|
||||||
public Key(Resources res, Row row, int x, int y, XmlResourceParser parser,
|
public Key(Resources res, Row row, int x, int y, XmlResourceParser parser,
|
||||||
KeyStyles keyStyles) {
|
KeyStyles keyStyles) {
|
||||||
mKeyboard = row.getKeyboard();
|
final Keyboard keyboard = row.getKeyboard();
|
||||||
|
|
||||||
final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
|
final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
|
||||||
R.styleable.Keyboard);
|
R.styleable.Keyboard);
|
||||||
|
@ -238,13 +237,14 @@ public class Key {
|
||||||
try {
|
try {
|
||||||
mHeight = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
mHeight = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
||||||
R.styleable.Keyboard_rowHeight,
|
R.styleable.Keyboard_rowHeight,
|
||||||
mKeyboard.getKeyboardHeight(), row.mDefaultHeight) - row.mVerticalGap;
|
keyboard.getKeyboardHeight(), row.mDefaultHeight) - row.mVerticalGap;
|
||||||
mGap = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
mHorizontalGap = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
||||||
R.styleable.Keyboard_horizontalGap,
|
R.styleable.Keyboard_horizontalGap,
|
||||||
mKeyboard.getDisplayWidth(), row.mDefaultHorizontalGap);
|
keyboard.getDisplayWidth(), row.mDefaultHorizontalGap);
|
||||||
|
mVerticalGap = keyboard.getVerticalGap();
|
||||||
keyWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
keyWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr,
|
||||||
R.styleable.Keyboard_keyWidth,
|
R.styleable.Keyboard_keyWidth,
|
||||||
mKeyboard.getDisplayWidth(), row.mDefaultWidth);
|
keyboard.getDisplayWidth(), row.mDefaultWidth);
|
||||||
} finally {
|
} finally {
|
||||||
keyboardAttr.recycle();
|
keyboardAttr.recycle();
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ public class Key {
|
||||||
style = keyStyles.getEmptyKeyStyle();
|
style = keyStyles.getEmptyKeyStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int keyboardWidth = mKeyboard.getDisplayWidth();
|
final int keyboardWidth = keyboard.getDisplayWidth();
|
||||||
int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr,
|
int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||||
R.styleable.Keyboard_Key_keyXPos, keyboardWidth, x);
|
R.styleable.Keyboard_Key_keyXPos, keyboardWidth, x);
|
||||||
if (keyXPos < 0) {
|
if (keyXPos < 0) {
|
||||||
|
@ -287,19 +287,19 @@ public class Key {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal gap is divided equally to both sides of the key.
|
// Horizontal gap is divided equally to both sides of the key.
|
||||||
mX = keyXPos + mGap / 2;
|
mX = keyXPos + mHorizontalGap / 2;
|
||||||
mY = y;
|
mY = y;
|
||||||
mWidth = keyWidth - mGap;
|
mWidth = keyWidth - mHorizontalGap;
|
||||||
|
|
||||||
CharSequence[] popupCharacters = style.getTextArray(
|
CharSequence[] popupCharacters = style.getTextArray(
|
||||||
keyAttr, R.styleable.Keyboard_Key_popupCharacters);
|
keyAttr, R.styleable.Keyboard_Key_popupCharacters);
|
||||||
if (mKeyboard.mId.mPasswordInput) {
|
if (keyboard.mId.mPasswordInput) {
|
||||||
popupCharacters = PopupCharactersParser.filterOut(
|
popupCharacters = PopupCharactersParser.filterOut(
|
||||||
res, popupCharacters, PopupCharactersParser.NON_ASCII_FILTER);
|
res, popupCharacters, PopupCharactersParser.NON_ASCII_FILTER);
|
||||||
}
|
}
|
||||||
// In Arabic symbol layouts, we'd like to keep digits in popup characters regardless of
|
// In Arabic symbol layouts, we'd like to keep digits in popup characters regardless of
|
||||||
// config_digit_popup_characters_enabled.
|
// config_digit_popup_characters_enabled.
|
||||||
if (mKeyboard.mId.isAlphabetKeyboard() && !res.getBoolean(
|
if (keyboard.mId.isAlphabetKeyboard() && !res.getBoolean(
|
||||||
R.bool.config_digit_popup_characters_enabled)) {
|
R.bool.config_digit_popup_characters_enabled)) {
|
||||||
mPopupCharacters = PopupCharactersParser.filterOut(
|
mPopupCharacters = PopupCharactersParser.filterOut(
|
||||||
res, popupCharacters, PopupCharactersParser.DIGIT_FILTER);
|
res, popupCharacters, PopupCharactersParser.DIGIT_FILTER);
|
||||||
|
@ -308,7 +308,7 @@ public class Key {
|
||||||
}
|
}
|
||||||
mMaxPopupColumn = style.getInt(keyboardAttr,
|
mMaxPopupColumn = style.getInt(keyboardAttr,
|
||||||
R.styleable.Keyboard_Key_maxPopupKeyboardColumn,
|
R.styleable.Keyboard_Key_maxPopupKeyboardColumn,
|
||||||
mKeyboard.getMaxPopupKeyboardColumn());
|
keyboard.getMaxPopupKeyboardColumn());
|
||||||
|
|
||||||
mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false);
|
mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false);
|
||||||
mFunctional = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional, false);
|
mFunctional = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional, false);
|
||||||
|
@ -316,7 +316,7 @@ public class Key {
|
||||||
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
|
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
|
||||||
mEdgeFlags = 0;
|
mEdgeFlags = 0;
|
||||||
|
|
||||||
final KeyboardIconsSet iconsSet = mKeyboard.mIconsSet;
|
final KeyboardIconsSet iconsSet = keyboard.mIconsSet;
|
||||||
mVisualInsetsLeft = KeyboardParser.getDimensionOrFraction(keyAttr,
|
mVisualInsetsLeft = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||||
R.styleable.Keyboard_Key_visualInsetsLeft, keyboardWidth, 0);
|
R.styleable.Keyboard_Key_visualInsetsLeft, keyboardWidth, 0);
|
||||||
mVisualInsetsRight = KeyboardParser.getDimensionOrFraction(keyAttr,
|
mVisualInsetsRight = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||||
|
@ -331,7 +331,7 @@ public class Key {
|
||||||
KeyboardIconsSet.ICON_UNDEFINED);
|
KeyboardIconsSet.ICON_UNDEFINED);
|
||||||
if (shiftedIconId != KeyboardIconsSet.ICON_UNDEFINED) {
|
if (shiftedIconId != KeyboardIconsSet.ICON_UNDEFINED) {
|
||||||
final Drawable shiftedIcon = iconsSet.getIcon(shiftedIconId);
|
final Drawable shiftedIcon = iconsSet.getIcon(shiftedIconId);
|
||||||
mKeyboard.addShiftedIcon(this, shiftedIcon);
|
keyboard.addShiftedIcon(this, shiftedIcon);
|
||||||
}
|
}
|
||||||
mHintLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLabel);
|
mHintLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLabel);
|
||||||
|
|
||||||
|
@ -344,14 +344,14 @@ public class Key {
|
||||||
Keyboard.CODE_UNSPECIFIED);
|
Keyboard.CODE_UNSPECIFIED);
|
||||||
if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) {
|
if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) {
|
||||||
final int firstChar = mLabel.charAt(0);
|
final int firstChar = mLabel.charAt(0);
|
||||||
mCode = mKeyboard.isRtlKeyboard() ? getRtlParenthesisCode(firstChar) : firstChar;
|
mCode = keyboard.isRtlKeyboard() ? getRtlParenthesisCode(firstChar) : firstChar;
|
||||||
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
||||||
mCode = code;
|
mCode = code;
|
||||||
} else {
|
} else {
|
||||||
mCode = Keyboard.CODE_DUMMY;
|
mCode = Keyboard.CODE_DUMMY;
|
||||||
}
|
}
|
||||||
if (mCode == Keyboard.CODE_SHIFT) {
|
if (mCode == Keyboard.CODE_SHIFT) {
|
||||||
mKeyboard.addShiftKey(this);
|
keyboard.addShiftKey(this);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
keyAttr.recycle();
|
keyAttr.recycle();
|
||||||
|
@ -453,10 +453,10 @@ public class Key {
|
||||||
* assume that all points between the key and the edge are considered to be on the key.
|
* assume that all points between the key and the edge are considered to be on the key.
|
||||||
*/
|
*/
|
||||||
public boolean isOnKey(int x, int y) {
|
public boolean isOnKey(int x, int y) {
|
||||||
final int left = mX - mGap / 2;
|
final int left = mX - mHorizontalGap / 2;
|
||||||
final int right = left + mWidth + mGap;
|
final int right = left + mWidth + mHorizontalGap;
|
||||||
final int top = mY;
|
final int top = mY;
|
||||||
final int bottom = top + mHeight + mKeyboard.getVerticalGap();
|
final int bottom = top + mHeight + mVerticalGap;
|
||||||
final int flags = mEdgeFlags;
|
final int flags = mEdgeFlags;
|
||||||
if (flags == 0) {
|
if (flags == 0) {
|
||||||
return x >= left && x <= right && y >= top && y <= bottom;
|
return x >= left && x <= right && y >= top && y <= bottom;
|
||||||
|
|
|
@ -401,7 +401,7 @@ public class Keyboard {
|
||||||
int maxCount = 0;
|
int maxCount = 0;
|
||||||
int mostCommonWidth = 0;
|
int mostCommonWidth = 0;
|
||||||
for (final Key key : mKeys) {
|
for (final Key key : mKeys) {
|
||||||
final Integer width = key.mWidth + key.mGap;
|
final Integer width = key.mWidth + key.mHorizontalGap;
|
||||||
Integer count = histogram.get(width);
|
Integer count = histogram.get(width);
|
||||||
if (count == null)
|
if (count == null)
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
|
@ -644,7 +644,7 @@ public class KeyboardParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endKey(Key key) {
|
private void endKey(Key key) {
|
||||||
mCurrentX = key.mX - key.mGap / 2 + key.mWidth + key.mGap;
|
mCurrentX = key.mX - key.mHorizontalGap / 2 + key.mWidth + key.mHorizontalGap;
|
||||||
if (mLeftEdge) {
|
if (mLeftEdge) {
|
||||||
key.addEdgeFlags(Keyboard.EDGE_LEFT);
|
key.addEdgeFlags(Keyboard.EDGE_LEFT);
|
||||||
mLeftEdge = false;
|
mLeftEdge = false;
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class MiniKeyboardBuilder {
|
||||||
final MiniKeyboardLayoutParams params = new MiniKeyboardLayoutParams(
|
final MiniKeyboardLayoutParams params = new MiniKeyboardLayoutParams(
|
||||||
mPopupCharacters.length, parentKey.mMaxPopupColumn,
|
mPopupCharacters.length, parentKey.mMaxPopupColumn,
|
||||||
keyWidth, parentKeyboard.getRowHeight(),
|
keyWidth, parentKeyboard.getRowHeight(),
|
||||||
parentKey.mX + (parentKey.mWidth + parentKey.mGap) / 2 - keyWidth / 2,
|
parentKey.mX + (parentKey.mWidth + parentKey.mHorizontalGap) / 2 - keyWidth / 2,
|
||||||
view.getMeasuredWidth());
|
view.getMeasuredWidth());
|
||||||
params.setTopPadding(keyboard.getVerticalGap());
|
params.setTopPadding(keyboard.getVerticalGap());
|
||||||
mParams = params;
|
mParams = params;
|
||||||
|
|
Loading…
Reference in New Issue