Dark theme support for Android 5.0
This commit is contained in:
parent
28051cf450
commit
3d87a167c8
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
Copyright (C) 2012-2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -36,7 +36,6 @@ THE SOFTWARE.
|
||||
android:label="@string/app_name">
|
||||
<activity
|
||||
android:name="FullPlaybackActivity"
|
||||
android:theme="@style/Playback"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name="LibraryActivity"
|
||||
@ -50,8 +49,7 @@ THE SOFTWARE.
|
||||
</activity>
|
||||
<activity
|
||||
android:name="PlaylistActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/BackActionBar" />
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name="MiniPlaybackActivity"
|
||||
android:theme="@style/Dialog"
|
||||
@ -59,7 +57,6 @@ THE SOFTWARE.
|
||||
android:launchMode="singleInstance" />
|
||||
<activity
|
||||
android:name="ShowQueueActivity"
|
||||
android:theme="@style/BackActionBar"
|
||||
android:launchMode="singleInstance" />
|
||||
<receiver
|
||||
android:name=".OneCellWidget"
|
||||
@ -136,14 +133,11 @@ THE SOFTWARE.
|
||||
</intent-filter>
|
||||
</service>
|
||||
<activity
|
||||
android:name="PreferencesActivity"
|
||||
android:theme="@style/BackActionBar" />
|
||||
android:name="PreferencesActivity" />
|
||||
<activity
|
||||
android:name="TabOrderActivity"
|
||||
android:theme="@style/BackActionBar" />
|
||||
android:name="TabOrderActivity" />
|
||||
<activity
|
||||
android:name="FilebrowserStartActivity"
|
||||
android:theme="@style/BackActionBar" />
|
||||
android:name="FilebrowserStartActivity" />
|
||||
|
||||
<activity android:name="AudioPickerActivity" android:theme="@style/DialogMinWidth"
|
||||
android:excludeFromRecents="true" android:exported="true" >
|
||||
|
@ -67,6 +67,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_color"/>
|
||||
android:background="?divider_color"/>
|
||||
|
||||
</ch.blinkenlights.android.vanilla.DraggableRow>
|
||||
|
@ -67,6 +67,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_color"/>
|
||||
android:background="?divider_color"/>
|
||||
|
||||
</ch.blinkenlights.android.vanilla.DraggableRow>
|
||||
|
@ -48,7 +48,7 @@ THE SOFTWARE.
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@color/divider_color"
|
||||
android:background="?divider_color"
|
||||
/>
|
||||
|
||||
<ListView
|
||||
@ -56,7 +56,7 @@ THE SOFTWARE.
|
||||
android:id="@+id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="@color/divider_color"
|
||||
android:divider="?divider_color"
|
||||
android:dividerHeight="1dip"
|
||||
android:listSelector="?android:attr/selectableItemBackground"
|
||||
android:scrollbarStyle="outsideInset" />
|
||||
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/overlay_background_color"
|
||||
android:background="?overlay_background_color"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/elapsed"
|
||||
@ -61,7 +61,7 @@ THE SOFTWARE.
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_gravity="bottom|left"
|
||||
android:layout_margin="0dip"
|
||||
android:background="@color/overlay_background_color"
|
||||
android:background="?overlay_background_color"
|
||||
android:orientation="horizontal">
|
||||
<include layout="@layout/controls" />
|
||||
</LinearLayout>
|
||||
|
@ -33,18 +33,18 @@ THE SOFTWARE.
|
||||
android:collapseColumns="0"
|
||||
android:stretchColumns="1"
|
||||
android:shrinkColumns="1"
|
||||
android:background="@color/overlay_background_color"
|
||||
android:background="?overlay_background_color"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip">
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_title"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:id="@+id/queue_pos"
|
||||
@ -54,66 +54,66 @@ THE SOFTWARE.
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_artist"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/artist" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/artist" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_album"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/album" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/album" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_genre"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/genre" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/genre" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_track"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/track" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/track" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_year"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/year" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/year" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_composer"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/composer" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/composer" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_format"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/format" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/format" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/_replaygain"
|
||||
android:textColor="@color/overlay_foreground_color"
|
||||
android:textColor="?overlay_foreground_color"
|
||||
android:paddingRight="5dip"
|
||||
android:gravity="right" />
|
||||
<TextView android:id="@+id/replaygain" android:textColor="@color/overlay_foreground_color"/>
|
||||
<TextView android:id="@+id/replaygain" android:textColor="?overlay_foreground_color"/>
|
||||
</TableRow>
|
||||
<LinearLayout android:id="@+id/controls_top">
|
||||
<TextView
|
||||
@ -144,7 +144,7 @@ THE SOFTWARE.
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_gravity="bottom|left"
|
||||
android:layout_margin="0dip"
|
||||
android:background="@color/overlay_background_color"
|
||||
android:background="?overlay_background_color"
|
||||
android:orientation="horizontal">
|
||||
<include layout="@layout/controls" />
|
||||
</LinearLayout>
|
||||
|
@ -38,7 +38,7 @@ THE SOFTWARE.
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="1dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/divider_color" />
|
||||
android:background="?divider_color" />
|
||||
<ImageView
|
||||
android:id="@+id/arrow"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
|
@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@color/divider_color"
|
||||
android:divider="?divider_color"
|
||||
android:dividerHeight="1dip"
|
||||
android:listSelector="?android:attr/selectableItemBackground"
|
||||
android:scrollbarStyle="outsideInset" />
|
||||
|
@ -25,5 +25,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:scrollbarStyle="outsideInset"
|
||||
dslv:drag_enabled="false"
|
||||
dslv:drag_start_mode="onMove"
|
||||
dslv:float_background_color="@color/float_color"
|
||||
dslv:float_background_color="?float_color"
|
||||
dslv:drag_handle_id="@+id/dragger"/>
|
||||
|
@ -10,7 +10,7 @@
|
||||
android:divider="@null"
|
||||
dslv:drag_enabled="true"
|
||||
dslv:drag_start_mode="onMove"
|
||||
dslv:float_background_color="@color/float_color"
|
||||
dslv:float_background_color="?float_color"
|
||||
dslv:drag_handle_id="@+id/dragger"
|
||||
dslv:remove_enabled="true"
|
||||
dslv:remove_mode="flingRemove"
|
||||
|
@ -37,7 +37,7 @@ THE SOFTWARE.
|
||||
android:choiceMode="multipleChoice"
|
||||
dslv:drag_enabled="true"
|
||||
dslv:drag_start_mode="onMove"
|
||||
dslv:float_background_color="@color/float_color"
|
||||
dslv:float_background_color="?float_color"
|
||||
dslv:drag_handle_id="@+id/dragger" />
|
||||
<LinearLayout
|
||||
style="?android:attr/buttonBarStyle"
|
||||
|
@ -24,12 +24,7 @@ Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
<color name="material_grey_600">#ff757575</color>
|
||||
<color name="material_grey_900">#ff212121</color>
|
||||
<color name="button_material_light">#ffd6d7d7</color>
|
||||
|
||||
<!-- Color used in LibraryActivity list dividers -->
|
||||
<color name="divider_color">@color/button_material_light</color>
|
||||
<color name="overlay_background_color">#ffefefef</color>
|
||||
<color name="overlay_foreground_color">#f000</color>
|
||||
<color name="float_color">@color/button_material_light</color>
|
||||
<color name="button_material_dark">#ff5a595b</color>
|
||||
|
||||
<!-- Material design primary colors -->
|
||||
<color name="vanillaPrimary">#ff37474f</color>
|
||||
@ -40,17 +35,15 @@ Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
<color name="controls_active">@color/vanillaAccent</color>
|
||||
<color name="controls_normal">@color/material_grey_600</color>
|
||||
|
||||
<!-- styling of the default cover bitmap -->
|
||||
<color name="defaultcover_background">@color/overlay_background_color</color>
|
||||
<color name="defaultcover_gradient_begin">@color/divider_color</color>
|
||||
<color name="defaultcover_gradient_end">@color/divider_color</color>
|
||||
<color name="defaultcover_center">#55ffffff</color>
|
||||
|
||||
<!-- styles -->
|
||||
<style name="Dialog" parent="android:Theme.Material.Light.Dialog" />
|
||||
<style name="DialogMinWidth" parent="android:Theme.Material.Light.Dialog.MinWidth" />
|
||||
|
||||
<style name="VanillaBase" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="overlay_background_color">#ffeeeeee</item>
|
||||
<item name="overlay_foreground_color">#f000</item>
|
||||
<item name="divider_color">@color/button_material_light</item>
|
||||
<item name="float_color">@color/button_material_light</item>
|
||||
<item name="android:colorAccent">@color/vanillaAccent</item>
|
||||
<item name="android:colorPrimary">@color/vanillaPrimary</item>
|
||||
<item name="android:colorPrimaryDark">@color/vanillaPrimaryDark</item>
|
||||
@ -85,4 +78,36 @@ Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
<item name="android:textColor">@color/material_grey_900</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<!-- dark theme -->
|
||||
<style name="Dark.VanillaBase" parent="android:Theme.Material">
|
||||
<item name="overlay_background_color">#ff303030</item>
|
||||
<item name="overlay_foreground_color">#ffffffff</item>
|
||||
<item name="divider_color">@color/button_material_dark</item>
|
||||
<item name="float_color">@color/material_grey_900</item>
|
||||
<item name="android:colorAccent">@color/vanillaAccent</item>
|
||||
<item name="android:colorPrimary">@color/vanillaPrimary</item>
|
||||
<item name="android:colorPrimaryDark">@color/vanillaPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.Playback" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.Library" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/LibraryActionBar</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/Dark.LibraryActionBarTabText</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.BackActionBar" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.LibraryActionBarTabText" parent="android:Widget.Material.ActionBar.TabText">
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textSize">11.5sp</item>
|
||||
<item name="android:textColor">@color/material_grey_300</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
6
res/values/attrs.xml
Normal file
6
res/values/attrs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<attr name="overlay_background_color" format="color" />
|
||||
<attr name="overlay_foreground_color" format="color" />
|
||||
<attr name="divider_color" format="color" />
|
||||
<attr name="float_color" format="color" />
|
||||
</resources>
|
@ -21,19 +21,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<resources>
|
||||
<!-- Color used in LibraryActivity list dividers -->
|
||||
<color name="divider_color">#f444</color>
|
||||
<color name="overlay_background_color">#a000</color>
|
||||
<!-- color to use in full_playback text, set to bright_foreground_disabled_holo_light //-->
|
||||
<color name="overlay_foreground_color">#ffb2b2b2</color>
|
||||
<color name="float_color">#f222</color>
|
||||
|
||||
<!-- styling of the default cover bitmap -->
|
||||
<color name="defaultcover_background">#ff000000</color>
|
||||
<color name="defaultcover_gradient_begin">#ff606060</color>
|
||||
<color name="defaultcover_gradient_end">#ff404040</color>
|
||||
<color name="defaultcover_center">#88000000</color>
|
||||
|
||||
<!-- now-playing screen buttons tint -->
|
||||
<color name="controls_active">@android:color/holo_blue_dark</color>
|
||||
<color name="controls_normal">#fff5f5f5</color>
|
||||
@ -44,17 +31,26 @@ THE SOFTWARE.
|
||||
<style name="AlertDialogItem">
|
||||
<item name="android:textColor">?android:textColorAlertDialogListItem</item>
|
||||
</style>
|
||||
<style name="Playback" parent="android:Theme.Holo">
|
||||
|
||||
<style name="VanillaBase" parent="android:Theme.Holo">
|
||||
<item name="overlay_background_color">#a000</item>
|
||||
<!-- color to use in full_playback text, set to bright_foreground_disabled_holo_light //-->
|
||||
<item name="overlay_foreground_color">#ffb2b2b2</item>
|
||||
<item name="divider_color">#f444</item>
|
||||
<item name="float_color">#f222</item>
|
||||
</style>
|
||||
|
||||
<style name="Playback" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
<item name="android:windowBackground">@android:color/black</item>
|
||||
</style>
|
||||
<style name="BackActionBar" parent="android:Theme.Holo">
|
||||
<style name="BackActionBar" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
</style>
|
||||
<style name="PlaybackActionBar" parent="android:Widget.Holo.ActionBar">
|
||||
<item name="android:displayOptions">showTitle|homeAsUp</item>
|
||||
</style>
|
||||
<style name="Library" parent="android:Theme.Holo">
|
||||
<style name="Library" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/LibraryActionBar</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/LibraryActionBarTabText</item>
|
||||
</style>
|
||||
|
@ -207,6 +207,8 @@ THE SOFTWARE.
|
||||
<string name="shake_threshold_title">Shake Force Threshold</string>
|
||||
|
||||
<string name="misc_features">Miscellaneous Features</string>
|
||||
<string name="use_dark_theme_title">Use dark theme</string>
|
||||
<string name="use_dark_theme_summary">Enables the dark material theme (requires restart)</string>
|
||||
<string name="disable_lockscreen_title">Disable Lockscreen</string>
|
||||
<string name="disable_lockscreen_summary">Prevent the lockscreen from activating when in the library or playback screen</string>
|
||||
<string name="use_idle_timeout_title">Enable Idle Timeout</string>
|
||||
|
@ -28,6 +28,11 @@ THE SOFTWARE.
|
||||
android:title="@string/playback_on_startup_title"
|
||||
android:summary="@string/playback_on_startup_summary"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="use_dark_theme"
|
||||
android:title="@string/use_dark_theme_title"
|
||||
android:summary="@string/use_dark_theme_summary"
|
||||
android:defaultValue="false" />
|
||||
<ch.blinkenlights.android.vanilla.ListPreferenceSummary
|
||||
android:key="display_mode"
|
||||
android:title="@string/display_mode_title"
|
||||
|
@ -339,10 +339,11 @@ public final class CoverBitmap {
|
||||
int halfSize = size / 2;
|
||||
int eightSize = size / 8;
|
||||
|
||||
int rgb_background = context.getResources().getColor(R.color.defaultcover_background);
|
||||
int rgb_gardient_begin = context.getResources().getColor(R.color.defaultcover_gradient_begin);
|
||||
int rgb_gardient_end = context.getResources().getColor(R.color.defaultcover_gradient_end);
|
||||
int rgb_center = context.getResources().getColor(R.color.defaultcover_center);
|
||||
int[] colors = ThemeHelper.getDefaultCoverColors(context);
|
||||
int rgb_background = colors[0];
|
||||
int rgb_gardient_begin = colors[1];
|
||||
int rgb_gardient_end = colors[2];
|
||||
int rgb_center = colors[3];
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
bitmap.eraseColor(rgb_background);
|
||||
|
@ -45,8 +45,9 @@ public class FilebrowserStartActivity extends PlaybackActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
ThemeHelper.setTheme(this, R.style.BackActionBar);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setTitle(R.string.filebrowser_start);
|
||||
setContentView(R.layout.filebrowser_content);
|
||||
mCurrentPath = (String)getFilesystemBrowseStart().getAbsolutePath();
|
||||
|
@ -123,6 +123,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
@Override
|
||||
public void onCreate(Bundle icicle)
|
||||
{
|
||||
ThemeHelper.setTheme(this, R.style.Playback);
|
||||
super.onCreate(icicle);
|
||||
|
||||
setTitle(R.string.playback_view);
|
||||
@ -254,7 +255,8 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
TextView view = new TextView(this);
|
||||
// This will be drawn on top of all other controls, so we flood this view
|
||||
// with a non-alpha color
|
||||
view.setBackgroundResource(R.color.defaultcover_background);
|
||||
int[] colors = ThemeHelper.getDefaultCoverColors(this);
|
||||
view.setBackgroundColor(colors[0]); // background of default cover
|
||||
view.setGravity(Gravity.CENTER);
|
||||
view.setPadding(25, 25, 25, 25);
|
||||
// Make the view clickable so it eats touch events
|
||||
|
@ -165,6 +165,7 @@ public class LibraryActivity
|
||||
@Override
|
||||
public void onCreate(Bundle state)
|
||||
{
|
||||
ThemeHelper.setTheme(this, R.style.Library);
|
||||
super.onCreate(state);
|
||||
|
||||
if (state == null) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2014-2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -55,7 +55,8 @@ import android.widget.Toast;
|
||||
public abstract class PlaybackActivity extends Activity
|
||||
implements Handler.Callback,
|
||||
View.OnClickListener,
|
||||
CoverView.Callback
|
||||
CoverView.Callback,
|
||||
SharedPreferences.OnSharedPreferenceChangeListener
|
||||
{
|
||||
private Action mUpAction;
|
||||
private Action mDownAction;
|
||||
@ -118,6 +119,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
startService(new Intent(this, PlaybackService.class));
|
||||
|
||||
SharedPreferences prefs = PlaybackService.getSettings(this);
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
mUpAction = Action.getAction(prefs, PrefKeys.SWIPE_UP_ACTION, Action.Nothing);
|
||||
mDownAction = Action.getAction(prefs, PrefKeys.SWIPE_DOWN_ACTION, Action.Nothing);
|
||||
|
||||
@ -139,8 +141,19 @@ public abstract class PlaybackActivity extends Activity
|
||||
PlaybackService service = PlaybackService.get(this);
|
||||
service.userActionTriggered();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(PrefKeys.USE_DARK_THEME)) {
|
||||
// Terminate this activity as the currently used theme is outdated
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
|
@ -1944,13 +1944,7 @@ public final class PlaybackService extends Service
|
||||
|
||||
String title = song.title;
|
||||
|
||||
int playButton = 0;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// Android >= 5.0 uses the dark version of this drawable
|
||||
playButton = playing ? R.drawable.widget_pause : R.drawable.widget_play;
|
||||
} else {
|
||||
playButton = playing ? R.drawable.pause : R.drawable.play;
|
||||
}
|
||||
int playButton = ThemeHelper.getPlayButtonResource(playing);
|
||||
|
||||
views.setImageViewResource(R.id.play_pause, playButton);
|
||||
expanded.setImageViewResource(R.id.play_pause, playButton);
|
||||
|
@ -91,6 +91,7 @@ public class PlaylistActivity extends Activity
|
||||
@Override
|
||||
public void onCreate(Bundle state)
|
||||
{
|
||||
ThemeHelper.setTheme(this, R.style.BackActionBar);
|
||||
super.onCreate(state);
|
||||
|
||||
HandlerThread thread = new HandlerThread(getClass().getName());
|
||||
|
@ -63,5 +63,5 @@ public class PrefKeys {
|
||||
public static final String REPLAYGAIN_BUMP = "replaygain_bump";
|
||||
public static final String REPLAYGAIN_UNTAGGED_DEBUMP = "replaygain_untagged_debump";
|
||||
public static final String ENABLE_READAHEAD = "enable_readahead";
|
||||
public static final String USE_LIGHT_THEME = "light_theme";
|
||||
public static final String USE_DARK_THEME = "use_dark_theme";
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2012-2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -31,6 +31,7 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -42,6 +43,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.net.Uri;
|
||||
import android.util.TypedValue;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -55,6 +57,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
ThemeHelper.setTheme(this, R.style.BackActionBar);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@ -152,6 +155,14 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preference_playback);
|
||||
|
||||
// Hide the dark theme preference if this device
|
||||
// does not support multiple themes
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
CheckBoxPreference dark_theme_pref = (CheckBoxPreference)findPreference("use_dark_theme");
|
||||
if (ThemeHelper.couldUseDarkTheme() == false)
|
||||
screen.removePreference(dark_theme_pref);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +217,10 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
{
|
||||
WebView view = (WebView)super.onCreateView(inflater, container, savedInstanceState);
|
||||
view.getSettings().setJavaScriptEnabled(true);
|
||||
String fontColor = getResources().getString(R.color.overlay_foreground_color);
|
||||
|
||||
TypedValue value = new TypedValue();
|
||||
getActivity().getTheme().resolveAttribute(R.attr.overlay_foreground_color, value, true);
|
||||
String fontColor = TypedValue.coerceToString(value.type, value.data);
|
||||
view.loadUrl("file:///android_asset/about.html?"+Uri.encode(fontColor));
|
||||
view.setBackgroundColor(Color.TRANSPARENT);
|
||||
return view;
|
||||
|
@ -40,11 +40,12 @@ public class ShowQueueActivity extends PlaybackActivity
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
ThemeHelper.setTheme(this, R.style.BackActionBar);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setTitle(R.string.queue);
|
||||
setContentView(R.layout.showqueue_listview);
|
||||
|
||||
|
||||
mService = PlaybackService.get(this);
|
||||
mListView = (DragSortListView) findViewById(R.id.list);
|
||||
listAdapter = new ShowQueueAdapter(this, R.layout.draggable_row);
|
||||
|
@ -44,7 +44,9 @@ public class TabOrderActivity extends Activity implements View.OnClickListener,
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
ThemeHelper.setTheme(this, R.style.BackActionBar);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setTitle(R.string.tabs);
|
||||
setContentView(R.layout.tab_order);
|
||||
|
||||
|
115
src/ch/blinkenlights/android/vanilla/ThemeHelper.java
Normal file
115
src/ch/blinkenlights/android/vanilla/ThemeHelper.java
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package ch.blinkenlights.android.vanilla;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
|
||||
public class ThemeHelper {
|
||||
|
||||
/**
|
||||
* Calls context.setTheme() with given theme.
|
||||
* Will automatically swap the theme with an alternative
|
||||
* version if the user requested us to use it
|
||||
*/
|
||||
final public static int setTheme(Context context, int theme)
|
||||
{
|
||||
if (usesDarkTheme(context)) {
|
||||
switch (theme) {
|
||||
case R.style.Playback:
|
||||
theme = R.style.Dark_Playback;
|
||||
break;
|
||||
case R.style.Library:
|
||||
theme = R.style.Dark_Library;
|
||||
break;
|
||||
case R.style.BackActionBar:
|
||||
theme = R.style.Dark_BackActionBar;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
context.setTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the correct play button drawable for our
|
||||
* notification: The notification does not depend on the theme but
|
||||
* depends on the API level
|
||||
*/
|
||||
final public static int getPlayButtonResource(boolean playing)
|
||||
{
|
||||
int playButton = 0;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// Android >= 5.0 uses the dark version of this drawable
|
||||
playButton = playing ? R.drawable.widget_pause : R.drawable.widget_play;
|
||||
} else {
|
||||
playButton = playing ? R.drawable.pause : R.drawable.play;
|
||||
}
|
||||
return playButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures (or unconfigures) the use of the black theme
|
||||
*/
|
||||
final public static void setDarkTheme(boolean enable)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if we should use the dark material theme,
|
||||
* Returns FALSE otherwise - always returns FALSE on pre-5.x devices
|
||||
*/
|
||||
final private static boolean usesDarkTheme(Context context)
|
||||
{
|
||||
boolean useDark = false;
|
||||
if(couldUseDarkTheme()) {
|
||||
SharedPreferences settings = PlaybackService.getSettings(context);
|
||||
useDark = settings.getBoolean(PrefKeys.USE_DARK_THEME, false);
|
||||
}
|
||||
return useDark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if this device may use the dark theme
|
||||
* (eg: running api v21 or later)
|
||||
*/
|
||||
final public static boolean couldUseDarkTheme() {
|
||||
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hacky function to get the colors needed to draw the default cover
|
||||
* These colors should actually be attributes, but getting them programatically
|
||||
* is a big mess
|
||||
*/
|
||||
final public static int[] getDefaultCoverColors(Context context) {
|
||||
int[] colors_holo_yolo = { 0xff000000, 0xff606060, 0xff404040, 0x88000000 };
|
||||
int[] colors_material_light = { 0xffeeeeee, 0xffd6d7d7, 0xffd6d7d7, 0x55ffffff };
|
||||
int[] colors_material_dark = { 0xff303030, 0xff606060, 0xff404040, 0x33ffffff };
|
||||
if (couldUseDarkTheme() == false)
|
||||
return colors_holo_yolo;
|
||||
if (usesDarkTheme(context))
|
||||
return colors_material_dark;
|
||||
// else
|
||||
return colors_material_light;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user