[Android] Merge options for video playback in multitasking
Geoffrey Métais
git at videolan.org
Thu Jun 22 13:09:25 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jun 22 13:07:59 2017 +0200| [1ce967626f73fbfd09ba144829b906a7ac512038] | committer: Geoffrey Métais
Merge options for video playback in multitasking
> https://code.videolan.org/videolan/vlc-android/commit/1ce967626f73fbfd09ba144829b906a7ac512038
---
vlc-android/res/values/arrays.xml | 12 +++++++++++
vlc-android/res/values/strings.xml | 4 ++--
vlc-android/res/xml/preferences_video.xml | 19 ++++++----------
.../vlc/gui/preferences/PreferencesActivity.java | 2 +-
.../vlc/gui/preferences/PreferencesVideo.java | 25 ----------------------
.../vlc/gui/tv/preferences/PreferencesVideo.java | 2 +-
.../vlc/gui/video/VideoPlayerActivity.java | 4 ++--
7 files changed, 25 insertions(+), 43 deletions(-)
diff --git a/vlc-android/res/values/arrays.xml b/vlc-android/res/values/arrays.xml
index 0fba72e65..a7af28bc6 100644
--- a/vlc-android/res/values/arrays.xml
+++ b/vlc-android/res/values/arrays.xml
@@ -176,4 +176,16 @@
<item>65280</item>
</string-array>
+ <string-array name="video_app_switch_action_titles" translatable="false">
+ <item>@string/stop</item>
+ <item>@string/play_as_audio_background</item>
+ <item>@string/play_pip_title</item>
+ </string-array>
+
+ <string-array name="video_app_switch_action_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index efe99a954..6da8238ea 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -25,10 +25,10 @@
<string name="play_from_start">Play from start</string>
<string name="play_as_audio">Play as audio</string>
<string name="play_as_video">Play as video</string>
+ <string name="video_app_switch_title">Action on application switching</string>
+ <string name="video_app_switch_summary">Select VLC behavior when you switch to other application from video playback</string>
<string name="play_pip_title">Play videos in Picture-in-picture mode</string>
- <string name="play_pip_summary">Continue video playback in Picture-In-Picture mode when clicking HOME button or switching apps.</string>
<string name="play_as_audio_background">Play videos in background</string>
- <string name="play_as_audio_background_summary">Continue video playback in background when turning device screen off or clicking HOME button.</string>
<string name="append">Append</string>
<string name="insert_next">Insert next</string>
<string name="play_all">Play all</string>
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index 0ce149cee..58ee7b115 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -29,18 +29,13 @@
android:summary="@string/save_audiodelay_summary"
android:title="@string/save_audiodelay_title" />
- <CheckBoxPreference
- android:defaultValue="false"
- android:key="video_background"
- android:summary="@string/play_as_audio_background_summary"
- android:title="@string/play_as_audio_background" />
-
- <CheckBoxPreference
- android:defaultValue="false"
- android:key="video_home_pip"
- android:summary="@string/play_pip_summary"
- android:title="@string/play_pip_title" />
-
+ <ListPreference
+ android:key="video_action_switch"
+ android:defaultValue="0"
+ android:entries="@array/video_app_switch_action_titles"
+ android:entryValues="@array/video_app_switch_action_values"
+ android:summary="@string/video_app_switch_summary"
+ android:title="@string/video_app_switch_title" />
<PreferenceCategory android:title="@string/controls_prefs_category">
<CheckBoxPreference
android:defaultValue="false"
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
index 990f94073..66bde4590 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
@@ -42,7 +42,6 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static String VIDEO_PAUSED = "VideoPaused";
public final static String VIDEO_SUBTITLE_FILES = "VideoSubtitleFiles";
public final static String VIDEO_SPEED = "VideoSpeed";
- public final static String VIDEO_BACKGROUND = "video_background";
public final static String VIDEO_RESTORE = "video_restore";
public final static String VIDEO_RATE = "video_rate";
public final static String VIDEO_RATIO = "video_ratio";
@@ -50,6 +49,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static String LOGIN_STORE = "store_login";
public static final String KEY_AUDIO_PLAYBACK_RATE = "playback_rate";
public static final String KEY_AUDIO_PLAYBACK_SPEED_PERSIST = "playback_speed";
+ public final static String KEY_VIDEO_APP_SWITCH = "video_action_switch";
public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1;
public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
public final static int RESULT_RESTART_APP = RESULT_FIRST_USER + 3;
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
index bcadfaaf1..b4981d67e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
@@ -22,11 +22,8 @@
package org.videolan.vlc.gui.preferences;
-import android.os.Bundle;
-import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
-import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
public class PreferencesVideo extends BasePreferenceFragment {
@@ -42,20 +39,6 @@ public class PreferencesVideo extends BasePreferenceFragment {
}
@Override
- public void onStart() {
- super.onStart();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- CheckBoxPreference pip = (CheckBoxPreference) findPreference("video_home_pip");
- CheckBoxPreference background = (CheckBoxPreference) findPreference("video_background");
- pip.setEnabled(!background.isChecked());
- background.setEnabled(!pip.isChecked());
- }
-
- @Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey() == null)
return false;
@@ -66,14 +49,6 @@ public class PreferencesVideo extends BasePreferenceFragment {
case "force_list_portrait":
((PreferencesActivity) getActivity()).setRestart();
return true;
- case "video_home_pip":
- findPreference("video_background").setEnabled(!((CheckBoxPreference)preference).isChecked());
- return true;
- case "video_background":
- if (!AndroidUtil.isOOrLater)
- return false;
- findPreference("video_home_pip").setEnabled(!((CheckBoxPreference)preference).isChecked());
- return true;
}
return super.onPreferenceTreeClick(preference);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
index a873da5d0..53eebef2c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
@@ -54,7 +54,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("popup_keepscreen").setVisible(false);
- findPreference("video_home_pip").setVisible(AndroidDevices.isAndroidTv());
+ findPreference("video_action_switch").setVisible(AndroidDevices.hasPiP);
}
@Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 5314ea3f8..99e807ec0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -592,7 +592,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
(AndroidUtil.isNougatOrLater && !AndroidUtil.isOOrLater //Video on background on Nougat Android TVs
&& AndroidDevices.isAndroidTv() && !requestVisibleBehind(true)))
stopPlayback();
- else if (mSettings.getBoolean("video_home_pip", false) && isInteractive()) {
+ else if ("2".equals(mSettings.getString(PreferencesActivity.KEY_VIDEO_APP_SWITCH, "0")) && isInteractive()) {
switchToPopup();
}
}
@@ -695,7 +695,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mAlertDialog != null && mAlertDialog.isShowing())
mAlertDialog.dismiss();
if (!isFinishing() && mService != null && mService.isPlaying() &&
- mSettings.getBoolean(PreferencesActivity.VIDEO_BACKGROUND, false)) {
+ "1".equals(mSettings.getString(PreferencesActivity.KEY_VIDEO_APP_SWITCH, "0"))) {
switchToAudioMode(false);
}
More information about the Android
mailing list