forked from extern/Unexpected-Keyboard
Fix keys drawing
This commit is contained in:
parent
3909976b85
commit
6737bda402
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="horizontal_margin">10dp</dimen>
|
<dimen name="horizontal_margin">12dp</dimen>
|
||||||
<dimen name="key_padding">7dp</dimen>
|
<dimen name="key_padding">3dp</dimen>
|
||||||
<dimen name="key_height">37dp</dimen>
|
<dimen name="key_height">37dp</dimen>
|
||||||
<dimen name="label_text_size">18dp</dimen>
|
<dimen name="label_text_size">18dp</dimen>
|
||||||
<dimen name="sublabel_text_size">11dp</dimen>
|
<dimen name="sublabel_text_size">11dp</dimen>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<dimen name="vertical_margin">3dp</dimen>
|
<dimen name="vertical_margin">3dp</dimen>
|
||||||
<dimen name="horizontal_margin">2dp</dimen>
|
<dimen name="horizontal_margin">2dp</dimen>
|
||||||
<dimen name="key_padding">5dp</dimen>
|
<dimen name="key_padding">1dp</dimen>
|
||||||
<dimen name="key_bg_padding">1dp</dimen>
|
<dimen name="key_bg_padding">1dp</dimen>
|
||||||
<dimen name="key_height">44dp</dimen>
|
<dimen name="key_height">44dp</dimen>
|
||||||
<dimen name="key_round">4dp</dimen>
|
<dimen name="key_round">4dp</dimen>
|
||||||
|
@ -132,7 +132,7 @@ class KeyValue
|
|||||||
new KeyValue("end", "↗", CHAR_NONE, KeyEvent.KEYCODE_MOVE_END, 0);
|
new KeyValue("end", "↗", CHAR_NONE, KeyEvent.KEYCODE_MOVE_END, 0);
|
||||||
new KeyValue("backspace", "⌫", CHAR_NONE, KeyEvent.KEYCODE_DEL, 0);
|
new KeyValue("backspace", "⌫", CHAR_NONE, KeyEvent.KEYCODE_DEL, 0);
|
||||||
new KeyValue("delete", "⌦", CHAR_NONE, KeyEvent.KEYCODE_FORWARD_DEL, 0);
|
new KeyValue("delete", "⌦", CHAR_NONE, KeyEvent.KEYCODE_FORWARD_DEL, 0);
|
||||||
new KeyValue("insert", "Insert", CHAR_NONE, KeyEvent.KEYCODE_INSERT, 0);
|
new KeyValue("insert", "Ins", CHAR_NONE, KeyEvent.KEYCODE_INSERT, 0);
|
||||||
|
|
||||||
new KeyValue("tab", "↹", '\t', EVENT_NONE, 0);
|
new KeyValue("tab", "↹", '\t', EVENT_NONE, 0);
|
||||||
new KeyValue("space", " ", ' ', EVENT_NONE, 0);
|
new KeyValue("space", " ", ' ', EVENT_NONE, 0);
|
||||||
|
@ -223,7 +223,7 @@ public class Keyboard2View extends View
|
|||||||
y = _verticalMargin;
|
y = _verticalMargin;
|
||||||
for (KeyboardData.Row row : _keyboard.getRows())
|
for (KeyboardData.Row row : _keyboard.getRows())
|
||||||
{
|
{
|
||||||
x = (KEY_PER_ROW * _keyWidth - row.getWidth(_keyWidth)) / 2 + _horizontalMargin;
|
x = (KEY_PER_ROW * _keyWidth - row.getWidth(_keyWidth)) / 2f + _horizontalMargin;
|
||||||
for (KeyboardData.Key k : row)
|
for (KeyboardData.Key k : row)
|
||||||
{
|
{
|
||||||
float keyW = _keyWidth * k.width;
|
float keyW = _keyWidth * k.width;
|
||||||
@ -235,25 +235,37 @@ public class Keyboard2View extends View
|
|||||||
canvas.drawRoundRect(new RectF(x + _keyBgPadding, y + _keyBgPadding,
|
canvas.drawRoundRect(new RectF(x + _keyBgPadding, y + _keyBgPadding,
|
||||||
x + keyW - _keyBgPadding, y + _keyHeight - _keyBgPadding), _keyRound, _keyRound, _keyBgPaint);
|
x + keyW - _keyBgPadding, y + _keyHeight - _keyBgPadding), _keyRound, _keyRound, _keyBgPaint);
|
||||||
if (k.key0 != null)
|
if (k.key0 != null)
|
||||||
canvas.drawText(k.key0.getSymbol(upperCase), keyW / 2 + x,
|
canvas.drawText(k.key0.getSymbol(upperCase), keyW / 2f + x,
|
||||||
(_keyHeight + _keyLabelPaint.getTextSize()) / 2 + y,
|
(_keyHeight + _keyLabelPaint.getTextSize()) / 2f + y,
|
||||||
(keyDown != null && (keyDown.flags & KeyValue.FLAG_LOCKED) != 0)
|
(keyDown != null && (keyDown.flags & KeyValue.FLAG_LOCKED) != 0)
|
||||||
? _keyLabelLockedPaint : _keyLabelPaint);
|
? _keyLabelLockedPaint : _keyLabelPaint);
|
||||||
float textOffsetY = _keySubLabelPaint.getTextSize() / 2;
|
float textOffsetY = -_keySubLabelPaint.ascent();
|
||||||
float subPadding = _keyPadding + _keyBgPadding;
|
float subPadding = _keyBgPadding + _keyPadding;
|
||||||
if (k.key1 != null)
|
if (k.key1 != null)
|
||||||
|
{
|
||||||
|
_keySubLabelPaint.setTextAlign(Paint.Align.LEFT);
|
||||||
canvas.drawText(k.key1.getSymbol(upperCase), x + subPadding,
|
canvas.drawText(k.key1.getSymbol(upperCase), x + subPadding,
|
||||||
y + subPadding + textOffsetY, _keySubLabelPaint);
|
y + subPadding + textOffsetY, _keySubLabelPaint);
|
||||||
|
}
|
||||||
if (k.key2 != null)
|
if (k.key2 != null)
|
||||||
|
{
|
||||||
|
_keySubLabelPaint.setTextAlign(Paint.Align.RIGHT);
|
||||||
canvas.drawText(k.key2.getSymbol(upperCase), x + keyW - subPadding,
|
canvas.drawText(k.key2.getSymbol(upperCase), x + keyW - subPadding,
|
||||||
y + subPadding + textOffsetY, _keySubLabelPaint);
|
y + subPadding + textOffsetY, _keySubLabelPaint);
|
||||||
textOffsetY /= 2; // lol
|
}
|
||||||
|
textOffsetY = _keySubLabelPaint.descent();
|
||||||
if (k.key3 != null)
|
if (k.key3 != null)
|
||||||
|
{
|
||||||
|
_keySubLabelPaint.setTextAlign(Paint.Align.LEFT);
|
||||||
canvas.drawText(k.key3.getSymbol(upperCase), x + subPadding,
|
canvas.drawText(k.key3.getSymbol(upperCase), x + subPadding,
|
||||||
y + _keyHeight - subPadding + textOffsetY, _keySubLabelPaint);
|
y + _keyHeight - subPadding - textOffsetY, _keySubLabelPaint);
|
||||||
|
}
|
||||||
if (k.key4 != null)
|
if (k.key4 != null)
|
||||||
|
{
|
||||||
|
_keySubLabelPaint.setTextAlign(Paint.Align.RIGHT);
|
||||||
canvas.drawText(k.key4.getSymbol(upperCase), x + keyW - subPadding,
|
canvas.drawText(k.key4.getSymbol(upperCase), x + keyW - subPadding,
|
||||||
y + _keyHeight - subPadding + textOffsetY, _keySubLabelPaint);
|
y + _keyHeight - subPadding - textOffsetY, _keySubLabelPaint);
|
||||||
|
}
|
||||||
x += keyW;
|
x += keyW;
|
||||||
}
|
}
|
||||||
y += _keyHeight;
|
y += _keyHeight;
|
||||||
|
Loading…
Reference in New Issue
Block a user