aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java15
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/ThemeUtil.java112
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java59
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/SongView.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteChooserDialogFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteControllerDialogFragment.java3
-rw-r--r--app/src/main/res/values/arrays.xml4
-rw-r--r--app/src/main/res/values/strings.xml2
8 files changed, 134 insertions, 67 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
index d987f403..8882ad98 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -80,6 +80,7 @@ import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.DrawableTint;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.SilentBackgroundTask;
+import github.daneren2005.dsub.util.ThemeUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.util.UserUtil;
@@ -123,6 +124,10 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
boolean drawerOpen = false;
SharedPreferences.OnSharedPreferenceChangeListener preferencesListener;
+ static {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
+ }
+
@Override
protected void onCreate(Bundle bundle) {
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
@@ -216,7 +221,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
protected void createCustomActionBarView() {
actionBarSpinner = (Spinner) getLayoutInflater().inflate(R.layout.actionbar_spinner, null);
- if((this instanceof SubsonicFragmentActivity || this instanceof SettingsActivity) && (Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true) || Util.getThemeRes(this) != R.style.Theme_DSub_Light_No_Color)) {
+ if((this instanceof SubsonicFragmentActivity || this instanceof SettingsActivity) && (Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true) || ThemeUtil.getThemeRes(this) != R.style.Theme_DSub_Light_No_Color)) {
actionBarSpinner.setBackgroundDrawable(DrawableTint.getTintedDrawableFromColor(this, R.drawable.abc_spinner_mtrl_am_alpha, android.R.color.white));
}
spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
@@ -234,7 +239,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
// Make sure to update theme
SharedPreferences prefs = Util.getPreferences(this);
- if (theme != null && !theme.equals(Util.getTheme(this)) || fullScreen != prefs.getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false) || actionbarColored != prefs.getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true)) {
+ if (theme != null && !theme.equals(ThemeUtil.getTheme(this)) || fullScreen != prefs.getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false) || actionbarColored != prefs.getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true)) {
restart();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
DrawableTint.wipeTintCache();
@@ -922,14 +927,14 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
}
private void applyTheme() {
- theme = Util.getTheme(this);
+ theme = ThemeUtil.getTheme(this);
if(theme != null && theme.indexOf("fullscreen") != -1) {
theme = theme.substring(0, theme.indexOf("_fullscreen"));
- Util.setTheme(this, theme);
+ ThemeUtil.setTheme(this, theme);
}
- Util.applyTheme(this, theme);
+ ThemeUtil.applyTheme(this, theme);
actionbarColored = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true);
}
private void applyFullscreen() {
diff --git a/app/src/main/java/github/daneren2005/dsub/util/ThemeUtil.java b/app/src/main/java/github/daneren2005/dsub/util/ThemeUtil.java
new file mode 100644
index 00000000..7de4f928
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/util/ThemeUtil.java
@@ -0,0 +1,112 @@
+/*
+ This file is part of Subsonic.
+ Subsonic 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.
+ Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2016 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+
+import java.util.Locale;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.activity.SettingsActivity;
+import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
+
+public final class ThemeUtil {
+ public static final String THEME_DARK = "dark";
+ public static final String THEME_BLACK = "black";
+ public static final String THEME_LIGHT = "light";
+ public static final String THEME_HOLO = "holo";
+ public static final String THEME_DAY_NIGHT = "day/night";
+ public static final String THEME_DAY_BLACK_NIGHT = "day/black";
+
+ public static String getTheme(Context context) {
+ SharedPreferences prefs = Util.getPreferences(context);
+ String theme = prefs.getString(Constants.PREFERENCES_KEY_THEME, null);
+
+ if(THEME_DAY_NIGHT.equals(theme)) {
+ int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ if(currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
+ theme = THEME_DARK;
+ } else {
+ theme = THEME_LIGHT;
+ }
+ } else if(THEME_DAY_BLACK_NIGHT.equals(theme)) {
+ int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ if(currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
+ theme = THEME_BLACK;
+ } else {
+ theme = THEME_LIGHT;
+ }
+ }
+
+ return theme;
+ }
+ public static int getThemeRes(Context context) {
+ return getThemeRes(context, getTheme(context));
+ }
+ public static int getThemeRes(Context context, String theme) {
+ if(context instanceof SubsonicFragmentActivity || context instanceof SettingsActivity) {
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true)) {
+ if (THEME_DARK.equals(theme)) {
+ return R.style.Theme_DSub_Dark_No_Actionbar;
+ } else if (THEME_BLACK.equals(theme)) {
+ return R.style.Theme_DSub_Black_No_Actionbar;
+ } else if (THEME_HOLO.equals(theme)) {
+ return R.style.Theme_DSub_Holo_No_Actionbar;
+ } else {
+ return R.style.Theme_DSub_Light_No_Actionbar;
+ }
+ } else {
+ if (THEME_DARK.equals(theme)) {
+ return R.style.Theme_DSub_Dark_No_Color;
+ } else if (THEME_BLACK.equals(theme)) {
+ return R.style.Theme_DSub_Black_No_Color;
+ } else if (THEME_HOLO.equals(theme)) {
+ return R.style.Theme_DSub_Holo_No_Color;
+ } else {
+ return R.style.Theme_DSub_Light_No_Color;
+ }
+ }
+ } else {
+ if (THEME_DARK.equals(theme)) {
+ return R.style.Theme_DSub_Dark;
+ } else if (THEME_BLACK.equals(theme)) {
+ return R.style.Theme_DSub_Black;
+ } else if (THEME_HOLO.equals(theme)) {
+ return R.style.Theme_DSub_Holo;
+ } else {
+ return R.style.Theme_DSub_Light;
+ }
+ }
+ }
+ public static void setTheme(Context context, String theme) {
+ SharedPreferences.Editor editor = Util.getPreferences(context).edit();
+ editor.putString(Constants.PREFERENCES_KEY_THEME, theme);
+ editor.commit();
+ }
+
+ public static void applyTheme(Context context, String theme) {
+ context.setTheme(getThemeRes(context, theme));
+
+ SharedPreferences prefs = Util.getPreferences(context);
+ if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) {
+ Configuration config = new Configuration();
+ config.locale = Locale.ENGLISH;
+ context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
+ }
+ }
+}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index 759c6799..b1f1617d 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -274,65 +274,6 @@ public final class Util {
editor.putBoolean(Constants.PREFERENCES_KEY_ALBUMS_PER_FOLDER + instance, perFolder);
editor.commit();
}
-
- public static String getTheme(Context context) {
- SharedPreferences prefs = getPreferences(context);
- return prefs.getString(Constants.PREFERENCES_KEY_THEME, null);
- }
- public static int getThemeRes(Context context) {
- return getThemeRes(context, getTheme(context));
- }
- public static int getThemeRes(Context context, String theme) {
- if(context instanceof SubsonicFragmentActivity || context instanceof SettingsActivity) {
- if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true)) {
- if ("dark".equals(theme)) {
- return R.style.Theme_DSub_Dark_No_Actionbar;
- } else if ("black".equals(theme)) {
- return R.style.Theme_DSub_Black_No_Actionbar;
- } else if ("holo".equals(theme)) {
- return R.style.Theme_DSub_Holo_No_Actionbar;
- } else {
- return R.style.Theme_DSub_Light_No_Actionbar;
- }
- } else {
- if ("dark".equals(theme)) {
- return R.style.Theme_DSub_Dark_No_Color;
- } else if ("black".equals(theme)) {
- return R.style.Theme_DSub_Black_No_Color;
- } else if ("holo".equals(theme)) {
- return R.style.Theme_DSub_Holo_No_Color;
- } else {
- return R.style.Theme_DSub_Light_No_Color;
- }
- }
- } else {
- if ("dark".equals(theme)) {
- return R.style.Theme_DSub_Dark;
- } else if ("black".equals(theme)) {
- return R.style.Theme_DSub_Black;
- } else if ("holo".equals(theme)) {
- return R.style.Theme_DSub_Holo;
- } else {
- return R.style.Theme_DSub_Light;
- }
- }
- }
- public static void setTheme(Context context, String theme) {
- SharedPreferences.Editor editor = getPreferences(context).edit();
- editor.putString(Constants.PREFERENCES_KEY_THEME, theme);
- editor.commit();
- }
-
- public static void applyTheme(Context context, String theme) {
- context.setTheme(getThemeRes(context, theme));
-
- SharedPreferences prefs = Util.getPreferences(context);
- if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) {
- Configuration config = new Configuration();
- config.locale = Locale.ENGLISH;
- context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
- }
- }
public static boolean getDisplayTrack(Context context) {
SharedPreferences prefs = getPreferences(context);
diff --git a/app/src/main/java/github/daneren2005/dsub/view/SongView.java b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
index 8cb0c21c..7a02c91d 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/SongView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
@@ -30,6 +30,7 @@ import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.util.DrawableTint;
import github.daneren2005.dsub.util.SongDBHandler;
+import github.daneren2005.dsub.util.ThemeUtil;
import github.daneren2005.dsub.util.Util;
import java.io.File;
@@ -336,7 +337,7 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
if(isRated == 1) {
this.setBackgroundColor(Color.RED);
- String theme = Util.getTheme(context);
+ String theme = ThemeUtil.getTheme(context);
if("black".equals(theme)) {
this.getBackground().setAlpha(80);
} else if("dark".equals(theme) || "holo".equals(theme)) {
diff --git a/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteChooserDialogFragment.java b/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteChooserDialogFragment.java
index da9b135f..a2c898b9 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteChooserDialogFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteChooserDialogFragment.java
@@ -5,11 +5,12 @@ import android.os.Bundle;
import android.support.v7.app.MediaRouteChooserDialog;
import android.support.v7.app.MediaRouteChooserDialogFragment;
+import github.daneren2005.dsub.util.ThemeUtil;
import github.daneren2005.dsub.util.Util;
public class CustomMediaRouteChooserDialogFragment extends MediaRouteChooserDialogFragment {
@Override
public MediaRouteChooserDialog onCreateChooserDialog(Context context, Bundle savedInstanceState) {
- return new MediaRouteChooserDialog(context, Util.getThemeRes(context));
+ return new MediaRouteChooserDialog(context, ThemeUtil.getThemeRes(context));
}
}
diff --git a/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteControllerDialogFragment.java b/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteControllerDialogFragment.java
index 7fd54142..ea890b9f 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteControllerDialogFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/compat/CustomMediaRouteControllerDialogFragment.java
@@ -5,11 +5,12 @@ import android.os.Bundle;
import android.support.v7.app.MediaRouteControllerDialog;
import android.support.v7.app.MediaRouteControllerDialogFragment;
+import github.daneren2005.dsub.util.ThemeUtil;
import github.daneren2005.dsub.util.Util;
public class CustomMediaRouteControllerDialogFragment extends MediaRouteControllerDialogFragment {
@Override
public MediaRouteControllerDialog onCreateControllerDialog(Context context, Bundle savedInstanceState) {
- return new MediaRouteControllerDialog(context, Util.getThemeRes(context));
+ return new MediaRouteControllerDialog(context, ThemeUtil.getThemeRes(context));
}
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 01296e9e..ee246d16 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -25,6 +25,8 @@
<item>dark</item>
<item>black</item>
<item>holo</item>
+ <item>day/night</item>
+ <item>day/black</item>
</string-array>
<string-array name="themeNames">
@@ -32,6 +34,8 @@
<item>@string/settings.theme_dark</item>
<item>@string/settings.theme_black</item>
<item>@string/settings.theme_holo</item>
+ <item>@string/settings.theme_day_night</item>
+ <item>@string/settings.theme_day_black_night</item>
</string-array>
<string-array name="sleepTimerValues">
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 92d0bb8a..c15a5d3e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -306,6 +306,8 @@
<string name="settings.theme_dark">Dark</string>
<string name="settings.theme_black">Black</string>
<string name="settings.theme_holo">Holo</string>
+ <string name="settings.theme_day_night">Day/Night</string>
+ <string name="settings.theme_day_black_night">Day/Black Night</string>
<string name="settings.theme_fullscreen">Fullscreen</string>
<string name="settings.theme_fullscreen_summary">Hide as many UI elements as Android will allow</string>
<string name="settings.track_title">Display Track #</string>