From 065d9520e571eccca21e28d0e4003ebd4b7079f4 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 17 Feb 2024 19:03:52 +0100 Subject: 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. --- srcs/juloo.keyboard2/Theme.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'srcs') 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); } -- cgit v1.2.3