mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-22 07:13:13 +01:00
Use the themes abstraction
Themes replace 'colors.xml' and soon will replace 'dimens.xml'.
This commit is contained in:
parent
93704cca0a
commit
40b1ec63a9
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:hardwareAccelerated="false">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:hardwareAccelerated="false" android:theme="@style/Dark">
|
||||
<juloo.keyboard2.EmojiGroupButtonsBar android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
|
||||
<juloo.keyboard2.EmojiGridView android:id="@+id/emoji_grid" android:background="@color/bg" android:layout_width="fill_parent" android:layout_height="@dimen/emoji_grid_height"/>
|
||||
<juloo.keyboard2.EmojiGridView android:id="@+id/emoji_grid" android:background="?attr/colorKeyboard" android:layout_width="fill_parent" android:layout_height="@dimen/emoji_grid_height"/>
|
||||
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" key="switch_back_emoji"/>
|
||||
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" android:layout_weight="4" key="space"/>
|
||||
|
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/bg" android:hardwareAccelerated="false"/>
|
||||
<juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android" android:hardwareAccelerated="false" android:theme="@style/Dark" android:background="?attr/colorKeyboard"/>
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="bg" type="color">#1B1B1B</item>
|
||||
<item name="key_bg" type="color">#303030</item>
|
||||
<item name="key_down_bg" type="color">#1B1B1B</item>
|
||||
<item name="key_label" type="color">#FFFFFF</item>
|
||||
<item name="key_label_locked" type="color">#229933</item>
|
||||
<item name="key_label_activated" type="color">#226b99</item>
|
||||
<item name="key_sub_label" type="color">#A0A0A0</item>
|
||||
<item name="emoji_button_bg" type="color">#202020</item>
|
||||
<item name="emoji_color" type="color">#FFFFFF</item>
|
||||
<item name="emoji_key_bg" type="color">@color/emoji_button_bg</item>
|
||||
<item name="emoji_key_text" type="color">@color/key_label</item>
|
||||
</resources>
|
@ -12,4 +12,5 @@
|
||||
<dimen name="sublabel_text_size">12dp</dimen>
|
||||
<dimen name="emoji_type_button_height">56dp</dimen>
|
||||
<dimen name="emoji_grid_height">250dp</dimen>
|
||||
<dimen name="emoji_text_size">28dp</dimen>
|
||||
</resources>
|
||||
|
@ -4,8 +4,8 @@
|
||||
<item name="android:padding">1px</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:minHeight">@dimen/label_text_size</item>
|
||||
<item name="android:background">@color/emoji_button_bg</item>
|
||||
<item name="android:textColor">@color/emoji_key_text</item>
|
||||
<item name="android:background">?attr/emoji_button_bg</item>
|
||||
<item name="android:textColor">?attr/emoji_key_text</item>
|
||||
<item name="android:textSize">@dimen/label_text_size</item>
|
||||
</style>
|
||||
<style name="emojiKeyButton">
|
||||
@ -13,8 +13,13 @@
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:padding">0px</item>
|
||||
<item name="android:background">@color/emoji_key_bg</item>
|
||||
<item name="android:textColor">@color/emoji_key_text</item>
|
||||
<item name="android:background">?attr/emoji_key_bg</item>
|
||||
<item name="android:textColor">?attr/emoji_key_text</item>
|
||||
<item name="android:textSize">@dimen/label_text_size</item>
|
||||
</style>
|
||||
<!-- Passed to TextView.setTextAppearance -->
|
||||
<style name="emojiGridButton">
|
||||
<item name="android:textSize">@dimen/emoji_text_size</item>
|
||||
<item name="android:textColor">?attr/emoji_color</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
35
res/values/themes.xml
Normal file
35
res/values/themes.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="keyboard">
|
||||
<!-- The background of the keyboard -->
|
||||
<attr name="colorKeyboard" format="color"/>
|
||||
<!-- Background of the keys -->
|
||||
<attr name="colorKey" format="color"/>
|
||||
<!-- Background of the keys when pressed -->
|
||||
<attr name="colorKeyActivated" format="color"/>
|
||||
<!-- Label colors -->
|
||||
<attr name="colorLabel" format="color"/>
|
||||
<attr name="colorLabelActivated" format="color"/>
|
||||
<attr name="colorLabelLocked" format="color"/>
|
||||
<!-- Corner labels -->
|
||||
<attr name="colorSubLabel" format="color"/>
|
||||
<!-- Emoji panel -->
|
||||
<attr name="emoji_button_bg" type="color" format="color"/>
|
||||
<attr name="emoji_color" type="color" format="color"/>
|
||||
<attr name="emoji_key_bg" type="color" format="color"/>
|
||||
<attr name="emoji_key_text" type="color" format="color"/>
|
||||
</declare-styleable>
|
||||
<style name="Dark">
|
||||
<item name="colorKeyboard">#1B1B1B</item>
|
||||
<item name="colorKey">#303030</item>
|
||||
<item name="colorKeyActivated">#1B1B1B</item>
|
||||
<item name="colorLabel">#FFFFFF</item>
|
||||
<item name="colorLabelActivated">#226b99</item>
|
||||
<item name="colorLabelLocked">#229933</item>
|
||||
<item name="colorSubLabel">#A0A0A0</item>
|
||||
<item name="emoji_button_bg" type="color">#202020</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_text" type="color">?attr/colorLabel</item>
|
||||
</style>
|
||||
</resources>
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user