commit 7936f9b80182d24e0819232533eade96b27d0b83
parent f43695b177e76941ef2b3c7698d6b46f3f672f6d
Author: gstraube <gstraube@mailbox.org>
Date: Mon, 5 Feb 2018 15:21:29 +0100
Adjust background colors
Diffstat:
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/app/src/main/java/com/github/cythara/CanvasPainter.java b/app/src/main/java/com/github/cythara/CanvasPainter.java
@@ -29,7 +29,9 @@ class CanvasPainter {
private TextPaint numbersPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
private Paint gaugePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint symbolPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
- private Paint background = new Paint();
+
+ private int redBackground;
+ private int greenBackground;
private PitchDifference pitchDifference;
@@ -58,9 +60,14 @@ class CanvasPainter {
this.canvas = canvas;
+ redBackground = R.color.red_light;
+ greenBackground = R.color.green_light;
if (MainActivity.isNightModeEnabled()) {
int color = context.getResources().getColor(R.color.colorPrimaryDark);
this.canvas.drawColor(color);
+
+ redBackground = R.color.red_dark;
+ greenBackground = R.color.green_dark;
}
gaugeWidth = 0.45F * canvas.getWidth();
@@ -76,6 +83,8 @@ class CanvasPainter {
if (pitchDifference != null && Math.abs(getNearestDeviation()) <= MAX_DEVIATION) {
setBackground();
+ drawGauge();
+
drawIndicator();
drawText();
@@ -240,16 +249,12 @@ class CanvasPainter {
}
private void setBackground() {
- int color = Color.RED;
+ int color = redBackground;
if (Math.abs(getNearestDeviation()) <= TOLERANCE) {
- color = Color.GREEN;
+ color = greenBackground;
}
- background.setColor(color);
-
- background.setStyle(Paint.Style.FILL);
- background.setAlpha(70);
- canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), background);
+ canvas.drawColor(context.getResources().getColor(color));
}
private int getNearestDeviation() {
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
@@ -2,4 +2,8 @@
<resources>
<color name="colorPrimaryDark">#FF212121</color>
<color name="colorTextDark">#DDFFFFFF</color>
+ <color name="red_light">#46e10000</color>
+ <color name="green_light">#4600ff00</color>
+ <color name="red_dark">#20e10000</color>
+ <color name="green_dark">#2000ff00</color>
</resources>