diff options
| author | Jules Aguillon | 2021-12-30 00:52:50 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2021-12-30 00:52:50 +0100 |
| commit | 29367f127d8927b063c1f869646d489df83079be (patch) | |
| tree | 9baf3cbee781d4272a6e76c77cf9b6a7dfc47dca | |
| parent | 093a00c572a29d292bc6bbb09559611cb61e1331 (diff) | |
| download | unexpected-keyboard-29367f127d8927b063c1f869646d489df83079be.tar.gz unexpected-keyboard-29367f127d8927b063c1f869646d489df83079be.zip | |
Move the border radius from Config to Theme
Also, draw activated keys with a round border too.
| -rw-r--r-- | res/values/dimens.xml | 1 | ||||
| -rw-r--r-- | res/values/themes.xml | 4 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 6 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Theme.java | 4 |
5 files changed, 10 insertions, 7 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 0fe54d3..fce808b 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -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> diff --git a/res/values/themes.xml b/res/values/themes.xml index 11689d5..0d347cd 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -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> diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index fdac104..5f59241 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -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; diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 2edb745..10ec678 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -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; diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index 04f365f..0f46cd0 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -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); |
