diff options
| author | juloo | 2015-07-31 23:52:47 +0200 |
|---|---|---|
| committer | juloo | 2015-07-31 23:52:47 +0200 |
| commit | 90cd2e1c7bd068c4a3278aeb1e709973fd813286 (patch) | |
| tree | b99efba037312601c9f1c339c0bcd7c81697df99 /srcs | |
| parent | 56612121f8c600fe0e71f631fbea8af47345831a (diff) | |
| download | unexpected-keyboard-90cd2e1c7bd068c4a3278aeb1e709973fd813286.tar.gz unexpected-keyboard-90cd2e1c7bd068c4a3278aeb1e709973fd813286.zip | |
Use dimens.xml instead of constants
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 53bceae..999bf64 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -13,11 +13,6 @@ public class Keyboard2View extends View implements View.OnTouchListener { private static final float KEY_PER_ROW = 10; - private static final float KEY_MARGIN_DPI = 2; - 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 = 10; private Keyboard2 _ime; private KeyboardData _keyboard; @@ -36,9 +31,9 @@ public class Keyboard2View extends View { super(context, attrs); DisplayMetrics dm = context.getResources().getDisplayMetrics(); - _keyMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, KEY_MARGIN_DPI, dm); - _keyHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, KEY_HEIGHT_DPI, dm); - _keyPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, KEY_PADDING_DPI, dm); + _keyMargin = getResources().getDimension(R.dimen.key_margin); + _keyHeight = getResources().getDimension(R.dimen.key_height); + _keyPadding = getResources().getDimension(R.dimen.key_padding); _keyWidth = (dm.widthPixels - _keyMargin) / KEY_PER_ROW - _keyMargin; _keyBgPaint = new Paint(); _keyBgPaint.setColor(getResources().getColor(R.color.key_bg)); @@ -46,11 +41,11 @@ public class Keyboard2View extends View _keyDownBgPaint.setColor(getResources().getColor(R.color.key_down_bg)); _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.setTextSize(getResources().getDimension(R.dimen.label_text_size)); _keyLabelPaint.setTextAlign(Paint.Align.CENTER); _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.setTextSize(getResources().getDimension(R.dimen.sublabel_text_size)); _keySubLabelPaint.setTextAlign(Paint.Align.CENTER); setOnTouchListener(this); } @@ -197,7 +192,7 @@ public class Keyboard2View extends View if (k.key2 != null) canvas.drawText(new char[]{k.key2.getChar()}, 0, 1, x + keyW - _keyPadding, y + _keyPadding + textOffsetY, _keySubLabelPaint); - textOffsetY /= 2; // WTF it work + textOffsetY /= 2; // lol if (k.key3 != null) canvas.drawText(new char[]{k.key3.getChar()}, 0, 1, x + _keyPadding, y + _keyHeight - _keyPadding + textOffsetY, _keySubLabelPaint); |
