Skip to content

Commit

Permalink
Rename fields/classes in response to code review feedback.
Browse files Browse the repository at this point in the history
Using American English for the class in this file, but leaving elsewhere (that is a tomorrow problem for another PR ;)
  • Loading branch information
pserwylo committed Sep 11, 2023
1 parent 9ed8a9c commit 10340b1
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions app/src/main/java/com/nicobrailo/pianoli/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class Theme {

private final KeyColour[] colours;
private final KeyColor[] colors;

public static Theme fromPreferences(Context context) {
String selectedTheme = Preferences.selectedTheme(context);
Expand All @@ -27,78 +27,78 @@ public static Theme fromPreferences(Context context) {
}

/**
* Note that light green, orange and yellow have higher lightness than other colours,
* Note that light green, orange and yellow have higher lightness than other colors,
* so adding just a little white doesn't have the desired effect.
* That is why they have a larger proportion of white added in.
*/
private static final Theme BOOMWHACKER = new Theme(
new KeyColour[] {
KeyColour.createLighterWhenPressed(Color.rgb(220, 0, 0), 0.5f), // Red
KeyColour.createLighterWhenPressed(Color.rgb(255, 135, 0), 0.6f), // Orange
KeyColour.createLighterWhenPressed(Color.rgb(255, 255, 0), 0.75f), // Yellow
KeyColour.createLighterWhenPressed(Color.rgb(80, 220, 20), 0.6f), // Light Green
KeyColour.createLighterWhenPressed(Color.rgb(0, 150, 150), 0.5f), // Dark Green
KeyColour.createLighterWhenPressed(Color.rgb(95, 70, 165), 0.5f), // Purple
KeyColour.createLighterWhenPressed(Color.rgb(213, 43, 149), 0.5f), // Pink
new KeyColor[] {
KeyColor.createLighterWhenPressed(Color.rgb(220, 0, 0), 0.5f), // Red
KeyColor.createLighterWhenPressed(Color.rgb(255, 135, 0), 0.6f), // Orange
KeyColor.createLighterWhenPressed(Color.rgb(255, 255, 0), 0.75f), // Yellow
KeyColor.createLighterWhenPressed(Color.rgb(80, 220, 20), 0.6f), // Light Green
KeyColor.createLighterWhenPressed(Color.rgb(0, 150, 150), 0.5f), // Dark Green
KeyColor.createLighterWhenPressed(Color.rgb(95, 70, 165), 0.5f), // Purple
KeyColor.createLighterWhenPressed(Color.rgb(213, 43, 149), 0.5f), // Pink
}
);

private static final Theme PASTEL = new Theme(
new KeyColour[] {
new KeyColor[] {
// https://colorbrewer2.org/#type=qualitative&scheme=Pastel1&n=8
KeyColour.createLighterWhenPressed(0xfffbb4ae, 0.5f),
KeyColour.createLighterWhenPressed(0xffb3cde3, 0.5f),
KeyColour.createLighterWhenPressed(0xffccebc5, 0.5f),
KeyColour.createLighterWhenPressed(0xffdecbe4, 0.5f),
KeyColour.createLighterWhenPressed(0xfffed9a6, 0.5f),
KeyColour.createLighterWhenPressed(0xffffffcc, 0.5f),
KeyColour.createLighterWhenPressed(0xffe5d8bd, 0.5f),
KeyColor.createLighterWhenPressed(0xfffbb4ae, 0.5f),
KeyColor.createLighterWhenPressed(0xffb3cde3, 0.5f),
KeyColor.createLighterWhenPressed(0xffccebc5, 0.5f),
KeyColor.createLighterWhenPressed(0xffdecbe4, 0.5f),
KeyColor.createLighterWhenPressed(0xfffed9a6, 0.5f),
KeyColor.createLighterWhenPressed(0xffffffcc, 0.5f),
KeyColor.createLighterWhenPressed(0xffe5d8bd, 0.5f),
}
);

private static final Theme RAINBOW = new Theme(
new KeyColour[] {
KeyColour.createLighterWhenPressed(0xff001caf, 0.5f), // darkblue
KeyColour.createLighterWhenPressed(0xff0099ff, 0.5f), // lightblue
KeyColour.createLighterWhenPressed(0xff63c624, 0.5f), // darkgreen
KeyColour.createLighterWhenPressed(0xffbde53d, 0.5f), // lightgreen
KeyColour.createLighterWhenPressed(0xfffcc000, 0.5f), // yellow
KeyColour.createLighterWhenPressed(0xffff810a, 0.5f), // lightorange
KeyColour.createLighterWhenPressed(0xffff5616, 0.5f), // darkorange
KeyColour.createLighterWhenPressed(0xffd51016, 0.5f), // red
new KeyColor[] {
KeyColor.createLighterWhenPressed(0xff001caf, 0.5f), // darkblue
KeyColor.createLighterWhenPressed(0xff0099ff, 0.5f), // lightblue
KeyColor.createLighterWhenPressed(0xff63c624, 0.5f), // darkgreen
KeyColor.createLighterWhenPressed(0xffbde53d, 0.5f), // lightgreen
KeyColor.createLighterWhenPressed(0xfffcc000, 0.5f), // yellow
KeyColor.createLighterWhenPressed(0xffff810a, 0.5f), // lightorange
KeyColor.createLighterWhenPressed(0xffff5616, 0.5f), // darkorange
KeyColor.createLighterWhenPressed(0xffd51016, 0.5f), // red
}
);

private static final Theme BLACK_AND_WHITE = new Theme(
new KeyColour[] {
new KeyColour(
new KeyColor[] {
new KeyColor(
Color.rgb(240, 240, 240),
Color.rgb(200, 200, 200)
)
}
);

private Theme(KeyColour[] colors) {
this.colours = colors;
private Theme(KeyColor[] colors) {
this.colors = colors;
}

public int getColorForKey(int keyIndex, boolean isPressed) {
final int col_idx = (keyIndex / 2) % colours.length;
final KeyColour key = colours[col_idx];
return isPressed ? key.pressedColour : key.colour;
final int col_idx = (keyIndex / 2) % colors.length;
final KeyColor color = colors[col_idx];
return isPressed ? color.pressed : color.normal;
}

private static class KeyColour {
public final int colour;
public final int pressedColour;
private static class KeyColor {
public final int normal;
public final int pressed;

public KeyColour(int colour, int pressedColour) {
this.colour = colour;
this.pressedColour = pressedColour;
public KeyColor(int normal, int pressed) {
this.normal = normal;
this.pressed = pressed;
}

public static KeyColour createLighterWhenPressed(int colour, float blendWhiteFactor) {
return new KeyColour(colour, ColorUtils.blendARGB(colour, Color.WHITE, blendWhiteFactor));
public static KeyColor createLighterWhenPressed(int color, float blendWhiteFactor) {
return new KeyColor(color, ColorUtils.blendARGB(color, Color.WHITE, blendWhiteFactor));
}
}

Expand Down

0 comments on commit 10340b1

Please sign in to comment.