commit c71793e574242a96e942b25f6202713ec6183d6f
parent 4aea2eea5a4751c23e4a516392c1cbff6887dd97
Author: gstraube <gstraube@mailbox.org>
Date: Mon, 8 Jan 2018 17:48:43 +0100
Adjust sign display in Solfège notation (issue #9)
Diffstat:
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
@@ -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 @@ class CanvasPainter {
}
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 @@ class CanvasPainter {
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 @@ class CanvasPainter {
}
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();
}