169 lines
6.4 KiB
Perl
169 lines
6.4 KiB
Perl
#!/usr/bin/perl
|
|
use strict;
|
|
|
|
use constant THEMES_OUTDIR => './res/values-v21/';
|
|
use constant THEMES_LIST => './res/values-v21/themes-list.xml';
|
|
|
|
my $THEMES = [
|
|
{
|
|
_name => 'standard',
|
|
light => { colorAccent => '#ff3e677a', colorPrimary => '#ff37474f', colorPrimaryDark => '#ff263238', _bg => '#fff0f0f0' },
|
|
dark => { colorAccent => '#ff3e677a', colorPrimary => '#ff37474f', colorPrimaryDark => '#ff263238', _bg => '#ff2a2a2a' },
|
|
},
|
|
{
|
|
_name => 'greyish',
|
|
light => { colorAccent => '#ff212121', colorPrimary => '#ff212121', colorPrimaryDark => '#ff090909', _bg => '#fff0f0f0' },
|
|
dark => { colorAccent => '#ffececec', colorPrimary => '#ff212121', colorPrimaryDark => '#ff090909', _bg => '#ff2a2a2a' },
|
|
},
|
|
{
|
|
_name => 'orange',
|
|
light => { colorAccent => '#FFF57F17', colorPrimary => '#FFE65100', colorPrimaryDark => '#FFBF360C', _bg => '#fff0f0f0' },
|
|
dark => { colorAccent => '#FFF57F17', colorPrimary => '#FFE65100', colorPrimaryDark => '#FFBF360C', _bg => '#ff2a2a2a' },
|
|
},
|
|
];
|
|
|
|
my $BUFF_TENTRIES = '';
|
|
my $BUFF_TVALS = '';
|
|
my $BUFF_TSTYLES = '';
|
|
|
|
my $THEME_ID = 0;
|
|
foreach my $theme_ref (@$THEMES) {
|
|
my $theme_name = $theme_ref->{_name};
|
|
my $theme_id = ($theme_name eq 'standard' ? '' : ucfirst($theme_name)."."); # standard has no prefix
|
|
my $outfile = THEMES_OUTDIR."/theme-$theme_name.xml";
|
|
my $outbuff = get_theme_xml($theme_ref, $theme_id);
|
|
|
|
open(OUT, ">", $outfile) or die "Can not write to $outfile: $!\n";
|
|
print OUT $outbuff;
|
|
close(OUT);
|
|
|
|
# use this loop to also populate the theme list output
|
|
# assumes that get_theme_xml created two themes per definition (light and dark)
|
|
foreach my $variant ('', 'Dark.') {
|
|
my $tvvar = ($variant eq '' ? 'light' : 'dark');
|
|
my $tvarr = join(",", map { $theme_ref->{$tvvar}->{$_} } qw(colorPrimaryDark _bg colorPrimary));
|
|
$BUFF_TENTRIES .= "\t\t<item>$variant".ucfirst($theme_name)."</item>\n";
|
|
$BUFF_TVALS .= "\t\t<item>".($THEME_ID).",$tvarr</item>\n";
|
|
$BUFF_TSTYLES .= "\t\t<item>\@style/${theme_id}${variant}VanillaBase</item>\n";
|
|
$THEME_ID++;
|
|
}
|
|
}
|
|
|
|
|
|
open(OUT, ">", THEMES_LIST) or die "Cannot write theme list: $!\n";
|
|
print OUT << "EOLIST";
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- THIS FILE IS AUTOGENERATED BY generate-themes.pl - DO NOT TOUCH! -->
|
|
<resources>
|
|
<!-- human visible names of the themes -->
|
|
<string-array name="theme_entries">
|
|
$BUFF_TENTRIES </string-array>
|
|
|
|
<!-- the value stored in the shared preferences for each theme -->
|
|
<string-array name="theme_values">
|
|
$BUFF_TVALS </string-array>
|
|
|
|
<!-- the style id for each theme -->
|
|
<integer-array name="theme_styles">
|
|
$BUFF_TSTYLES </integer-array>
|
|
</resources>
|
|
EOLIST
|
|
close(OUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub get_theme_xml {
|
|
my($this, $tid) = @_;
|
|
|
|
my $DATA = << "EOF";
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<!--
|
|
|
|
*** THIS FILE WAS GENERATED BY 'generate-themes.pl' - DO NOT TOUCH ***
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
-->
|
|
|
|
<resources>
|
|
<style name="${tid}VanillaBase" parent="android:Theme.Material.Light.DarkActionBar">
|
|
<item name="overlay_background_color">\@color/overlay_background_light</item>
|
|
<item name="overlay_foreground_color">\@color/overlay_foreground_light</item>
|
|
<item name="float_color">\@color/material_grey_400</item>
|
|
<item name="tabs_background">$this->{light}->{colorPrimary}</item>
|
|
<item name="now_playing_marker">$this->{light}->{colorAccent}</item>
|
|
<item name="controls_normal">\@color/material_grey_600</item>
|
|
<item name="controls_active">$this->{light}->{colorAccent}</item>
|
|
<item name="android:colorAccent">$this->{light}->{colorAccent}</item>
|
|
<item name="android:colorPrimary">$this->{light}->{colorPrimary}</item>
|
|
<item name="android:colorPrimaryDark">$this->{light}->{colorPrimaryDark}</item>
|
|
</style>
|
|
|
|
<style name="${tid}Playback" parent="${tid}VanillaBase">
|
|
<item name="android:actionBarStyle">\@style/Universal.PlaybackActionBar</item>
|
|
</style>
|
|
|
|
<style name="${tid}BackActionBar" parent="${tid}VanillaBase">
|
|
<item name="android:actionBarStyle">\@style/Universal.PlaybackActionBar</item>
|
|
</style>
|
|
|
|
<style name="${tid}Library" parent="${tid}VanillaBase">
|
|
<item name="android:windowActionBar">false</item>
|
|
<item name="android:windowNoTitle">true</item>
|
|
</style>
|
|
|
|
<style name="${tid}PopupDialog" parent="android:Theme.Material.Light.Dialog.MinWidth">
|
|
<item name="controls_normal">\@color/material_grey_600</item>
|
|
<item name="controls_active">$this->{light}->{colorAccent}</item>
|
|
</style>
|
|
|
|
<!-- dark theme -->
|
|
<style name="${tid}Dark.VanillaBase" parent="android:Theme.Material">
|
|
<item name="overlay_background_color">\@color/overlay_background_dark</item>
|
|
<item name="overlay_foreground_color">\@color/overlay_foreground_dark</item>
|
|
<item name="float_color">\@color/material_grey_900</item>
|
|
<item name="tabs_background">$this->{dark}->{colorPrimary}</item>
|
|
<item name="now_playing_marker">$this->{dark}->{colorAccent}</item>
|
|
<item name="controls_normal">\@color/material_grey_600</item>
|
|
<item name="controls_active">$this->{dark}->{colorAccent}</item>
|
|
<item name="android:colorAccent">$this->{dark}->{colorAccent}</item>
|
|
<item name="android:colorPrimary">$this->{dark}->{colorPrimary}</item>
|
|
<item name="android:colorPrimaryDark">$this->{dark}->{colorPrimaryDark}</item>
|
|
</style>
|
|
|
|
<style name="${tid}Dark.Playback" parent="${tid}Dark.VanillaBase">
|
|
<item name="android:actionBarStyle">\@style/Universal.PlaybackActionBar</item>
|
|
</style>
|
|
|
|
<style name="${tid}Dark.BackActionBar" parent="${tid}Dark.VanillaBase">
|
|
<item name="android:actionBarStyle">\@style/Universal.PlaybackActionBar</item>
|
|
</style>
|
|
|
|
<style name="${tid}Dark.Library" parent="${tid}Dark.VanillaBase">
|
|
<item name="android:windowActionBar">false</item>
|
|
<item name="android:windowNoTitle">true</item>
|
|
</style>
|
|
|
|
<style name="${tid}Dark.PopupDialog" parent="android:Theme.Material.Dialog.MinWidth">
|
|
<item name="controls_normal">\@color/material_grey_600</item>
|
|
<item name="controls_active">$this->{dark}->{colorAccent}</item>
|
|
</style>
|
|
|
|
</resources>
|
|
EOF
|
|
return $DATA
|
|
}
|