am 817a66e7: Merge "Support large label text ratio in KeyboardView" into jb-dev
* commit '817a66e7e6bc9eb0bc74bacf0431308f40185cb1': Support large label text ratio in KeyboardViewmain
commit
db8b3a1ecf
|
@ -55,6 +55,8 @@
|
|||
<attr name="keyLargeLetterRatio" format="float" />
|
||||
<!-- 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. -->
|
||||
<attr name="keyLargeLabelRatio" format="float" />
|
||||
<!-- Size of the text for hint letter (= one character hint label), in the proportion of
|
||||
key height. -->
|
||||
<attr name="keyHintLetterRatio" format="float" />
|
||||
|
@ -275,7 +277,8 @@
|
|||
<flag name="followKeyLargeLetterRatio" value="0x40" />
|
||||
<flag name="followKeyLetterRatio" value="0x80" />
|
||||
<flag name="followKeyLabelRatio" value="0xC0" />
|
||||
<flag name="followKeyHintLabelRatio" value="0x100" />
|
||||
<flag name="followKeyLargeLabelRatio" value="0x100" />
|
||||
<flag name="followKeyHintLabelRatio" value="0x140" />
|
||||
<flag name="hasPopupHint" value="0x200" />
|
||||
<flag name="hasShiftedLetterHint" value="0x400" />
|
||||
<flag name="hasHintLabel" value="0x800" />
|
||||
|
|
|
@ -66,11 +66,14 @@ public class Key {
|
|||
private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
|
||||
private static final int LABEL_FLAGS_FONT_NORMAL = 0x10;
|
||||
private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x20;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK = 0x1C0;
|
||||
// Start of key text ratio enum values
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_TEXT_RATIO_MASK = 0x1C0;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO = 0x40;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO = 0x80;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO = 0xC0;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO = 0x100;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_LARGE_LABEL_RATIO = 0x100;
|
||||
private static final int LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO = 0x140;
|
||||
// End of key text ratio mask enum values
|
||||
private static final int LABEL_FLAGS_HAS_POPUP_HINT = 0x200;
|
||||
private static final int LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT = 0x400;
|
||||
private static final int LABEL_FLAGS_HAS_HINT_LABEL = 0x800;
|
||||
|
@ -490,18 +493,21 @@ public class Key {
|
|||
}
|
||||
}
|
||||
|
||||
public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
|
||||
switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK) {
|
||||
public int selectTextSize(KeyboardView.KeyDrawParams params) {
|
||||
switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_TEXT_RATIO_MASK) {
|
||||
case LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO:
|
||||
return largeLetter;
|
||||
return params.mKeyLargeLetterSize;
|
||||
case LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO:
|
||||
return letter;
|
||||
return params.mKeyLetterSize;
|
||||
case LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO:
|
||||
return label;
|
||||
return params.mKeyLabelSize;
|
||||
case LABEL_FLAGS_FOLLOW_KEY_LARGE_LABEL_RATIO:
|
||||
return params.mKeyLargeLabelSize;
|
||||
case LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO:
|
||||
return hintLabel;
|
||||
return params.mKeyHintLabelSize;
|
||||
default: // No follow key ratio flag specified.
|
||||
return StringUtils.codePointCount(mLabel) == 1 ? letter : label;
|
||||
return StringUtils.codePointCount(mLabel) == 1
|
||||
? params.mKeyLetterSize : params.mKeyLabelSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
/* package */ final float mKeyLetterRatio;
|
||||
private final float mKeyLargeLetterRatio;
|
||||
private final float mKeyLabelRatio;
|
||||
private final float mKeyLargeLabelRatio;
|
||||
private final float mKeyHintLetterRatio;
|
||||
private final float mKeyShiftedLetterHintRatio;
|
||||
private final float mKeyHintLabelRatio;
|
||||
|
@ -200,6 +201,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
public int mKeyLetterSize;
|
||||
public int mKeyLargeLetterSize;
|
||||
public int mKeyLabelSize;
|
||||
public int mKeyLargeLabelSize;
|
||||
public int mKeyHintLetterSize;
|
||||
public int mKeyShiftedLetterHintSize;
|
||||
public int mKeyHintLabelSize;
|
||||
|
@ -219,6 +221,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
} else {
|
||||
mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio);
|
||||
}
|
||||
mKeyLargeLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLabelRatio);
|
||||
mKeyLargeLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
||||
mKeyHintLetterRatio = getRatio(a, R.styleable.KeyboardView_keyHintLetterRatio);
|
||||
mKeyShiftedLetterHintRatio = getRatio(a,
|
||||
|
@ -254,6 +257,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
||||
if (mKeyLabelRatio >= 0.0f)
|
||||
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
|
||||
mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio);
|
||||
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
|
||||
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
|
||||
mKeyShiftedLetterHintSize = (int)(keyHeight * mKeyShiftedLetterHintRatio);
|
||||
|
@ -569,8 +573,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
final String label = key.mLabel;
|
||||
// For characters, use large font. For labels like "Done", use smaller font.
|
||||
paint.setTypeface(key.selectTypeface(params.mKeyTextStyle));
|
||||
final int labelSize = key.selectTextSize(params.mKeyLetterSize,
|
||||
params.mKeyLargeLetterSize, params.mKeyLabelSize, params.mKeyHintLabelSize);
|
||||
final int labelSize = key.selectTextSize(params);
|
||||
paint.setTextSize(labelSize);
|
||||
final float labelCharHeight = getCharHeight(KEY_LABEL_REFERENCE_CHAR, paint);
|
||||
final float labelCharWidth = getCharWidth(KEY_LABEL_REFERENCE_CHAR, paint);
|
||||
|
|
Loading…
Reference in New Issue