mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-06-25 04:02:02 +02:00
Move the border radius from Config to Theme
Also, draw activated keys with a round border too.
This commit is contained in:
parent
093a00c572
commit
29367f127d
@ -7,7 +7,6 @@
|
|||||||
<dimen name="key_vertical_interval">2dp</dimen>
|
<dimen name="key_vertical_interval">2dp</dimen>
|
||||||
<dimen name="key_horizontal_interval">2dp</dimen>
|
<dimen name="key_horizontal_interval">2dp</dimen>
|
||||||
<dimen name="key_height">51dp</dimen>
|
<dimen name="key_height">51dp</dimen>
|
||||||
<dimen name="key_round">5dp</dimen>
|
|
||||||
<dimen name="label_text_size">18dp</dimen>
|
<dimen name="label_text_size">18dp</dimen>
|
||||||
<dimen name="sublabel_text_size">12dp</dimen>
|
<dimen name="sublabel_text_size">12dp</dimen>
|
||||||
<dimen name="emoji_type_button_height">56dp</dimen>
|
<dimen name="emoji_type_button_height">56dp</dimen>
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
<attr name="colorLabelLocked" format="color"/>
|
<attr name="colorLabelLocked" format="color"/>
|
||||||
<!-- Corner labels -->
|
<!-- Corner labels -->
|
||||||
<attr name="colorSubLabel" format="color"/>
|
<attr name="colorSubLabel" format="color"/>
|
||||||
|
<!-- Dimens -->
|
||||||
|
<attr name="keyBorderRadius" format="dimension"/>
|
||||||
<!-- Emoji panel -->
|
<!-- Emoji panel -->
|
||||||
<attr name="emoji_button_bg" type="color" format="color"/>
|
<attr name="emoji_button_bg" type="color" format="color"/>
|
||||||
<attr name="emoji_color" type="color" format="color"/>
|
<attr name="emoji_color" type="color" format="color"/>
|
||||||
@ -27,6 +29,7 @@
|
|||||||
<item name="colorLabelActivated">#226b99</item>
|
<item name="colorLabelActivated">#226b99</item>
|
||||||
<item name="colorLabelLocked">#229933</item>
|
<item name="colorLabelLocked">#229933</item>
|
||||||
<item name="colorSubLabel">#A0A0A0</item>
|
<item name="colorSubLabel">#A0A0A0</item>
|
||||||
|
<item name="keyBorderRadius">5dp</item>
|
||||||
<item name="emoji_button_bg" type="color">#202020</item>
|
<item name="emoji_button_bg" type="color">#202020</item>
|
||||||
<item name="emoji_color" type="color">#FFFFFF</item>
|
<item name="emoji_color" type="color">#FFFFFF</item>
|
||||||
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
|
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
|
||||||
@ -40,6 +43,7 @@
|
|||||||
<item name="colorLabelActivated">#64afdd</item>
|
<item name="colorLabelActivated">#64afdd</item>
|
||||||
<item name="colorLabelLocked">#64dd76</item>
|
<item name="colorLabelLocked">#64dd76</item>
|
||||||
<item name="colorSubLabel">#5e5e5e</item>
|
<item name="colorSubLabel">#5e5e5e</item>
|
||||||
|
<item name="keyBorderRadius">5dp</item>
|
||||||
<item name="emoji_button_bg" type="color">#dedede</item>
|
<item name="emoji_button_bg" type="color">#dedede</item>
|
||||||
<item name="emoji_color" type="color">#000000</item>
|
<item name="emoji_color" type="color">#000000</item>
|
||||||
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
|
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
|
||||||
|
@ -14,7 +14,6 @@ final class Config
|
|||||||
public final float keyPadding;
|
public final float keyPadding;
|
||||||
public final float keyVerticalInterval;
|
public final float keyVerticalInterval;
|
||||||
public final float keyHorizontalInterval;
|
public final float keyHorizontalInterval;
|
||||||
public final float keyRound;
|
|
||||||
|
|
||||||
// From preferences
|
// From preferences
|
||||||
public int layout; // Or '-1' for the system defaults
|
public int layout; // Or '-1' for the system defaults
|
||||||
@ -45,7 +44,6 @@ final class Config
|
|||||||
keyPadding = res.getDimension(R.dimen.key_padding);
|
keyPadding = res.getDimension(R.dimen.key_padding);
|
||||||
keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
|
keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
|
||||||
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
|
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
|
||||||
keyRound = res.getDimension(R.dimen.key_round);
|
|
||||||
// default values
|
// default values
|
||||||
layout = -1;
|
layout = -1;
|
||||||
subValueDist = 10f;
|
subValueDist = 10f;
|
||||||
|
@ -352,10 +352,8 @@ public class Keyboard2View extends View
|
|||||||
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
||||||
KeyDown keyDown = getKeyDown(k);
|
KeyDown keyDown = getKeyDown(k);
|
||||||
_tmpRect.set(x, y, x + keyW, y + keyH);
|
_tmpRect.set(x, y, x + keyW, y + keyH);
|
||||||
if (keyDown != null)
|
canvas.drawRoundRect(_tmpRect, _theme.keyBorderRadius, _theme.keyBorderRadius,
|
||||||
canvas.drawRect(_tmpRect, _theme.keyDownBgPaint);
|
(keyDown != null) ? _theme.keyDownBgPaint : _theme.keyBgPaint);
|
||||||
else
|
|
||||||
canvas.drawRoundRect(_tmpRect, _config.keyRound, _config.keyRound, _theme.keyBgPaint);
|
|
||||||
if (k.key0 != null)
|
if (k.key0 != null)
|
||||||
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _theme.labelTextSize) / 2f + y, keyDown);
|
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _theme.labelTextSize) / 2f + y, keyDown);
|
||||||
float subPadding = _config.keyPadding;
|
float subPadding = _config.keyPadding;
|
||||||
|
@ -15,9 +15,12 @@ public class Theme
|
|||||||
public final int activatedColor;
|
public final int activatedColor;
|
||||||
public final int labelColor;
|
public final int labelColor;
|
||||||
public final int subLabelColor;
|
public final int subLabelColor;
|
||||||
|
|
||||||
public final float labelTextSize;
|
public final float labelTextSize;
|
||||||
public final float sublabelTextSize;
|
public final float sublabelTextSize;
|
||||||
|
|
||||||
|
public final float keyBorderRadius;
|
||||||
|
|
||||||
private final Paint _keyLabelPaint;
|
private final Paint _keyLabelPaint;
|
||||||
private final Paint _specialKeyLabelPaint;
|
private final Paint _specialKeyLabelPaint;
|
||||||
private final Paint _keySubLabelPaint;
|
private final Paint _keySubLabelPaint;
|
||||||
@ -33,6 +36,7 @@ public class Theme
|
|||||||
activatedColor = s.getColor(R.styleable.keyboard_colorLabelActivated, 0);
|
activatedColor = s.getColor(R.styleable.keyboard_colorLabelActivated, 0);
|
||||||
lockedColor = s.getColor(R.styleable.keyboard_colorLabelLocked, 0);
|
lockedColor = s.getColor(R.styleable.keyboard_colorLabelLocked, 0);
|
||||||
subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0);
|
subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0);
|
||||||
|
keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0);
|
||||||
s.recycle();
|
s.recycle();
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
labelTextSize = res.getDimension(R.dimen.label_text_size);
|
labelTextSize = res.getDimension(R.dimen.label_text_size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user