From c71793e574242a96e942b25f6202713ec6183d6f Mon Sep 17 00:00:00 2001 From: gstraube Date: Mon, 8 Jan 2018 17:48:43 +0100 Subject: [PATCH] =?UTF-8?q?Adjust=20sign=20display=20in=20Solf=C3=A8ge=20n?= =?UTF-8?q?otation=20(issue=20#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/cythara/CanvasPainter.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/cythara/CanvasPainter.java b/app/src/main/java/com/github/cythara/CanvasPainter.java index f37aaa1..7a6d561 100644 --- a/app/src/main/java/com/github/cythara/CanvasPainter.java +++ b/app/src/main/java/com/github/cythara/CanvasPainter.java @@ -35,6 +35,7 @@ class CanvasPainter { private float gaugeWidth; private float x; private float y; + private boolean useScientificNotation; static CanvasPainter with(Context context) { return new CanvasPainter(context); @@ -51,6 +52,9 @@ CanvasPainter paint(PitchDifference pitchDifference) { } void on(Canvas canvas) { + SharedPreferences preferences = context.getSharedPreferences(PREFS_FILE, MODE_PRIVATE); + useScientificNotation = preferences.getBoolean(USE_SCIENTIFIC_NOTATION, true); + this.canvas = canvas; gaugeWidth = 0.45F * canvas.getWidth(); @@ -192,17 +196,18 @@ private void drawText() { int textSize = (int) (textPaint.getTextSize() / 2); paint.setTextSize(textSize); - canvas.drawText(sign, x + offset * 1.25f, y - offset * 1.5f, paint); + float factor = 0.75f; + if (useScientificNotation) { + factor = 1.5f; + } + + canvas.drawText(sign, x + offset * 1.25f, y - offset * factor, paint); canvas.drawText(octave, x + offset * 1.25f, y + offset * 0.5f, paint); canvas.drawText(note, x - offset, y, textPaint); } private int getOctave(int octave) { - SharedPreferences preferences = context.getSharedPreferences(PREFS_FILE, MODE_PRIVATE); - - boolean useScientificNotation = preferences.getBoolean(USE_SCIENTIFIC_NOTATION, true); - if (useScientificNotation) { return octave; } @@ -221,10 +226,6 @@ The octave number in the (French notation) of Solfège is one less than the } private String getNote(NoteName name) { - SharedPreferences preferences = context.getSharedPreferences(PREFS_FILE, MODE_PRIVATE); - - boolean useScientificNotation = preferences.getBoolean(USE_SCIENTIFIC_NOTATION, true); - if (useScientificNotation) { return name.getScientific(); }