am 63ee10d6: am c29276b7: am 12814352: am 486c4894: Keep aspect ratio of Material action key background
* commit '63ee10d63a67fd8e2de3047c4a8de1dbac0c9fc1': Keep aspect ratio of Material action key backgroundmain
commit
0198674ded
|
@ -338,6 +338,8 @@
|
||||||
<!-- If true, use functionalTextColor instead of ketTextColor to drawing the label on
|
<!-- If true, use functionalTextColor instead of ketTextColor to drawing the label on
|
||||||
the key -->
|
the key -->
|
||||||
<flag name="followFunctionalTextColor" value="0x80000" />
|
<flag name="followFunctionalTextColor" value="0x80000" />
|
||||||
|
<!-- Keep aspect ratio of key background. -->
|
||||||
|
<flag name="keepBackgroundAspectRatio" value="0x100000" />
|
||||||
<!-- If true, disable keyHintLabel. -->
|
<!-- If true, disable keyHintLabel. -->
|
||||||
<flag name="disableKeyHintLabel" value="0x40000000" />
|
<flag name="disableKeyHintLabel" value="0x40000000" />
|
||||||
<!-- If true, disable additionalMoreKeys. -->
|
<!-- If true, disable additionalMoreKeys. -->
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
<item name="android:background">@android:color/transparent</item>
|
<item name="android:background">@android:color/transparent</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_dark</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_dark</item>
|
||||||
<item name="divider">@null</item>
|
<item name="divider">@null</item>
|
||||||
|
<item name="keyLabelFlags">keepBackgroundAspectRatio</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="SuggestionStripView.LXX_Dark"
|
name="SuggestionStripView.LXX_Dark"
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
<item name="android:background">@android:color/transparent</item>
|
<item name="android:background">@android:color/transparent</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_light</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_light</item>
|
||||||
<item name="divider">@null</item>
|
<item name="divider">@null</item>
|
||||||
|
<item name="keyLabelFlags">keepBackgroundAspectRatio</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="SuggestionStripView.LXX_Light"
|
name="SuggestionStripView.LXX_Light"
|
||||||
|
|
|
@ -80,13 +80,27 @@
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<!-- Enter key style -->
|
<!-- Enter key style -->
|
||||||
<key-style
|
<switch>
|
||||||
latin:styleName="defaultEnterKeyStyle"
|
<case latin:keyboardTheme="ICS|KLP">
|
||||||
latin:keySpec="!icon/enter_key|!code/key_enter"
|
<key-style
|
||||||
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor"
|
latin:styleName="defaultEnterKeyStyle"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||||
latin:backgroundType="action"
|
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor"
|
||||||
latin:parentStyle="navigateMoreKeysStyle" />
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action"
|
||||||
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
|
</case>
|
||||||
|
<!-- keyboardTheme="LXXLight|LXXDark" -->
|
||||||
|
<default>
|
||||||
|
<key-style
|
||||||
|
latin:styleName="defaultEnterKeyStyle"
|
||||||
|
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||||
|
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor|keepBackgroundAspectRatio"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action"
|
||||||
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
|
</default>
|
||||||
|
</switch>
|
||||||
<include latin:keyboardLayout="@xml/key_styles_actions" />
|
<include latin:keyboardLayout="@xml/key_styles_actions" />
|
||||||
<switch>
|
<switch>
|
||||||
<!-- Shift + Enter in textMultiLine field. -->
|
<!-- Shift + Enter in textMultiLine field. -->
|
||||||
|
|
|
@ -80,11 +80,24 @@
|
||||||
latin:keyActionFlags="isRepeatable|noKeyPreview"
|
latin:keyActionFlags="isRepeatable|noKeyPreview"
|
||||||
latin:backgroundType="functional" />
|
latin:backgroundType="functional" />
|
||||||
<!-- emojiKeyStyle must be defined before including @xml/key_syles_enter. -->
|
<!-- emojiKeyStyle must be defined before including @xml/key_syles_enter. -->
|
||||||
<key-style
|
<switch>
|
||||||
latin:styleName="emojiKeyStyle"
|
<case latin:keyboardTheme="ICS|KLP">
|
||||||
latin:keySpec="!icon/emoji_action_key|!code/key_emoji"
|
<key-style
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:styleName="emojiKeyStyle"
|
||||||
latin:backgroundType="action" />
|
latin:keySpec="!icon/emoji_action_key|!code/key_emoji"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action" />
|
||||||
|
</case>
|
||||||
|
<!-- keyboardTheme="LXXLight|LXXDark" -->
|
||||||
|
<default>
|
||||||
|
<key-style
|
||||||
|
latin:styleName="emojiKeyStyle"
|
||||||
|
latin:keySpec="!icon/emoji_action_key|!code/key_emoji"
|
||||||
|
latin:keyLabelFlags="keepBackgroundAspectRatio"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action" />
|
||||||
|
</default>
|
||||||
|
</switch>
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_styles_enter" />
|
latin:keyboardLayout="@xml/key_styles_enter" />
|
||||||
<!-- TODO: Currently there is no way to specify icon alignment per theme. -->
|
<!-- TODO: Currently there is no way to specify icon alignment per theme. -->
|
||||||
|
|
|
@ -212,13 +212,27 @@
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<!-- Enter key style -->
|
<!-- Enter key style -->
|
||||||
<key-style
|
<switch>
|
||||||
latin:styleName="defaultEnterKeyStyle"
|
<case latin:keyboardTheme="ICS|KLP">
|
||||||
latin:keySpec="!icon/enter_key|!code/key_enter"
|
<key-style
|
||||||
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor"
|
latin:styleName="defaultEnterKeyStyle"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||||
latin:backgroundType="action"
|
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor"
|
||||||
latin:parentStyle="navigateMoreKeysStyle" />
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action"
|
||||||
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
|
</case>
|
||||||
|
<!-- keyboardTheme="LXXLight|LXXDark" -->
|
||||||
|
<default>
|
||||||
|
<key-style
|
||||||
|
latin:styleName="defaultEnterKeyStyle"
|
||||||
|
latin:keySpec="!icon/enter_key|!code/key_enter"
|
||||||
|
latin:keyLabelFlags="preserveCase|autoXScale|followKeyLabelRatio|followFunctionalTextColor|keepBackgroundAspectRatio"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="action"
|
||||||
|
latin:parentStyle="navigateMoreKeysStyle" />
|
||||||
|
</default>
|
||||||
|
</switch>
|
||||||
<include latin:keyboardLayout="@xml/key_styles_actions" />
|
<include latin:keyboardLayout="@xml/key_styles_actions" />
|
||||||
<switch>
|
<switch>
|
||||||
<!-- Shift + Enter in textMultiLine field. -->
|
<!-- Shift + Enter in textMultiLine field. -->
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class Key implements Comparable<Key> {
|
||||||
private static final int LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED = 0x20000;
|
private static final int LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED = 0x20000;
|
||||||
private static final int LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL = 0x40000;
|
private static final int LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL = 0x40000;
|
||||||
private static final int LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR = 0x80000;
|
private static final int LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR = 0x80000;
|
||||||
|
private static final int LABEL_FLAGS_KEEP_BACKGROUND_ASPECT_RATIO = 0x100000;
|
||||||
private static final int LABEL_FLAGS_DISABLE_HINT_LABEL = 0x40000000;
|
private static final int LABEL_FLAGS_DISABLE_HINT_LABEL = 0x40000000;
|
||||||
private static final int LABEL_FLAGS_DISABLE_ADDITIONAL_MORE_KEYS = 0x80000000;
|
private static final int LABEL_FLAGS_DISABLE_ADDITIONAL_MORE_KEYS = 0x80000000;
|
||||||
|
|
||||||
|
@ -697,6 +698,10 @@ public class Key implements Comparable<Key> {
|
||||||
return (mLabelFlags & LABEL_FLAGS_AUTO_SCALE) == LABEL_FLAGS_AUTO_SCALE;
|
return (mLabelFlags & LABEL_FLAGS_AUTO_SCALE) == LABEL_FLAGS_AUTO_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean needsToKeepBackgroundAspectRatio(final int defaultFlags) {
|
||||||
|
return ((mLabelFlags | defaultFlags) & LABEL_FLAGS_KEEP_BACKGROUND_ASPECT_RATIO) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
private final boolean isShiftedLetterActivated() {
|
private final boolean isShiftedLetterActivated() {
|
||||||
return (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) != 0
|
return (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) != 0
|
||||||
&& !TextUtils.isEmpty(mHintLabel);
|
&& !TextUtils.isEmpty(mHintLabel);
|
||||||
|
|
|
@ -340,11 +340,25 @@ public class KeyboardView extends View {
|
||||||
// Draw key background.
|
// Draw key background.
|
||||||
protected void onDrawKeyBackground(final Key key, final Canvas canvas,
|
protected void onDrawKeyBackground(final Key key, final Canvas canvas,
|
||||||
final Drawable background) {
|
final Drawable background) {
|
||||||
final Rect padding = mKeyBackgroundPadding;
|
final int keyWidth = key.getDrawWidth();
|
||||||
final int bgWidth = key.getDrawWidth() + padding.left + padding.right;
|
final int keyHeight = key.getHeight();
|
||||||
final int bgHeight = key.getHeight() + padding.top + padding.bottom;
|
final int bgWidth, bgHeight, bgX, bgY;
|
||||||
final int bgX = -padding.left;
|
if (key.needsToKeepBackgroundAspectRatio(mDefaultKeyLabelFlags)) {
|
||||||
final int bgY = -padding.top;
|
final int intrinsicWidth = background.getIntrinsicWidth();
|
||||||
|
final int intrinsicHeight = background.getIntrinsicHeight();
|
||||||
|
final float minScale = Math.min(
|
||||||
|
keyWidth / (float)intrinsicWidth, keyHeight / (float)intrinsicHeight);
|
||||||
|
bgWidth = (int)(intrinsicWidth * minScale);
|
||||||
|
bgHeight = (int)(intrinsicHeight * minScale);
|
||||||
|
bgX = (keyWidth - bgWidth) / 2;
|
||||||
|
bgY = (keyHeight - bgHeight) / 2;
|
||||||
|
} else {
|
||||||
|
final Rect padding = mKeyBackgroundPadding;
|
||||||
|
bgWidth = keyWidth + padding.left + padding.right;
|
||||||
|
bgHeight = keyHeight + padding.top + padding.bottom;
|
||||||
|
bgX = -padding.left;
|
||||||
|
bgY = -padding.top;
|
||||||
|
}
|
||||||
final Rect bounds = background.getBounds();
|
final Rect bounds = background.getBounds();
|
||||||
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
|
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
|
||||||
background.setBounds(0, 0, bgWidth, bgHeight);
|
background.setBounds(0, 0, bgWidth, bgHeight);
|
||||||
|
|
|
@ -308,8 +308,8 @@ public final class MoreKeysKeyboard extends Keyboard {
|
||||||
dividerWidth = 0;
|
dividerWidth = 0;
|
||||||
}
|
}
|
||||||
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
||||||
mParams.setParameters(moreKeys.length, key.getMoreKeysColumnNumber(), keyWidth, rowHeight,
|
mParams.setParameters(moreKeys.length, key.getMoreKeysColumnNumber(), keyWidth,
|
||||||
key.getX() + key.getWidth() / 2, keyboard.mId.mWidth,
|
rowHeight, key.getX() + key.getWidth() / 2, keyboard.mId.mWidth,
|
||||||
key.isMoreKeysFixedColumn(), key.isMoreKeysFixedOrder(), dividerWidth);
|
key.isMoreKeysFixedColumn(), key.isMoreKeysFixedOrder(), dividerWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue