Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Adjust sign display in Solfège notation (issue #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
gstraube committed Jan 8, 2018
1 parent 4aea2ee commit c71793e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/src/main/java/com/github/cythara/CanvasPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
}
Expand Down

0 comments on commit c71793e

Please sign in to comment.