From 0997eec5eb80b874933036e1b42b6fbd50196ee0 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Mon, 25 Nov 2013 16:11:14 -0800 Subject: Add full screen logic, immersive mode for KitKat --- .../dsub/activity/SubsonicActivity.java | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index c475d321..dc149def 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -610,25 +610,40 @@ 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")); + } + if ("dark".equals(theme)) { setTheme(R.style.Theme_DSub_Dark); } else if ("black".equals(theme)) { setTheme(R.style.Theme_DSub_Black); } else if ("light".equals(theme)) { setTheme(R.style.Theme_DSub_Light); - } else if ("dark_fullscreen".equals(theme)) { - setTheme(R.style.Theme_DSub_Dark_Fullscreen); - } else if ("black_fullscreen".equals(theme)) { - setTheme(R.style.Theme_DSub_Black_Fullscreen); - } else if ("light_fullscreen".equals(theme)) { - setTheme(R.style.Theme_DSub_Light_Fullscreen); - } else if("holo".equals(theme)) { - setTheme(R.style.Theme_DSub_Holo); - } else if("holo_fullscreen".equals(theme)) { - setTheme(R.style.Theme_DSub_Holo_Fullscreen); - }else { + } 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); + + // 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; + } + + getWindow().getDecorView().setSystemUiVisibility(flags); + } + } } public boolean isDestroyed() { -- cgit v1.2.3