aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-25 21:06:36 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-25 21:06:36 -0800
commite5dbae103f57baa2baafbc552f0dfcb1006513a8 (patch)
tree1442eb4ad332216a4496bf0488026701cb57a91f /src
parentf0f408b8ff442fd4ae7cd4e22f0bf7cd58d00256 (diff)
downloaddsub-e5dbae103f57baa2baafbc552f0dfcb1006513a8.tar.gz
dsub-e5dbae103f57baa2baafbc552f0dfcb1006513a8.tar.bz2
dsub-e5dbae103f57baa2baafbc552f0dfcb1006513a8.zip
Fix immersive mode implementation
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java14
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java37
-rw-r--r--src/github/daneren2005/dsub/util/Util.java5
3 files changed, 26 insertions, 30 deletions
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 4dac82bd..49a5f15b 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -380,7 +380,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
return screen;
}
-
+
private void applyTheme() {
String activeTheme = Util.getTheme(this);
if ("dark".equals(activeTheme)) {
@@ -389,17 +389,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
setTheme(R.style.Theme_DSub_Black);
} else if ("light".equals(activeTheme)) {
setTheme(R.style.Theme_DSub_Light);
- } else if ("dark_fullscreen".equals(activeTheme)) {
- setTheme(R.style.Theme_DSub_Dark_Fullscreen);
- } else if ("black_fullscreen".equals(activeTheme)) {
- setTheme(R.style.Theme_DSub_Black_Fullscreen);
- } else if ("light_fullscreen".equals(activeTheme)) {
- setTheme(R.style.Theme_DSub_Light_Fullscreen);
- } else if("holo".equals(activeTheme)) {
- setTheme(R.style.Theme_DSub_Holo);
- } else if("holo_fullscreen".equals(activeTheme)) {
- setTheme(R.style.Theme_DSub_Holo_Fullscreen);
- }else {
+ } else {
setTheme(R.style.Theme_DSub_Holo);
}
}
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index dc149def..78ed14f3 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -45,6 +45,8 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
@@ -73,6 +75,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private static final String TAG = SubsonicActivity.class.getSimpleName();
private static ImageLoader IMAGE_LOADER;
protected static String theme;
+ protected static boolean fullScreen;
private String[] drawerItemsDescriptions;
private String[] drawerItems;
private boolean drawerIdle = true;
@@ -98,6 +101,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
setUncaughtExceptionHandler();
applyTheme();
super.onCreate(bundle);
+ applyFullscreen();
startService(new Intent(this, DownloadServiceImpl.class));
setVolumeControlStream(AudioManager.STREAM_MUSIC);
@@ -126,7 +130,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
Util.registerMediaButtonEventReceiver(this);
// Make sure to update theme
- if (theme != null && !theme.equals(Util.getTheme(this))) {
+ if (theme != null && !theme.equals(Util.getTheme(this)) || fullScreen != Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false)) {
restart();
}
@@ -610,9 +614,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private void applyTheme() {
theme = Util.getTheme(this);
-
+
if(theme != null && theme.indexOf("fullscreen") != -1) {
theme = theme.substring(0, theme.indexOf("_fullscreen"));
+ Util.setTheme(this, theme);
}
if ("dark".equals(theme)) {
@@ -624,25 +629,21 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
} else {
setTheme(R.style.Theme_DSub_Holo);
}
-
- if(Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false)) {
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
+ }
+ private void applyFullscreen() {
+ fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
+ if(fullScreen) {
// Hide additional elements on higher Android versions
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
- View.SYSTEM_UI_FLAG_FULLSCREEN;
-
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- flags = flags | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
- }
-
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_FULLSCREEN |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+
getWindow().getDecorView().setSystemUiVisibility(flags);
+ } else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index ce6ba914..83e8deee 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -279,6 +279,11 @@ public final class Util {
SharedPreferences prefs = getPreferences(context);
return prefs.getString(Constants.PREFERENCES_KEY_THEME, null);
}
+ 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 boolean getDisplayTrack(Context context) {
SharedPreferences prefs = getPreferences(context);