forked from extern/Unexpected-Keyboard
Add sub more subkeys + Better drawing
This commit is contained in:
parent
45ea215bb6
commit
56612121f8
@ -3,5 +3,6 @@
|
||||
<item name="bg" type="color">#111111</item>
|
||||
<item name="key_bg" type="color">#303030</item>
|
||||
<item name="key_down_bg" type="color">#FFFFFF</item>
|
||||
<item name="key_label" type="color">#BFBFBF</item>
|
||||
<item name="key_label" type="color">#DFDFDF</item>
|
||||
<item name="key_sub_label" type="color">#BFBFBF</item>
|
||||
</resources>
|
||||
|
@ -1,19 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard>
|
||||
<row>
|
||||
<key key0="a" key2="1" />
|
||||
<key key0="z" key2="2" />
|
||||
<key key0="e" key2="3" />
|
||||
<key key0="r" key2="4" />
|
||||
<key key0="t" key2="5" />
|
||||
<key key0="y" key2="6" />
|
||||
<key key0="u" key2="7" />
|
||||
<key key0="i" key2="8" />
|
||||
<key key0="o" key2="9" />
|
||||
<key key0="p" key2="0" />
|
||||
<key key0="a" key2="1" key3="&" />
|
||||
<key key0="z" key2="2" key3="é" key4="~" />
|
||||
<key key0="e" key2="3" key3=""" key4="\#" />
|
||||
<key key0="r" key2="4" key3="'" key4="{" />
|
||||
<key key0="t" key2="5" key3="(" key4="[" />
|
||||
<key key0="y" key2="6" key3="-" key4="|" />
|
||||
<key key0="u" key2="7" key3="è" key4="`" />
|
||||
<key key0="i" key2="8" key3="_" key4="\" />
|
||||
<key key0="o" key2="9" key3="ç" key4="^" />
|
||||
<key key0="p" key2="0" key3="à" key4="\@" />
|
||||
</row>
|
||||
<row>
|
||||
<key key0="q" />
|
||||
<key key0="q" key1="1" key2="2" key3="3" key4="4" />
|
||||
<key key0="s" />
|
||||
<key key0="d" />
|
||||
<key key0="f" />
|
||||
@ -31,6 +31,7 @@
|
||||
<key key0="v" />
|
||||
<key key0="b" />
|
||||
<key key0="n" />
|
||||
<key width="1.5" key0="del" />
|
||||
</row>
|
||||
<row>
|
||||
<key width="4.0" key0="space" />
|
||||
|
@ -41,8 +41,28 @@ enum KeyValue
|
||||
KEY_7("7", '7'),
|
||||
KEY_8("8", '8'),
|
||||
KEY_9("9", '9'),
|
||||
KEY_AND("&", '&'),
|
||||
KEY_E2("é", 'é'),
|
||||
KEY_DQUOTE("\"", '"'),
|
||||
KEY_QUOTE("'", '\''),
|
||||
KEY_PARENTHESIS("(", '('),
|
||||
KEY_MINUS("-", '-'),
|
||||
KEY_E3("è", 'è'),
|
||||
KEY_UNDERSCORE("_", '_'),
|
||||
KEY_C2("ç", 'ç'),
|
||||
KEY_A2("à", 'à'),
|
||||
KEY_TILDE("~", '~'),
|
||||
KEY_DIESE("#", '#'),
|
||||
KEY_BLOCK("{", '{'),
|
||||
KEY_SQUARE("[", '['),
|
||||
KEY_PIPE("|", '|'),
|
||||
KEY_BACKQUOTE("`", '`'),
|
||||
KEY_BACKSLASH("\\", '\\'),
|
||||
KEY_XOR("^", '^'),
|
||||
KEY_AROBASE("@", '@'),
|
||||
KEY_ENTER("enter", '\n'),
|
||||
KEY_SPACE("space", ' ');
|
||||
KEY_SPACE("space", ' '),
|
||||
KEY_DEL("del", '\u007F');
|
||||
|
||||
private String _name;
|
||||
private char _char;
|
||||
|
@ -14,10 +14,10 @@ public class Keyboard2View extends View
|
||||
{
|
||||
private static final float KEY_PER_ROW = 10;
|
||||
private static final float KEY_MARGIN_DPI = 2;
|
||||
private static final float KEY_PADDING_DPI = 6;
|
||||
private static final float KEY_PADDING_DPI = 5;
|
||||
private static final float KEY_HEIGHT_DPI = 40;
|
||||
private static final float KEY_LABEL_DPI = 16;
|
||||
private static final float KEY_SUBLABEL_DPI = 12;
|
||||
private static final float KEY_SUBLABEL_DPI = 10;
|
||||
|
||||
private Keyboard2 _ime;
|
||||
private KeyboardData _keyboard;
|
||||
@ -44,12 +44,12 @@ public class Keyboard2View extends View
|
||||
_keyBgPaint.setColor(getResources().getColor(R.color.key_bg));
|
||||
_keyDownBgPaint = new Paint();
|
||||
_keyDownBgPaint.setColor(getResources().getColor(R.color.key_down_bg));
|
||||
_keyLabelPaint = new Paint();
|
||||
_keyLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
_keyLabelPaint.setColor(getResources().getColor(R.color.key_label));
|
||||
_keyLabelPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, KEY_LABEL_DPI, dm));
|
||||
_keyLabelPaint.setTextAlign(Paint.Align.CENTER);
|
||||
_keySubLabelPaint = new Paint();
|
||||
_keySubLabelPaint.setColor(getResources().getColor(R.color.key_label));
|
||||
_keySubLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
_keySubLabelPaint.setColor(getResources().getColor(R.color.key_sub_label));
|
||||
_keySubLabelPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, KEY_SUBLABEL_DPI, dm));
|
||||
_keySubLabelPaint.setTextAlign(Paint.Align.CENTER);
|
||||
setOnTouchListener(this);
|
||||
@ -190,18 +190,20 @@ public class Keyboard2View extends View
|
||||
if (k.key0 != null)
|
||||
canvas.drawText(new char[]{k.key0.getChar()}, 0, 1,
|
||||
keyW / 2 + x, (_keyHeight + _keyLabelPaint.getTextSize()) / 2 + y, _keyLabelPaint);
|
||||
float textOffsetY = _keySubLabelPaint.getTextSize() / 2;
|
||||
if (k.key1 != null)
|
||||
canvas.drawText(new char[]{k.key1.getChar()}, 0, 1,
|
||||
x + _keyPadding, y + _keyPadding, _keySubLabelPaint);
|
||||
x + _keyPadding, y + _keyPadding + textOffsetY, _keySubLabelPaint);
|
||||
if (k.key2 != null)
|
||||
canvas.drawText(new char[]{k.key2.getChar()}, 0, 1,
|
||||
x + keyW - _keyPadding, y + _keyPadding, _keySubLabelPaint);
|
||||
x + keyW - _keyPadding, y + _keyPadding + textOffsetY, _keySubLabelPaint);
|
||||
textOffsetY /= 2; // WTF it work
|
||||
if (k.key3 != null)
|
||||
canvas.drawText(new char[]{k.key3.getChar()}, 0, 1,
|
||||
x + _keyPadding, y + _keyHeight - _keyPadding, _keySubLabelPaint);
|
||||
x + _keyPadding, y + _keyHeight - _keyPadding + textOffsetY, _keySubLabelPaint);
|
||||
if (k.key4 != null)
|
||||
canvas.drawText(new char[]{k.key4.getChar()}, 0, 1,
|
||||
x + keyW - _keyPadding, y + _keyHeight - _keyPadding, _keySubLabelPaint);
|
||||
x + keyW - _keyPadding, y + _keyHeight - _keyPadding + textOffsetY, _keySubLabelPaint);
|
||||
x += keyW + _keyMargin;
|
||||
}
|
||||
y += _keyHeight + _keyMargin;
|
||||
|
Loading…
Reference in New Issue
Block a user