From 40b1ec63a932606fb432ee81801acf147e9ee70e Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 28 Dec 2021 19:12:50 +0100 Subject: Use the themes abstraction Themes replace 'colors.xml' and soon will replace 'dimens.xml'. --- srcs/juloo.keyboard2/EmojiGridView.java | 5 +---- srcs/juloo.keyboard2/Theme.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'srcs') diff --git a/srcs/juloo.keyboard2/EmojiGridView.java b/srcs/juloo.keyboard2/EmojiGridView.java index 9fc08be..eb2d6df 100644 --- a/srcs/juloo.keyboard2/EmojiGridView.java +++ b/srcs/juloo.keyboard2/EmojiGridView.java @@ -24,7 +24,6 @@ public class EmojiGridView extends GridView public static final int GROUP_LAST_USE = -1; public static final int COLUMN_WIDTH = 192; - public static final float EMOJI_SIZE = 32.f; private static final String LAST_USE_PREF = "emoji_last_use"; @@ -120,10 +119,8 @@ public class EmojiGridView extends GridView public EmojiView(Context context) { super(context); - setTextSize(EMOJI_SIZE); + setTextAppearance(context, R.style.emojiGridButton); setGravity(Gravity.CENTER); - setBackgroundColor(0x0); - setTextColor(getResources().getColor(R.color.emoji_color)); setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, GridView.LayoutParams.WRAP_CONTENT)); } diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index af2f3d7..e90074b 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -2,6 +2,7 @@ package juloo.keyboard2; import android.content.Context; import android.content.res.Resources; +import android.content.res.TypedArray; import android.graphics.Paint; import android.graphics.Typeface; import android.util.AttributeSet; @@ -24,15 +25,18 @@ public class Theme public Theme(Context context, AttributeSet attrs) { + TypedArray s = context.getTheme().obtainStyledAttributes(attrs, R.styleable.keyboard, 0, R.style.Dark); + keyBgPaint.setColor(s.getColor(R.styleable.keyboard_colorKey, 0)); + keyDownBgPaint.setColor(s.getColor(R.styleable.keyboard_colorKeyActivated, 0)); + // colorKeyboard = s.getColor(R.styleable.keyboard_colorKeyboard, 0); + labelColor = s.getColor(R.styleable.keyboard_colorLabel, 0); + activatedColor = s.getColor(R.styleable.keyboard_colorLabelActivated, 0); + lockedColor = s.getColor(R.styleable.keyboard_colorLabelLocked, 0); + subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0); + s.recycle(); Resources res = context.getResources(); - lockedColor = res.getColor(R.color.key_label_locked); - activatedColor = res.getColor(R.color.key_label_activated); - labelColor = res.getColor(R.color.key_label); - subLabelColor = res.getColor(R.color.key_sub_label); labelTextSize = res.getDimension(R.dimen.label_text_size); sublabelTextSize = res.getDimension(R.dimen.sublabel_text_size); - keyBgPaint.setColor(res.getColor(R.color.key_bg)); - keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg)); _keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null); _keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null); Typeface specialKeyFont = getSpecialKeyFont(context); -- cgit v1.2.3