Add followKeyLabelRatio flag for keyLabelFlags of Key attribute
This change renames largeLetter flag to followKeyLargeLetterRatio as well. Change-Id: Ida777aac57e4d885fa051654fe863f493f8e946amain
parent
10f18f5fb7
commit
ab0d0d8a02
|
@ -275,10 +275,11 @@
|
||||||
<flag name="alignLeft" value="0x01" />
|
<flag name="alignLeft" value="0x01" />
|
||||||
<flag name="alignRight" value="0x02" />
|
<flag name="alignRight" value="0x02" />
|
||||||
<flag name="alignLeftOfCenter" value="0x08" />
|
<flag name="alignLeftOfCenter" value="0x08" />
|
||||||
<flag name="largeLetter" value="0x10" />
|
<flag name="fontNormal" value="0x10" />
|
||||||
<flag name="fontNormal" value="0x20" />
|
<flag name="fontMonoSpace" value="0x20" />
|
||||||
<flag name="fontMonoSpace" value="0x40" />
|
<flag name="followKeyLargeLetterRatio" value="0x40" />
|
||||||
<flag name="followKeyLetterRatio" value="0x80" />
|
<flag name="followKeyLetterRatio" value="0x80" />
|
||||||
|
<flag name="followKeyLabelRatio" value="0xC0" />
|
||||||
<flag name="followKeyHintLabelRatio" value="0x100" />
|
<flag name="followKeyHintLabelRatio" value="0x100" />
|
||||||
<flag name="hasPopupHint" value="0x200" />
|
<flag name="hasPopupHint" value="0x200" />
|
||||||
<flag name="hasShiftedLetterHint" value="0x400" />
|
<flag name="hasShiftedLetterHint" value="0x400" />
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
latin:styleName="defaultEnterKeyStyle"
|
latin:styleName="defaultEnterKeyStyle"
|
||||||
latin:code="!code/key_enter"
|
latin:code="!code/key_enter"
|
||||||
latin:keyIcon="iconReturnKey"
|
latin:keyIcon="iconReturnKey"
|
||||||
latin:keyLabelFlags="autoXScale|preserveCase"
|
latin:keyLabelFlags="autoXScale|preserveCase|followKeyLabelRatio"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:keyActionFlags="noKeyPreview"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
latin:parentStyle="navigateMoreKeysStyle" />
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
latin:keyActionFlags="noKeyPreview" />
|
latin:keyActionFlags="noKeyPreview" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="numKeyStyle"
|
latin:styleName="numKeyStyle"
|
||||||
latin:keyLabelFlags="largeLetter|followKeyLetterRatio"
|
latin:keyLabelFlags="followKeyLargeLetterRatio"
|
||||||
latin:parentStyle="numKeyBaseStyle" />
|
latin:parentStyle="numKeyBaseStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="numModeKeyStyle"
|
latin:styleName="numModeKeyStyle"
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
latin:parentStyle="numKeyBaseStyle" />
|
latin:parentStyle="numKeyBaseStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="numFunctionalKeyStyle"
|
latin:styleName="numFunctionalKeyStyle"
|
||||||
latin:keyLabelFlags="largeLetter|followKeyLetterRatio"
|
latin:keyLabelFlags="followKeyLargeLetterRatio"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
latin:parentStyle="numKeyBaseStyle" />
|
latin:parentStyle="numKeyBaseStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
|
|
|
@ -60,10 +60,12 @@ public class Key {
|
||||||
private static final int LABEL_FLAGS_ALIGN_LEFT = 0x01;
|
private static final int LABEL_FLAGS_ALIGN_LEFT = 0x01;
|
||||||
private static final int LABEL_FLAGS_ALIGN_RIGHT = 0x02;
|
private static final int LABEL_FLAGS_ALIGN_RIGHT = 0x02;
|
||||||
private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
|
private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
|
||||||
private static final int LABEL_FLAGS_LARGE_LETTER = 0x10;
|
private static final int LABEL_FLAGS_FONT_NORMAL = 0x10;
|
||||||
private static final int LABEL_FLAGS_FONT_NORMAL = 0x20;
|
private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x20;
|
||||||
private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x40;
|
private static final int LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK = 0x1C0;
|
||||||
public static final int LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO = 0x80;
|
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_HINT_LABEL_RATIO = 0x100;
|
||||||
private static final int LABEL_FLAGS_HAS_POPUP_HINT = 0x200;
|
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_SHIFTED_LETTER_HINT = 0x400;
|
||||||
|
@ -498,16 +500,17 @@ public class Key {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
|
public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
|
||||||
if (StringUtils.codePointCount(mLabel) > 1
|
switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK) {
|
||||||
&& (mLabelFlags & (LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO
|
case LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO:
|
||||||
| LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO)) == 0) {
|
|
||||||
return label;
|
|
||||||
} else if ((mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO) != 0) {
|
|
||||||
return hintLabel;
|
|
||||||
} else if ((mLabelFlags & LABEL_FLAGS_LARGE_LETTER) != 0) {
|
|
||||||
return largeLetter;
|
return largeLetter;
|
||||||
} else {
|
case LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO:
|
||||||
return letter;
|
return letter;
|
||||||
|
case LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO:
|
||||||
|
return label;
|
||||||
|
case LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO:
|
||||||
|
return hintLabel;
|
||||||
|
default: // No follow key ratio flag specified.
|
||||||
|
return StringUtils.codePointCount(mLabel) == 1 ? letter : label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,6 +566,12 @@ public class Key {
|
||||||
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMoreKeyLabelFlags() {
|
||||||
|
return hasLabelsInMoreKeys()
|
||||||
|
? LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO
|
||||||
|
: LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean needsDividersInMoreKeys() {
|
public boolean needsDividersInMoreKeys() {
|
||||||
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,10 +332,7 @@ public class MoreKeysKeyboard extends Keyboard {
|
||||||
@Override
|
@Override
|
||||||
public MoreKeysKeyboard build() {
|
public MoreKeysKeyboard build() {
|
||||||
final MoreKeysKeyboardParams params = mParams;
|
final MoreKeysKeyboardParams params = mParams;
|
||||||
// moreKeyFlags == 0 means that the rendered text size will be determined by its
|
final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags();
|
||||||
// label's code point count.
|
|
||||||
final int moreKeyFlags = mParentKey.hasLabelsInMoreKeys() ? 0
|
|
||||||
: Key.LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
|
|
||||||
final MoreKeySpec[] moreKeys = mParentKey.mMoreKeys;
|
final MoreKeySpec[] moreKeys = mParentKey.mMoreKeys;
|
||||||
for (int n = 0; n < moreKeys.length; n++) {
|
for (int n = 0; n < moreKeys.length; n++) {
|
||||||
final MoreKeySpec moreKeySpec = moreKeys[n];
|
final MoreKeySpec moreKeySpec = moreKeys[n];
|
||||||
|
|
Loading…
Reference in New Issue