[Android] VLCOptions: don't use any equalizer by default

Thomas Guillem git at videolan.org
Mon Oct 23 15:37:12 CEST 2017


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Oct 23 15:36:57 2017 +0200| [ec000500d2a5cd5606f2240d2fb42a89b37e5034] | committer: Thomas Guillem

VLCOptions: don't use any equalizer by default

> https://code.videolan.org/videolan/vlc-android/commit/ec000500d2a5cd5606f2240d2fb42a89b37e5034
---

 .../org/videolan/vlc/gui/audio/EqualizerFragment.java   |  2 +-
 vlc-android/src/org/videolan/vlc/util/VLCOptions.java   | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
index 48ffd2b0d..3b398e920 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.java
@@ -132,7 +132,7 @@ public class EqualizerFragment extends AppCompatDialogFragment implements Playba
         }
         allSets.add(newPresetName);
 
-        mEqualizer = VLCOptions.getEqualizerSetFromSettings(context);
+        mEqualizer = VLCOptions.getEqualizerSetFromSettings(context, true);
 
         // on/off
         binding.equalizerButton.setChecked(VLCOptions.getEqualizerEnabledState(context));
diff --git a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
index 47c857ec0..2751fc1b5 100644
--- a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
+++ b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
@@ -202,9 +202,7 @@ public class VLCOptions {
             media.addOption(":start-paused");
     }
 
-    @MainThread
-    public static MediaPlayer.Equalizer getEqualizerSetFromSettings(Context context) {
-        final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
+    private static MediaPlayer.Equalizer getEqualizerSetFromSettings(SharedPreferences pref) {
         final float[] bands = Preferences.getFloatArray(pref, "equalizer_values");
         if (bands != null && pref.contains("equalizer_enabled")) {
             final int bandCount = MediaPlayer.Equalizer.getBandCount();
@@ -221,6 +219,19 @@ public class VLCOptions {
     }
 
     @MainThread
+    public static MediaPlayer.Equalizer getEqualizerSetFromSettings(Context context, boolean force) {
+        final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
+        if (!force && !pref.getBoolean("equalizer_enabled", false))
+            return null;
+        return getEqualizerSetFromSettings(pref);
+    }
+
+    @MainThread
+    public static MediaPlayer.Equalizer getEqualizerSetFromSettings(Context context) {
+        return getEqualizerSetFromSettings(context, false);
+    }
+
+    @MainThread
     public static String getEqualizerNameFromSettings(Context context) {
         final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
         return pref.getString("equalizer_set", "Flat");



More information about the Android mailing list