From 065d9520e571eccca21e28d0e4003ebd4b7079f4 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 17 Feb 2024 19:03:52 +0100 Subject: [PATCH] Dim secondary keys in every themes Themes do not dim secondary keys the same way due to the "offset" mechanism. Instead, use a ratio that is the same for every themes. It's still possible to override this ratio per theme. --- res/values/themes.xml | 10 ++-------- srcs/juloo.keyboard2/Theme.java | 10 ++++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/res/values/themes.xml b/res/values/themes.xml index 5eac562..ef3ede6 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -11,7 +11,7 @@ - + @@ -38,6 +38,7 @@ 5dp 0dp 0dp + 0.25 ?attr/emoji_button_bg ?attr/colorLabel @@ -53,7 +54,6 @@ #3399ff #33cc33 #cccccc - -0.2 #202020 #ffffff @@ -72,7 +72,6 @@ #0066cc #33cc33 #333333 - +0.3 #dedede #000000 @@ -91,7 +90,6 @@ #009dff #00ff26 #bbbbbb - -0.25 1dp #000000 #ffffff @@ -114,7 +112,6 @@ #0066cc #33cc33 #333333 - +0.35 #ffffff #000000 @@ -133,7 +130,6 @@ #000000 #33cc33 #333333 - +0.35 #ffffff #000000 @@ -145,7 +141,6 @@ #000000 #ffffff #e65100 - 0.1 #333333 0.0dip 0.0dip @@ -164,7 +159,6 @@ #000000 #ffffff #64ffda - 0.0 #004d40 0.0dip 0.0dip diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index 8539edb..0319c99 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -48,8 +48,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); + secondaryLabelColor = adjustLight(labelColor, + s.getFloat(R.styleable.keyboard_secondaryDimming, 0.25f)); keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0); keyBorderWidth = s.getDimension(R.styleable.keyboard_keyBorderWidth, 0); keyBorderWidthActivated = s.getDimension(R.styleable.keyboard_keyBorderWidthActivated, 0); @@ -85,11 +85,13 @@ public class Theme return _indicationPaint; } - int adjustLight(int color, float offset) + /** Interpolate the 'value' component toward its opposite by 'alpha'. */ + int adjustLight(int color, float alpha) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); - hsv[2] += offset; + float v = hsv[2]; + hsv[2] = alpha - (2 * alpha - 1) * v; return Color.HSVToColor(hsv); }