forked from extern/Unexpected-Keyboard
Dim secondary keys
Reduce the constrast of "secondary" labels. Modifiers (except diacritics), event and keyevent keys are considered secondary.
This commit is contained in:
parent
d644d2bf0e
commit
4d99bd4f4b
@ -11,6 +11,7 @@
|
||||
<attr name="colorLabel" format="color"/>
|
||||
<attr name="colorLabelActivated" format="color"/>
|
||||
<attr name="colorLabelLocked" format="color"/>
|
||||
<attr name="secondaryLightOffset" format="float"/>
|
||||
<!-- Corner labels -->
|
||||
<attr name="colorSubLabel" format="color"/>
|
||||
<!-- Dimens -->
|
||||
@ -41,6 +42,7 @@
|
||||
<item name="colorLabelActivated">#3399ff</item>
|
||||
<item name="colorLabelLocked">#33cc33</item>
|
||||
<item name="colorSubLabel">#cccccc</item>
|
||||
<item name="secondaryLightOffset">-0.2</item>
|
||||
<item name="emoji_button_bg" type="color">#202020</item>
|
||||
<item name="emoji_color" type="color">#ffffff</item>
|
||||
</style>
|
||||
@ -53,6 +55,7 @@
|
||||
<item name="colorLabelActivated">#0066cc</item>
|
||||
<item name="colorLabelLocked">#33cc33</item>
|
||||
<item name="colorSubLabel">#333333</item>
|
||||
<item name="secondaryLightOffset">+0.3</item>
|
||||
<item name="emoji_button_bg">#dedede</item>
|
||||
<item name="emoji_color">#000000</item>
|
||||
</style>
|
||||
@ -65,6 +68,7 @@
|
||||
<item name="colorLabelActivated">#009dff</item>
|
||||
<item name="colorLabelLocked">#00ff26</item>
|
||||
<item name="colorSubLabel">#bbbbbb</item>
|
||||
<item name="secondaryLightOffset">-0.25</item>
|
||||
<item name="keyBorderRadius">1dp</item>
|
||||
<item name="emoji_button_bg">#000000</item>
|
||||
<item name="emoji_color">#ffffff</item>
|
||||
@ -78,6 +82,7 @@
|
||||
<item name="colorLabelActivated">#0066cc</item>
|
||||
<item name="colorLabelLocked">#33cc33</item>
|
||||
<item name="colorSubLabel">#333333</item>
|
||||
<item name="secondaryLightOffset">+0.35</item>
|
||||
<item name="emoji_button_bg">#ffffff</item>
|
||||
<item name="emoji_color">#000000</item>
|
||||
</style>
|
||||
|
@ -58,11 +58,12 @@ final class KeyValue
|
||||
public static final int FLAG_SPECIAL = (1 << 22);
|
||||
public static final int FLAG_PRECISE_REPEAT = (1 << 23);
|
||||
// Rendering flags.
|
||||
public static final int FLAG_KEY_FONT = (1 << 24);
|
||||
public static final int FLAG_SMALLER_FONT = (1 << 25);
|
||||
public static final int FLAG_KEY_FONT = (1 << 24); // special font file
|
||||
public static final int FLAG_SMALLER_FONT = (1 << 25); // 25% smaller symbols
|
||||
public static final int FLAG_SECONDARY = (1 << 26); // dimmer
|
||||
// Used by [Pointers].
|
||||
public static final int FLAG_LOCKED = (1 << 26);
|
||||
public static final int FLAG_FAKE_PTR = (1 << 27);
|
||||
public static final int FLAG_LOCKED = (1 << 28);
|
||||
public static final int FLAG_FAKE_PTR = (1 << 29);
|
||||
|
||||
// Kinds
|
||||
public static final int KIND_CHAR = (0 << 29);
|
||||
@ -225,7 +226,7 @@ final class KeyValue
|
||||
if (symbol.length() > 1)
|
||||
flags |= FLAG_SMALLER_FONT;
|
||||
addKey(name, symbol, KIND_MODIFIER, m.ordinal(),
|
||||
FLAG_LATCH | FLAG_SPECIAL | flags);
|
||||
FLAG_LATCH | FLAG_SPECIAL | FLAG_SECONDARY | flags);
|
||||
}
|
||||
|
||||
private static void addModifierKey(String name, int symbol, Modifier m, int flags)
|
||||
@ -235,12 +236,13 @@ final class KeyValue
|
||||
|
||||
private static void addDiacritic(String name, int symbol, Modifier m)
|
||||
{
|
||||
addModifierKey(name, symbol, m, 0);
|
||||
addKey(name, String.valueOf((char)symbol), KIND_MODIFIER, m.ordinal(),
|
||||
FLAG_LATCH | FLAG_SPECIAL | FLAG_KEY_FONT);
|
||||
}
|
||||
|
||||
private static void addEventKey(String name, String symbol, Event e, int flags)
|
||||
{
|
||||
addKey(name, symbol, KIND_EVENT, e.ordinal(), flags | FLAG_SPECIAL);
|
||||
addKey(name, symbol, KIND_EVENT, e.ordinal(), flags | FLAG_SPECIAL | FLAG_SECONDARY);
|
||||
}
|
||||
|
||||
private static void addEventKey(String name, int symbol, Event e, int flags)
|
||||
@ -250,7 +252,7 @@ final class KeyValue
|
||||
|
||||
private static void addKeyeventKey(String name, String symbol, int code, int flags)
|
||||
{
|
||||
addKey(name, symbol, KIND_KEYEVENT, code, flags);
|
||||
addKey(name, symbol, KIND_KEYEVENT, code, flags | FLAG_SECONDARY);
|
||||
}
|
||||
|
||||
private static void addKeyeventKey(String name, int symbol, int code, int flags)
|
||||
@ -336,7 +338,7 @@ final class KeyValue
|
||||
addKeyeventKey("tab", 0x0F, KeyEvent.KEYCODE_TAB, FLAG_SMALLER_FONT);
|
||||
|
||||
addCharKey("\\t", "\\t", '\t', 0); // Send the tab character
|
||||
addCharKey("space", "\r", ' ', FLAG_KEY_FONT);
|
||||
addCharKey("space", "\r", ' ', FLAG_KEY_FONT | FLAG_SECONDARY);
|
||||
addCharKey("nbsp", "\u237d", '\u00a0', FLAG_SMALLER_FONT);
|
||||
|
||||
addPlaceholderKey("removed");
|
||||
|
@ -299,7 +299,7 @@ public class Keyboard2View extends View
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
private int labelColor(KeyValue k, boolean isKeyDown, int defaultColor)
|
||||
private int labelColor(KeyValue k, boolean isKeyDown, boolean sublabel)
|
||||
{
|
||||
if (isKeyDown && k.hasFlags(KeyValue.FLAG_LATCH))
|
||||
{
|
||||
@ -312,7 +312,9 @@ public class Keyboard2View extends View
|
||||
return _theme.activatedColor;
|
||||
}
|
||||
}
|
||||
return defaultColor;
|
||||
if (k.hasFlags(KeyValue.FLAG_SECONDARY))
|
||||
return _theme.secondaryLabelColor;
|
||||
return sublabel ? _theme.subLabelColor : _theme.labelColor;
|
||||
}
|
||||
|
||||
private void drawLabel(Canvas canvas, KeyboardData.Corner k, float x, float y, float keyH, boolean isKeyDown)
|
||||
@ -324,7 +326,7 @@ public class Keyboard2View extends View
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.labelTextSize, keyH);
|
||||
Paint p = _theme.labelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT));
|
||||
p.setColor(labelColor(kv, isKeyDown, _theme.labelColor));
|
||||
p.setColor(labelColor(kv, isKeyDown, false));
|
||||
p.setTextSize(textSize);
|
||||
canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
}
|
||||
@ -340,7 +342,7 @@ public class Keyboard2View extends View
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.sublabelTextSize, keyH);
|
||||
Paint p = _theme.subLabelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT), a);
|
||||
p.setColor(labelColor(kv, isKeyDown, _theme.subLabelColor));
|
||||
p.setColor(labelColor(kv, isKeyDown, true));
|
||||
p.setTextSize(textSize);
|
||||
float subPadding = _config.keyPadding;
|
||||
if (v == Vertical.CENTER)
|
||||
|
@ -3,6 +3,7 @@ package juloo.keyboard2;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
@ -15,6 +16,7 @@ public class Theme
|
||||
public final int activatedColor;
|
||||
public final int labelColor;
|
||||
public final int subLabelColor;
|
||||
public final int secondaryLabelColor;
|
||||
|
||||
public final float keyBorderRadius;
|
||||
|
||||
@ -39,6 +41,8 @@ public class Theme
|
||||
activatedColor = s.getColor(R.styleable.keyboard_colorLabelActivated, 0);
|
||||
lockedColor = s.getColor(R.styleable.keyboard_colorLabelLocked, 0);
|
||||
subLabelColor = s.getColor(R.styleable.keyboard_colorSubLabel, 0);
|
||||
float secondaryLightOffset = s.getFloat(R.styleable.keyboard_secondaryLightOffset, 1.f);
|
||||
secondaryLabelColor = adjustLight(labelColor, secondaryLightOffset);
|
||||
keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0);
|
||||
s.recycle();
|
||||
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
|
||||
@ -67,7 +71,15 @@ public class Theme
|
||||
return _indicationPaint;
|
||||
}
|
||||
|
||||
private Paint initLabelPaint(Paint.Align align, Typeface font)
|
||||
int adjustLight(int color, float offset)
|
||||
{
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
hsv[2] += offset;
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
|
||||
Paint initLabelPaint(Paint.Align align, Typeface font)
|
||||
{
|
||||
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setTextAlign(align);
|
||||
@ -76,7 +88,7 @@ public class Theme
|
||||
return (paint);
|
||||
}
|
||||
|
||||
private static Typeface _key_font = null;
|
||||
static Typeface _key_font = null;
|
||||
|
||||
static public Typeface getKeyFont(Context context)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user