Move the border radius from Config to Theme

Also, draw activated keys with a round border too.
This commit is contained in:
Jules Aguillon 2021-12-30 00:52:50 +01:00
parent 093a00c572
commit 29367f127d
5 changed files with 10 additions and 7 deletions

View File

@ -7,7 +7,6 @@
<dimen name="key_vertical_interval">2dp</dimen>
<dimen name="key_horizontal_interval">2dp</dimen>
<dimen name="key_height">51dp</dimen>
<dimen name="key_round">5dp</dimen>
<dimen name="label_text_size">18dp</dimen>
<dimen name="sublabel_text_size">12dp</dimen>
<dimen name="emoji_type_button_height">56dp</dimen>

View File

@ -13,6 +13,8 @@
<attr name="colorLabelLocked" format="color"/>
<!-- Corner labels -->
<attr name="colorSubLabel" format="color"/>
<!-- Dimens -->
<attr name="keyBorderRadius" format="dimension"/>
<!-- Emoji panel -->
<attr name="emoji_button_bg" type="color" format="color"/>
<attr name="emoji_color" type="color" format="color"/>
@ -27,6 +29,7 @@
<item name="colorLabelActivated">#226b99</item>
<item name="colorLabelLocked">#229933</item>
<item name="colorSubLabel">#A0A0A0</item>
<item name="keyBorderRadius">5dp</item>
<item name="emoji_button_bg" type="color">#202020</item>
<item name="emoji_color" type="color">#FFFFFF</item>
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
@ -40,6 +43,7 @@
<item name="colorLabelActivated">#64afdd</item>
<item name="colorLabelLocked">#64dd76</item>
<item name="colorSubLabel">#5e5e5e</item>
<item name="keyBorderRadius">5dp</item>
<item name="emoji_button_bg" type="color">#dedede</item>
<item name="emoji_color" type="color">#000000</item>
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>

View File

@ -14,7 +14,6 @@ final class Config
public final float keyPadding;
public final float keyVerticalInterval;
public final float keyHorizontalInterval;
public final float keyRound;
// From preferences
public int layout; // Or '-1' for the system defaults
@ -45,7 +44,6 @@ final class Config
keyPadding = res.getDimension(R.dimen.key_padding);
keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
keyRound = res.getDimension(R.dimen.key_round);
// default values
layout = -1;
subValueDist = 10f;

View File

@ -352,10 +352,8 @@ public class Keyboard2View extends View
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
KeyDown keyDown = getKeyDown(k);
_tmpRect.set(x, y, x + keyW, y + keyH);
if (keyDown != null)
canvas.drawRect(_tmpRect, _theme.keyDownBgPaint);
else
canvas.drawRoundRect(_tmpRect, _config.keyRound, _config.keyRound, _theme.keyBgPaint);
canvas.drawRoundRect(_tmpRect, _theme.keyBorderRadius, _theme.keyBorderRadius,
(keyDown != null) ? _theme.keyDownBgPaint : _theme.keyBgPaint);
if (k.key0 != null)
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _theme.labelTextSize) / 2f + y, keyDown);
float subPadding = _config.keyPadding;

View File

@ -15,9 +15,12 @@ public class Theme
public final int activatedColor;
public final int labelColor;
public final int subLabelColor;
public final float labelTextSize;
public final float sublabelTextSize;
public final float keyBorderRadius;
private final Paint _keyLabelPaint;
private final Paint _specialKeyLabelPaint;
private final Paint _keySubLabelPaint;
@ -33,6 +36,7 @@ public class Theme
activatedColor = s.getColor(R.styleable.keyboard_colorLabelActivated, 0);
lockedColor = s.getColor(R.styleable.keyboard_colorLabelLocked, 0);
subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0);
keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0);
s.recycle();
Resources res = context.getResources();
labelTextSize = res.getDimension(R.dimen.label_text_size);