[Android] Fix Advance Options dialogs themes

Alexandre Perraud git at videolan.org
Thu Jul 30 09:48:46 CEST 2015


vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Wed Jul 29 19:02:46 2015 +0200| [e561c78c22149d7f879fe17a4264a6a722df3739] | committer: Thomas Guillem

Fix Advance Options dialogs themes

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e561c78c22149d7f879fe17a4264a6a722df3739
---

 .../videolan/vlc/gui/dialogs/AdvOptionsDialog.java  |   15 ++++++++++-----
 .../videolan/vlc/gui/dialogs/JumpToTimeDialog.java  |   19 +++++++++++++++++++
 .../videolan/vlc/gui/dialogs/PickTimeFragment.java  |    6 ------
 .../vlc/gui/dialogs/PlaybackSpeedDialog.java        |   12 +++++++++++-
 .../vlc/gui/dialogs/SelectChapterDialog.java        |   12 +++++++++++-
 .../videolan/vlc/gui/dialogs/SleepTimerDialog.java  |   17 +++++++++++++++++
 vlc-android/src/org/videolan/vlc/util/Util.java     |    8 +++++++-
 7 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index 6865e18..bdd7914 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -74,6 +74,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
     public static final int ACTION_AUDIO_DELAY = 2 ;
     public static final int ACTION_SPU_DELAY = 3 ;
 
+    private int mTheme;
     private int mMode = -1;
     private TextView mAudioMode;
     private TextView mEqualizer;
@@ -100,13 +101,17 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setStyle(DialogFragment.STYLE_NO_FRAME, R.attr.advanced_options_style);
         if (VLCApplication.sPlayerSleepTime != null && VLCApplication.sPlayerSleepTime.before(Calendar.getInstance()))
             VLCApplication.sPlayerSleepTime = null;
         if (getArguments() != null && getArguments().containsKey(MODE_KEY))
             mMode = getArguments().getInt(MODE_KEY);
         else
             mMode = MODE_VIDEO;
+
+        mTheme = (mMode == MODE_VIDEO || Util.isBlackThemeEnabled()) ?
+                R.style.Theme_VLC_Black :
+                R.style.Theme_VLC;
+        setStyle(DialogFragment.STYLE_NO_FRAME, mTheme);
     }
 
     @Override
@@ -185,10 +190,10 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         DialogFragment newFragment = null;
         switch (action){
             case PickTimeFragment.ACTION_JUMP_TO_TIME:
-                newFragment = new JumpToTimeDialog();
+                newFragment = JumpToTimeDialog.newInstance(mTheme);
                 break;
             case PickTimeFragment.ACTION_SLEEP_TIMER:
-                newFragment = new SleepTimerDialog();
+                newFragment = SleepTimerDialog.newInstance(mTheme);
                 break;
             default:
                 return;
@@ -200,7 +205,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
 
     private void showPlayBackSpeedDialog() {
         DialogFragment newFragment = null;
-        newFragment = new PlaybackSpeedDialog();
+        newFragment = PlaybackSpeedDialog.newInstance(mTheme);
         if (newFragment != null)
             newFragment.show(getActivity().getSupportFragmentManager(), "playback_speed");
         dismiss();
@@ -208,7 +213,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
 
     private void showSelectChapterDialog() {
         DialogFragment newFragment = null;
-        newFragment = new SelectChapterDialog();
+        newFragment = SelectChapterDialog.newInstance(mTheme);
         if (newFragment != null)
             newFragment.show(getActivity().getSupportFragmentManager(), "select_chapter");
         dismiss();
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.java
index 21c6d32..0987cd8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.java
@@ -23,6 +23,9 @@
 
 package org.videolan.vlc.gui.dialogs;
 
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+
 import org.videolan.vlc.R;
 
 public class JumpToTimeDialog extends PickTimeFragment {
@@ -31,6 +34,22 @@ public class JumpToTimeDialog extends PickTimeFragment {
         super();
     }
 
+    public static JumpToTimeDialog newInstance(int theme) {
+        JumpToTimeDialog myFragment = new JumpToTimeDialog();
+
+        Bundle args = new Bundle();
+        args.putInt("theme", theme);
+        myFragment.setArguments(args);
+
+        return myFragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setStyle(DialogFragment.STYLE_NO_FRAME, getArguments().getInt("theme"));
+    }
+
     protected void executeAction() {
         if (mService == null)
             return;
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
index db2cf8e..69f7bef 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
@@ -62,12 +62,6 @@ public abstract class PickTimeFragment extends DialogFragment implements View.On
     }
 
     @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setStyle(DialogFragment.STYLE_NO_FRAME, R.attr.advanced_options_style);
-    }
-
-    @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.dialog_time_picker, container);
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
index 7d81c18..2a2500f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
@@ -51,10 +51,20 @@ public class PlaybackSpeedDialog extends DialogFragment implements PlaybackServi
     public PlaybackSpeedDialog() {
     }
 
+    public static PlaybackSpeedDialog newInstance(int theme) {
+        PlaybackSpeedDialog myFragment = new PlaybackSpeedDialog();
+
+        Bundle args = new Bundle();
+        args.putInt("theme", theme);
+        myFragment.setArguments(args);
+
+        return myFragment;
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setStyle(DialogFragment.STYLE_NO_FRAME, R.attr.advanced_options_style);
+        setStyle(DialogFragment.STYLE_NO_FRAME, getArguments().getInt("theme"));
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
index 0b8efc5..010492f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SelectChapterDialog.java
@@ -50,10 +50,20 @@ public class SelectChapterDialog extends DialogFragment implements PlaybackServi
     public SelectChapterDialog() {
     }
 
+    public static SelectChapterDialog newInstance(int theme) {
+        SelectChapterDialog myFragment = new SelectChapterDialog();
+
+        Bundle args = new Bundle();
+        args.putInt("theme", theme);
+        myFragment.setArguments(args);
+
+        return myFragment;
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setStyle(DialogFragment.STYLE_NO_FRAME, R.attr.advanced_options_style);
+        setStyle(DialogFragment.STYLE_NO_FRAME, getArguments().getInt("theme"));
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.java
index 9b6de8b..08507d7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.java
@@ -23,6 +23,7 @@
 package org.videolan.vlc.gui.dialogs;
 
 import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -39,6 +40,22 @@ public class SleepTimerDialog extends PickTimeFragment {
         super();
     }
 
+    public static SleepTimerDialog newInstance(int theme) {
+        SleepTimerDialog myFragment = new SleepTimerDialog();
+
+        Bundle args = new Bundle();
+        args.putInt("theme", theme);
+        myFragment.setArguments(args);
+
+        return myFragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setStyle(DialogFragment.STYLE_NO_FRAME, getArguments().getInt("theme"));
+    }
+
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index d0c2e96..2233231 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -32,6 +32,7 @@ import android.content.pm.ResolveInfo;
 import android.content.res.TypedArray;
 import android.net.Uri;
 import android.os.Build;
+import android.preference.PreferenceManager;
 import android.provider.MediaStore;
 import android.support.design.widget.Snackbar;
 import android.text.TextUtils.TruncateAt;
@@ -378,5 +379,10 @@ public class Util {
         List<ResolveInfo> list = VLCApplication.getAppContext().getPackageManager().queryIntentActivities(intent,
             PackageManager.MATCH_DEFAULT_ONLY);
         return list.size() > 0;
-}
+    }
+
+    public static boolean isBlackThemeEnabled() {
+        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
+        return pref.getBoolean("enable_black_theme", false);
+    }
 }



More information about the Android mailing list