Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two more themes + Bump for release V1.22. #64

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.nicobrailo.pianoli"
minSdkVersion 21
targetSdkVersion 33
versionCode 21
versionName "1.21"
versionCode 22
versionName "1.22"
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/nicobrailo/pianoli/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Preferences {
private final static String PREF_SELECTED_SOUND_SET = "selectedSoundSet";
private final static String PREF_SELECTED_MELODIES = "selectedMelodies";
private final static String PREF_ENABLE_MELODIES = "enableMelodies";
private static final String DEFAULT_THEME = "boomwhacker";
private static final String DEFAULT_THEME = "rainbow";
private final static String PREF_THEME = "theme";

/**
Expand Down
103 changes: 71 additions & 32 deletions app/src/main/java/com/nicobrailo/pianoli/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,99 @@

public class Theme {

private final int[] colours;
private final int[] pressedColours;
private final KeyColor[] colors;

public static Theme fromPreferences(Context context) {
String selectedTheme = Preferences.selectedTheme(context);
switch (selectedTheme) {
case "black_and_white":
return BLACK_AND_WHITE;

default:
case "pastel":
return PASTEL;

case "boomwhacker":
return BOOMWHACKER;

default:
return RAINBOW;
}
}

private static final int[] BOOMWHACKER_COLORS = new int[] {
Color.rgb(220, 0, 0), // Red
Color.rgb(255, 135, 0), // Orange
Color.rgb(255, 255, 0), // Yellow
Color.rgb(80, 220, 20), // Light Green
Color.rgb(0, 150, 150), // Dark Green
Color.rgb(95, 70, 165), // Purple
Color.rgb(213, 43, 149), // Pink
};

/**
* 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 int[] BOOMWHACKER_PRESSED_COLORS = new int[] {
ColorUtils.blendARGB(BOOMWHACKER_COLORS[0], Color.WHITE, 0.5f), // Red
ColorUtils.blendARGB(BOOMWHACKER_COLORS[1], Color.WHITE, 0.6f), // Orange
ColorUtils.blendARGB(BOOMWHACKER_COLORS[2], Color.WHITE, 0.75f), // Yellow
ColorUtils.blendARGB(BOOMWHACKER_COLORS[3], Color.WHITE, 0.6f), // Light Green
ColorUtils.blendARGB(BOOMWHACKER_COLORS[4], Color.WHITE, 0.5f), // Dark Green
ColorUtils.blendARGB(BOOMWHACKER_COLORS[5], Color.WHITE, 0.5f), // Purple
ColorUtils.blendARGB(BOOMWHACKER_COLORS[6], Color.WHITE, 0.5f), // Pink
};

private static final Theme BOOMWHACKER = new Theme(BOOMWHACKER_COLORS, BOOMWHACKER_PRESSED_COLORS);
private static final Theme BOOMWHACKER = new Theme(
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 KeyColor[] {
// https://colorbrewer2.org/#type=qualitative&scheme=Pastel1&n=8
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 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 int[] { Color.rgb(240, 240, 240) },
new int[] { Color.rgb(200, 200, 200) }
new KeyColor[] {
new KeyColor(
Color.rgb(240, 240, 240),
Color.rgb(200, 200, 200)
)
}
);

private Theme(int[] colors, int[] pressedColors) {
this.colours = colors;
this.pressedColours = pressedColors;
private Theme(KeyColor[] colors) {
this.colors = colors;
}

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

private static class KeyColor {
public final int normal;
public final int pressed;

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

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

}
8 changes: 6 additions & 2 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
</string-array>

<string-array name="theme_entryValues">
<item>boomwhacker</item>
<item>rainbow</item>
<item>pastel</item>
<item>black_and_white</item>
<item>boomwhacker</item>
</string-array>

<string-array name="theme_entries">
<item>@string/theme_boomwhacker</item>
<item>@string/theme_rainbow</item>
<item>@string/theme_pastel</item>
<item>@string/theme_black_and_white</item>
<item>@string/theme_boomwhacker</item>
</string-array>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@
<string name="theme">Theme</string>
<string name="theme_black_and_white">Black and White</string>
<string name="theme_boomwhacker" translatable="false">Boomwhacker</string>
<string name="theme_pastel">Pastel</string>
<string name="theme_rainbow">Rainbow</string>
</resources>
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/22.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* New translation: Dutch.
* Two additional themes: Rainbow + Pastel (based on research into xylophones available in toy shops).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.