[Android] Preferences : Modify headset behaviour preference

Alexandre Perraud git at videolan.org
Thu Jul 21 14:51:01 CEST 2016


vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu Jul 21 13:30:57 2016 +0200| [bf92cc3e6da4983800603546120968550ac5ff74] | committer: Alexandre Perraud

Preferences : Modify headset behaviour preference

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

 vlc-android/res/values/strings.xml                                   | 4 +++-
 vlc-android/res/xml/preferences_ui.xml                               | 5 +++++
 vlc-android/src/org/videolan/vlc/PlaybackService.java                | 2 +-
 vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java  | 2 ++
 .../src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java       | 1 +
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 66e9088..bd16c05 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -285,7 +285,9 @@
     <string name="force_list_portrait_summary">Show videos in list instead of grid in portrait mode</string>
     <string name="audio_title_alignment">Audio title alignment</string>
     <string name="enable_headset_detection">Detect headset</string>
-    <string name="enable_headset_detection_summary">Pause on headset removal; resume on headset insertion</string>
+    <string name="enable_headset_detection_summary">Detect headset insertion and removal</string>
+    <string name="enable_play_on_headset_insertion">Resume on headset insertion</string>
+    <string name="enable_play_on_headset_insertion_summary">Pause otherwise</string>
     <string name="enable_steal_remote_control">Exclusive headset remote control</string>
     <string name="enable_steal_remote_control_summary">Avoid conflicts by stealing the remote control from other apps. This prevents dialing on double click on HTC phones.</string>
     <string name="audio_title_alignment_default">Default</string>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index ad05565..b711f65 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -74,6 +74,11 @@
             android:summary="@string/enable_headset_detection_summary"
             android:title="@string/enable_headset_detection" />
         <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="enable_play_on_headset_insertion"
+            android:summary="@string/enable_play_on_headset_insertion_summary"
+            android:title="@string/enable_play_on_headset_insertion" />
+        <CheckBoxPreference
             android:defaultValue="false"
             android:key="enable_steal_remote_control"
             android:summary="@string/enable_steal_remote_control_summary"
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 26f19f5..492744e 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -511,7 +511,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                         pause();
                 } else if (action.equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG) && state != 0) {
                     Log.i(TAG, "Headset Inserted.");
-                    if (wasPlaying && hasCurrentMedia())
+                    if (wasPlaying && hasCurrentMedia() && mSettings.getBoolean("enable_play_on_headset_insertion", false))
                         play();
                 }
             }
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
index f27591f..69d0ba9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
@@ -57,6 +57,7 @@ public class PreferencesUi extends BasePreferenceFragment implements SharedPrefe
 
         findPreference("tv_ui").setVisible(AndroidUtil.isJellyBeanMR1OrLater());
         findPreference("languages_download_list").setVisible(AndroidUtil.isHoneycombOrLater());
+        findPreference("enable_play_on_headset_insertion").setVisible(((TwoStatePreference) findPreference("enable_headset_detection")).isChecked());
     }
 
     @Override
@@ -81,6 +82,7 @@ public class PreferencesUi extends BasePreferenceFragment implements SharedPrefe
                 return true;
             case "enable_headset_detection":
                 ((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
+                findPreference("enable_play_on_headset_insertion").setVisible(((TwoStatePreference) preference).isChecked());
                 return true;
             case "enable_steal_remote_control":
                 PlaybackService.Client.restartService(getActivity());
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
index 433ddc3..4f7eb67 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
@@ -53,6 +53,7 @@ public class PreferencesUi extends BasePreferenceFragment {
         findPreference("enable_clone_mode").setVisible(false);
         findPreference("force_list_portrait").setVisible(false);
         findPreference("enable_headset_detection").setVisible(false);
+        findPreference("enable_play_on_headset_insertion").setVisible(false);
         findPreference("enable_steal_remote_control").setVisible(false);
         findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
         findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());



More information about the Android mailing list