am 2133ca27: am 9fa0736d: Consolidate KeyboardView.keyLetterSize and keyLetterRatio
* commit '2133ca2759fcd89bbc7292757c17dfd3db760c1a': Consolidate KeyboardView.keyLetterSize and keyLetterRatiomain
commit
701cb39bd0
|
@ -41,26 +41,24 @@
|
||||||
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. -->
|
<!-- Size of the text for one letter keys. If specified as fraction, the text size is
|
||||||
<attr name="keyLetterSize" format="dimension" />
|
measured in the proportion of key height. -->
|
||||||
<!-- Size of the text for keys with multiple letters. If not defined, keyLabelRatio takes
|
<attr name="keyLetterSize" format="dimension|fraction" />
|
||||||
effect. -->
|
<!-- Size of the text for keys with multiple letters. If specified as fraction, the text
|
||||||
<attr name="keyLabelSize" format="dimension" />
|
size is measured in the proportion of key height. -->
|
||||||
<!-- Size of the text for one letter keys, in the proportion of key height. -->
|
<attr name="keyLabelSize" format="dimension|fraction" />
|
||||||
<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="fraction" />
|
||||||
<!-- Size of the text for keys with multiple letters, in the proportion of key height. -->
|
|
||||||
<attr name="keyLabelRatio" format="float" />
|
|
||||||
<!-- Large size of the text for keys with multiple letters, in the proportion of key height. -->
|
<!-- Large size of the text for keys with multiple letters, in the proportion of key height. -->
|
||||||
<attr name="keyLargeLabelRatio" format="float" />
|
<attr name="keyLargeLabelRatio" format="fraction" />
|
||||||
<!-- 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. -->
|
||||||
<attr name="keyHintLetterRatio" format="float" />
|
<attr name="keyHintLetterRatio" format="fraction" />
|
||||||
<!-- Size of the text for hint label, in the proportion of key height. -->
|
<!-- Size of the text for hint label, in the proportion of key height. -->
|
||||||
<attr name="keyHintLabelRatio" format="float" />
|
<attr name="keyHintLabelRatio" format="fraction" />
|
||||||
<!-- Size of the text for shifted letter hint, in the proportion of key height. -->
|
<!-- Size of the text for shifted letter hint, in the proportion of key height. -->
|
||||||
<attr name="keyShiftedLetterHintRatio" format="float" />
|
<attr name="keyShiftedLetterHintRatio" format="dimension|fraction" />
|
||||||
|
|
||||||
<!-- Horizontal padding of left/right aligned key label to the edge of the key. -->
|
<!-- Horizontal padding of left/right aligned key label to the edge of the key. -->
|
||||||
<attr name="keyLabelHorizontalPadding" format="dimension" />
|
<attr name="keyLabelHorizontalPadding" format="dimension" />
|
||||||
<!-- Right padding of hint letter to the edge of the key.-->
|
<!-- Right padding of hint letter to the edge of the key.-->
|
||||||
|
@ -96,8 +94,8 @@
|
||||||
<attr name="keyPreviewOffset" format="dimension" />
|
<attr name="keyPreviewOffset" format="dimension" />
|
||||||
<!-- Height of the key press feedback popup. -->
|
<!-- Height of the key press feedback popup. -->
|
||||||
<attr name="keyPreviewHeight" format="dimension" />
|
<attr name="keyPreviewHeight" format="dimension" />
|
||||||
<!-- Size of the text for key press feedback popup, int the proportion of key height -->
|
<!-- Size of the text for key press feedback popup, in the proportion of key height. -->
|
||||||
<attr name="keyPreviewTextRatio" format="float" />
|
<attr name="keyPreviewTextRatio" format="fraction" />
|
||||||
<!-- Delay after key releasing and key press feedback dismissing in millisecond -->
|
<!-- Delay after key releasing and key press feedback dismissing in millisecond -->
|
||||||
<attr name="keyPreviewLingerTimeout" format="integer" />
|
<attr name="keyPreviewLingerTimeout" format="integer" />
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
<style name="KeyboardView">
|
<style name="KeyboardView">
|
||||||
<item name="android:background">@drawable/keyboard_background</item>
|
<item name="android:background">@drawable/keyboard_background</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key</item>
|
||||||
<item name="keyLetterRatio">@fraction/key_letter_ratio</item>
|
<item name="keyLetterSize">@fraction/key_letter_ratio</item>
|
||||||
<item name="keyLargeLetterRatio">@fraction/key_large_letter_ratio</item>
|
<item name="keyLargeLetterRatio">@fraction/key_large_letter_ratio</item>
|
||||||
<item name="keyLabelRatio">@fraction/key_label_ratio</item>
|
<item name="keyLabelSize">@fraction/key_label_ratio</item>
|
||||||
<item name="keyLargeLabelRatio">@fraction/key_large_label_ratio</item>
|
<item name="keyLargeLabelRatio">@fraction/key_large_label_ratio</item>
|
||||||
<item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item>
|
<item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item>
|
||||||
<item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item>
|
<item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item>
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
// Miscellaneous constants
|
// Miscellaneous constants
|
||||||
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
|
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
|
||||||
private static final float UNDEFINED_RATIO = -1.0f;
|
private static final float UNDEFINED_RATIO = -1.0f;
|
||||||
|
private static final int UNDEFINED_DIMENSION = -1;
|
||||||
|
|
||||||
// XML attributes
|
// XML attributes
|
||||||
protected final float mVerticalCorrection;
|
protected final float mVerticalCorrection;
|
||||||
|
@ -214,19 +215,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
public int mKeyHintLabelSize;
|
public int mKeyHintLabelSize;
|
||||||
public int mAnimAlpha;
|
public int mAnimAlpha;
|
||||||
|
|
||||||
public KeyDrawParams(TypedArray a) {
|
public KeyDrawParams(final TypedArray a) {
|
||||||
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
||||||
if (a.hasValue(R.styleable.KeyboardView_keyLetterSize)) {
|
if (!isValidFraction(mKeyLetterRatio = getFraction(a,
|
||||||
mKeyLetterRatio = UNDEFINED_RATIO;
|
R.styleable.KeyboardView_keyLetterSize))) {
|
||||||
mKeyLetterSize = a.getDimensionPixelSize(R.styleable.KeyboardView_keyLetterSize, 0);
|
mKeyLetterSize = getDimensionPixelSize(a, R.styleable.KeyboardView_keyLetterSize);
|
||||||
} else {
|
|
||||||
mKeyLetterRatio = getFraction(a, R.styleable.KeyboardView_keyLetterRatio);
|
|
||||||
}
|
}
|
||||||
if (a.hasValue(R.styleable.KeyboardView_keyLabelSize)) {
|
if (!isValidFraction(mKeyLabelRatio = getFraction(a,
|
||||||
mKeyLabelRatio = UNDEFINED_RATIO;
|
R.styleable.KeyboardView_keyLabelSize))) {
|
||||||
mKeyLabelSize = a.getDimensionPixelSize(R.styleable.KeyboardView_keyLabelSize, 0);
|
mKeyLabelSize = getDimensionPixelSize(a, R.styleable.KeyboardView_keyLabelSize);
|
||||||
} else {
|
|
||||||
mKeyLabelRatio = getFraction(a, R.styleable.KeyboardView_keyLabelRatio);
|
|
||||||
}
|
}
|
||||||
mKeyLargeLabelRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLabelRatio);
|
mKeyLargeLabelRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLabelRatio);
|
||||||
mKeyLargeLetterRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
mKeyLargeLetterRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
||||||
|
@ -392,9 +389,21 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
static float getFraction(final TypedArray a, final int index) {
|
static float getFraction(final TypedArray a, final int index) {
|
||||||
|
final TypedValue value = a.peekValue(index);
|
||||||
|
if (value == null || value.type != TypedValue.TYPE_FRACTION) {
|
||||||
|
return UNDEFINED_RATIO;
|
||||||
|
}
|
||||||
return a.getFraction(index, 1, 1, UNDEFINED_RATIO);
|
return a.getFraction(index, 1, 1, UNDEFINED_RATIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDimensionPixelSize(final TypedArray a, final int index) {
|
||||||
|
final TypedValue value = a.peekValue(index);
|
||||||
|
if (value == null || value.type != TypedValue.TYPE_DIMENSION) {
|
||||||
|
return UNDEFINED_DIMENSION;
|
||||||
|
}
|
||||||
|
return a.getDimensionPixelSize(index, UNDEFINED_DIMENSION);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a keyboard to this view. The keyboard can be switched at any time and the
|
* Attaches a keyboard to this view. The keyboard can be switched at any time and the
|
||||||
* view will re-layout itself to accommodate the keyboard.
|
* view will re-layout itself to accommodate the keyboard.
|
||||||
|
|
Loading…
Reference in New Issue