mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-06-21 10:18:07 +02:00
Fix label brightness not being applied
This is due to Paint.setColor overriding any alpha value set with Paint.setAlpha. Bug was added in 653c598.
This commit is contained in:
parent
35219a458a
commit
6717613b5e
@ -441,8 +441,7 @@ public class Keyboard2View extends View
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.labelTextSize, keyH);
|
||||
Paint p = tc.label_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), textSize);
|
||||
p.setColor(labelColor(kv, isKeyDown, false));
|
||||
Paint p = tc.label_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), labelColor(kv, isKeyDown, false), textSize);
|
||||
canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
}
|
||||
|
||||
@ -456,8 +455,7 @@ public class Keyboard2View extends View
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.sublabelTextSize, keyH);
|
||||
Paint p = tc.sublabel_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), textSize, a);
|
||||
p.setColor(labelColor(kv, isKeyDown, true));
|
||||
Paint p = tc.sublabel_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), labelColor(kv, isKeyDown, true), textSize, a);
|
||||
float subPadding = _config.keyPadding;
|
||||
if (v == Vertical.CENTER)
|
||||
y += (keyH - p.ascent() - p.descent()) / 2f;
|
||||
|
@ -126,6 +126,7 @@ public class Theme
|
||||
final Paint _special_label_paint;
|
||||
final Paint _sublabel_paint;
|
||||
final Paint _special_sublabel_paint;
|
||||
final int _label_alpha_bits;
|
||||
|
||||
public Key(Theme theme, Config config, float keyWidth, boolean activated)
|
||||
{
|
||||
@ -149,18 +150,21 @@ public class Theme
|
||||
_special_label_paint = init_label_paint(config, _key_font);
|
||||
_sublabel_paint = init_label_paint(config, null);
|
||||
_special_sublabel_paint = init_label_paint(config, _key_font);
|
||||
_label_alpha_bits = (config.labelBrightness & 0xFF) << 24;
|
||||
}
|
||||
|
||||
public Paint label_paint(boolean special_font, float text_size)
|
||||
public Paint label_paint(boolean special_font, int color, float text_size)
|
||||
{
|
||||
Paint p = special_font ? _special_label_paint : _label_paint;
|
||||
p.setColor((color & 0x00FFFFFF) | _label_alpha_bits);
|
||||
p.setTextSize(text_size);
|
||||
return p;
|
||||
}
|
||||
|
||||
public Paint sublabel_paint(boolean special_font, float text_size, Paint.Align align)
|
||||
public Paint sublabel_paint(boolean special_font, int color, float text_size, Paint.Align align)
|
||||
{
|
||||
Paint p = special_font ? _special_sublabel_paint : _sublabel_paint;
|
||||
p.setColor((color & 0x00FFFFFF) | _label_alpha_bits);
|
||||
p.setTextSize(text_size);
|
||||
p.setTextAlign(align);
|
||||
return p;
|
||||
@ -181,7 +185,6 @@ public class Theme
|
||||
{
|
||||
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
p.setTextAlign(Paint.Align.CENTER);
|
||||
p.setAlpha(config.labelBrightness);
|
||||
if (font != null)
|
||||
p.setTypeface(font);
|
||||
return p;
|
||||
|
Loading…
x
Reference in New Issue
Block a user