diff options
| author | Jules Aguillon | 2024-02-17 19:03:52 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-02-17 23:28:31 +0100 |
| commit | 065d9520e571eccca21e28d0e4003ebd4b7079f4 (patch) | |
| tree | 95268d7f1a4b118e80f6ebd1666f0b00f2f6c72a /srcs/juloo.keyboard2/Theme.java | |
| parent | bb60ed9b13d985a5b52834c90babce305edb68ca (diff) | |
| download | unexpected-keyboard-065d9520e571eccca21e28d0e4003ebd4b7079f4.tar.gz unexpected-keyboard-065d9520e571eccca21e28d0e4003ebd4b7079f4.zip | |
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.
Diffstat (limited to 'srcs/juloo.keyboard2/Theme.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Theme.java | 10 |
1 files changed, 6 insertions, 4 deletions
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); } |
