Add keyLetterSize and keyLabelSize as KeyboardView attribute
Bug: 5023981 Change-Id: Iea7f8f340775cbb093c50d6e741b2f1476e9ac39main
parent
a9311741b8
commit
83da6c18fb
|
@ -38,11 +38,16 @@
|
||||||
checkable+checked+pressed. -->
|
checkable+checked+pressed. -->
|
||||||
<attr name="keyBackground" format="reference" />
|
<attr name="keyBackground" format="reference" />
|
||||||
|
|
||||||
|
<!-- Size of the text for one letter keys. If not defined, keyLetterRatio takes effect. -->
|
||||||
|
<attr name="keyLetterSize" format="float" />
|
||||||
|
<!-- Size of the text for keys with multiple letters. If not defined, keyLabelRatio takes
|
||||||
|
effect. -->
|
||||||
|
<attr name="keyLabelSize" format="float" />
|
||||||
<!-- Size of the text for one letter keys, in the proportion of key height. -->
|
<!-- Size of the text for one letter keys, in the proportion of key height. -->
|
||||||
<attr name="keyLetterRatio" format="float" />
|
<attr name="keyLetterRatio" format="float" />
|
||||||
<!-- Large size of the text for one letter keys, in the proportion of key height. -->
|
<!-- Large size of the text for one letter keys, in the proportion of key height. -->
|
||||||
<attr name="keyLargeLetterRatio" format="float" />
|
<attr name="keyLargeLetterRatio" format="float" />
|
||||||
<!-- Size of the text for keys with some text, in the proportion of key height. -->
|
<!-- Size of the text for keys with multiple letters, in the proportion of key height. -->
|
||||||
<attr name="keyLabelRatio" format="float" />
|
<attr name="keyLabelRatio" format="float" />
|
||||||
<!-- Size of the text for hint letter (= one character hint label), in the proportion of
|
<!-- Size of the text for hint letter (= one character hint label), in the proportion of
|
||||||
key height. -->
|
key height. -->
|
||||||
|
|
|
@ -211,6 +211,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
private final float mKeyHintLetterRatio;
|
private final float mKeyHintLetterRatio;
|
||||||
private final float mKeyUppercaseLetterRatio;
|
private final float mKeyUppercaseLetterRatio;
|
||||||
private final float mKeyHintLabelRatio;
|
private final float mKeyHintLabelRatio;
|
||||||
|
private static final float UNDEFINED_RATIO = -1.0f;
|
||||||
|
|
||||||
public final Rect mPadding = new Rect();
|
public final Rect mPadding = new Rect();
|
||||||
public int mKeyLetterSize;
|
public int mKeyLetterSize;
|
||||||
|
@ -222,9 +223,21 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
public KeyDrawParams(TypedArray a) {
|
public KeyDrawParams(TypedArray a) {
|
||||||
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
||||||
|
if (a.hasValue(R.styleable.KeyboardView_keyLabelSize)) {
|
||||||
|
mKeyLetterRatio = UNDEFINED_RATIO;
|
||||||
|
mKeyLetterSize = a.getDimensionPixelSize(
|
||||||
|
R.styleable.KeyboardView_keyLetterRatio, 0);
|
||||||
|
} else {
|
||||||
mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio);
|
mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio);
|
||||||
|
}
|
||||||
mKeyLargeLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
mKeyLargeLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
||||||
|
if (a.hasValue(R.styleable.KeyboardView_keyLabelSize)) {
|
||||||
|
mKeyLabelRatio = UNDEFINED_RATIO;
|
||||||
|
mKeyLabelSize = a.getDimensionPixelSize(
|
||||||
|
R.styleable.KeyboardView_keyLabelRatio, 0);
|
||||||
|
} else {
|
||||||
mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio);
|
mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio);
|
||||||
|
}
|
||||||
mKeyHintLetterRatio = getRatio(a, R.styleable.KeyboardView_keyHintLetterRatio);
|
mKeyHintLetterRatio = getRatio(a, R.styleable.KeyboardView_keyHintLetterRatio);
|
||||||
mKeyUppercaseLetterRatio = getRatio(a,
|
mKeyUppercaseLetterRatio = getRatio(a,
|
||||||
R.styleable.KeyboardView_keyUppercaseLetterRatio);
|
R.styleable.KeyboardView_keyUppercaseLetterRatio);
|
||||||
|
@ -253,8 +266,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateKeyHeight(int keyHeight) {
|
public void updateKeyHeight(int keyHeight) {
|
||||||
|
if (mKeyLetterRatio >= 0.0f)
|
||||||
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
||||||
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
|
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
|
||||||
|
if (mKeyLabelRatio >= 0.0f)
|
||||||
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
|
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
|
||||||
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
|
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
|
||||||
mKeyUppercaseLetterSize = (int)(keyHeight * mKeyUppercaseLetterRatio);
|
mKeyUppercaseLetterSize = (int)(keyHeight * mKeyUppercaseLetterRatio);
|
||||||
|
|
Loading…
Reference in New Issue