diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-09-02 17:08:50 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-09-02 17:08:50 -0700 |
commit | 2a3f49f2b61042cd57dbcc6d0acd7f8754fe534b (patch) | |
tree | e3016e759aa958c7b3baf6d83dfb4310e1883499 /app/src/main/java/github/daneren2005/dsub/activity | |
parent | d3cd581edd08ba9811aa4f87362ea81a02fe11db (diff) | |
download | dsub-2a3f49f2b61042cd57dbcc6d0acd7f8754fe534b.tar.gz dsub-2a3f49f2b61042cd57dbcc6d0acd7f8754fe534b.tar.bz2 dsub-2a3f49f2b61042cd57dbcc6d0acd7f8754fe534b.zip |
Fixes #656: Add Day/Night themes
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/activity')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java | 15 |
1 files changed, 10 insertions, 5 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() { |