plectrum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1c9f3fb10429fe33816ae51386512372d937bdff
parent 6e75c9b37fe262be3f7dc8b494eb7de28a0f4653
Author: gstraube <gstraube@mailbox.org>
Date:   Thu,  8 Feb 2018 16:17:09 +0100

Change text color on canvas

Diffstat:
Mapp/src/main/java/com/github/cythara/CanvasPainter.java | 11++++++++---
Mapp/src/main/res/values/colors.xml | 1+
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/com/github/cythara/CanvasPainter.java b/app/src/main/java/com/github/cythara/CanvasPainter.java @@ -32,6 +32,7 @@ class CanvasPainter { private int redBackground; private int greenBackground; + private int textColor; private PitchDifference pitchDifference; @@ -62,19 +63,21 @@ class CanvasPainter { redBackground = R.color.red_light; greenBackground = R.color.green_light; + textColor = Color.BLACK; if (MainActivity.isDarkModeEnabled()) { int color = context.getResources().getColor(R.color.colorPrimaryDark); this.canvas.drawColor(color); redBackground = R.color.red_dark; greenBackground = R.color.green_dark; + textColor = context.getResources().getColor(R.color.colorTextDarkCanvas); } gaugeWidth = 0.45F * canvas.getWidth(); x = canvas.getWidth() / 2F; y = canvas.getHeight() / 2F; - textPaint.setColor(Color.BLACK); + textPaint.setColor(textColor); int textSize = context.getResources().getDimensionPixelSize(R.dimen.noteTextSize); textPaint.setTextSize(textSize); @@ -94,13 +97,14 @@ class CanvasPainter { } private void drawGauge() { - gaugePaint.setColor(Color.BLACK); + gaugePaint.setColor(textColor); int gaugeSize = context.getResources().getDimensionPixelSize(R.dimen.gaugeSize); gaugePaint.setStrokeWidth(gaugeSize); int textSize = context.getResources().getDimensionPixelSize(R.dimen.numbersTextSize); numbersPaint.setTextSize(textSize); + numbersPaint.setColor(textColor); canvas.drawLine(x - gaugeWidth, y, x + gaugeWidth, y, gaugePaint); @@ -143,6 +147,7 @@ class CanvasPainter { int symbolsTextSize = context.getResources().getDimensionPixelSize(R.dimen.symbolsTextSize); symbolPaint.setTextSize(symbolsTextSize); + symbolPaint.setColor(textColor); float yPos = canvas.getHeight() / 4F; canvas.drawText(sharp, @@ -207,7 +212,7 @@ class CanvasPainter { String octave = String.valueOf(getOctave(closest.getOctave())); TextPaint paint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - paint.setColor(Color.BLACK); + paint.setColor(textColor); int textSize = (int) (textPaint.getTextSize() / 2); paint.setTextSize(textSize); diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml @@ -2,6 +2,7 @@ <resources> <color name="colorPrimaryDark">#FF212121</color> <color name="colorTextDark">#DDFFFFFF</color> + <color name="colorTextDarkCanvas">#ff9412</color> <color name="red_light">#46e10000</color> <color name="green_light">#4600ff00</color> <color name="red_dark">#20e10000</color>