summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2022-02-22 19:54:05 +0100
committerGitHub <noreply@github.com>2022-02-22 19:54:05 +0100
commit2f3efa5d3383732b52a4d9bf78b1b7502573151f (patch)
treefc33b53adc1c7e228150680ddc132250a86a6b3b
parentbe9093911ff5aac392e483a61e5aaca38782d723 (diff)
parent372db47f47d595deaffe0fd86b5f9dd1629f23b8 (diff)
downloadAntennaPod-2f3efa5d3383732b52a4d9bf78b1b7502573151f.zip
Merge pull request #5740 from ByteHamster/upon-exiting-video
Make it easier to play only audio, not video
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java18
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java6
-rw-r--r--app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java3
-rw-r--r--app/src/main/res/menu/mediaplayer.xml8
-rw-r--r--app/src/main/res/xml/preferences_playback.xml7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java14
-rw-r--r--core/src/main/res/values/arrays.xml22
-rw-r--r--core/src/main/res/values/strings.xml6
8 files changed, 13 insertions, 71 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 4ff2a5775..954a6c2f6 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -91,6 +91,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
private PlaybackController controller;
private boolean showTimeLeft = false;
private boolean isFavorite = false;
+ private boolean switchToAudioOnly = false;
private Disposable disposable;
private float prog;
@@ -119,6 +120,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
protected void onResume() {
super.onResume();
StorageUtils.checkStorageAvailability(this);
+ switchToAudioOnly = false;
if (PlaybackService.isCasting()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
@@ -149,8 +151,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
@Override
public void onUserLeaveHint() {
- if (!PictureInPictureUtil.isInPictureInPictureMode(this) && UserPreferences.getVideoBackgroundBehavior()
- == UserPreferences.VideoBackgroundBehavior.PICTURE_IN_PICTURE) {
+ if (!PictureInPictureUtil.isInPictureInPictureMode(this)) {
compatEnterPictureInPicture();
}
}
@@ -480,9 +481,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "Videosurface was destroyed");
videoSurfaceCreated = false;
- if (controller != null && !destroyingDueToReload
- && UserPreferences.getVideoBackgroundBehavior()
- != UserPreferences.VideoBackgroundBehavior.CONTINUE_PLAYING) {
+ if (controller != null && !destroyingDueToReload && !switchToAudioOnly) {
controller.notifyVideoSurfaceAbandoned();
}
}
@@ -590,17 +589,16 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
menu.findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
menu.findItem(R.id.disable_sleeptimer_item).setVisible(controller.sleepTimerActive());
- if (PictureInPictureUtil.supportsPictureInPicture(this)) {
- menu.findItem(R.id.player_go_to_picture_in_picture).setVisible(true);
- }
+ menu.findItem(R.id.player_switch_to_audio_only).setVisible(true);
menu.findItem(R.id.audio_controls).setIcon(R.drawable.ic_sliders);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.player_go_to_picture_in_picture) {
- compatEnterPictureInPicture();
+ if (item.getItemId() == R.id.player_switch_to_audio_only) {
+ switchToAudioOnly = true;
+ finish();
return true;
}
if (item.getItemId() == android.R.id.home) {
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
index 7fa2ed4d1..933a7d456 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/PlaybackPreferencesFragment.java
@@ -13,7 +13,6 @@ import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
import de.danoeh.antennapod.core.preferences.UsageStatistics;
import de.danoeh.antennapod.core.preferences.UserPreferences;
-import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
import de.danoeh.antennapod.dialog.SkipPreferenceDialog;
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
import java.util.Map;
@@ -54,11 +53,6 @@ public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
SkipPreferenceDialog.showSkipPreference(activity, SkipPreferenceDialog.SkipDirection.SKIP_FORWARD, null);
return true;
});
- if (!PictureInPictureUtil.supportsPictureInPicture(activity)) {
- ListPreference behaviour = findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR);
- behaviour.setEntries(R.array.video_background_behavior_options_without_pip);
- behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
- }
findPreference(PREF_PLAYBACK_PREFER_STREAMING).setOnPreferenceChangeListener((preference, newValue) -> {
// Update all visible lists to reflect new streaming action button
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java
index 3a0e4e91f..a2c5ca3ff 100644
--- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java
+++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java
@@ -90,9 +90,6 @@ public class PreferenceUpgrader {
UserPreferences.setEnqueueLocation(enqueueLocation);
}
}
- if (oldVersion < 1080100) {
- prefs.edit().putString(UserPreferences.PREF_VIDEO_BEHAVIOR, "pip").apply();
- }
if (oldVersion < 2010300) {
// Migrate hardware button preferences
if (prefs.getBoolean("prefHardwareForwardButtonSkips", false)) {
diff --git a/app/src/main/res/menu/mediaplayer.xml b/app/src/main/res/menu/mediaplayer.xml
index a9f15317b..e25872ade 100644
--- a/app/src/main/res/menu/mediaplayer.xml
+++ b/app/src/main/res/menu/mediaplayer.xml
@@ -52,10 +52,10 @@
</item>
<item
- android:id="@+id/player_go_to_picture_in_picture"
- custom:showAsAction="collapseActionView"
- android:title="@string/player_go_to_picture_in_picture"
- android:visible="false">
+ android:id="@+id/player_switch_to_audio_only"
+ custom:showAsAction="collapseActionView"
+ android:title="@string/player_switch_to_audio_only"
+ android:visible="false">
</item>
<item
diff --git a/app/src/main/res/xml/preferences_playback.xml b/app/src/main/res/xml/preferences_playback.xml
index add9e8d4c..969013056 100644
--- a/app/src/main/res/xml/preferences_playback.xml
+++ b/app/src/main/res/xml/preferences_playback.xml
@@ -34,13 +34,6 @@
android:key="prefResumeAfterCall"
android:summary="@string/pref_resumeAfterCall_sum"
android:title="@string/pref_resumeAfterCall_title"/>
- <ListPreference
- android:defaultValue="pip"
- android:entries="@array/video_background_behavior_options"
- android:entryValues="@array/video_background_behavior_values"
- android:key="prefVideoBehavior"
- android:summary="@string/pref_videoBehavior_sum"
- android:title="@string/pref_videoBehavior_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/playback_control">
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 357ea0b61..82ad27dcd 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -87,7 +87,6 @@ public class UserPreferences {
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss";
private static final String PREF_RESUME_AFTER_CALL = "prefResumeAfterCall";
- public static final String PREF_VIDEO_BEHAVIOR = "prefVideoBehavior";
private static final String PREF_TIME_RESPECTS_SPEED = "prefPlaybackTimeRespectsSpeed";
public static final String PREF_STREAM_OVER_DOWNLOAD = "prefStreamOverDownload";
@@ -846,15 +845,6 @@ public class UserPreferences {
.apply();
}
- public static VideoBackgroundBehavior getVideoBackgroundBehavior() {
- switch (prefs.getString(PREF_VIDEO_BEHAVIOR, "pip")) {
- case "stop": return VideoBackgroundBehavior.STOP;
- case "continue": return VideoBackgroundBehavior.CONTINUE_PLAYING;
- case "pip": //Deliberate fall-through
- default: return VideoBackgroundBehavior.PICTURE_IN_PICTURE;
- }
- }
-
public static EpisodeCleanupAlgorithm getEpisodeCleanupAlgorithm() {
if (!isEnableAutodownload()) {
return new APNullCleanupAlgorithm();
@@ -973,10 +963,6 @@ public class UserPreferences {
return prefs.getBoolean(PREF_CAST_ENABLED, false);
}
- public enum VideoBackgroundBehavior {
- STOP, PICTURE_IN_PICTURE, CONTINUE_PLAYING
- }
-
public enum BackButtonBehavior {
DEFAULT, OPEN_DRAWER, DOUBLE_TAP, SHOW_PROMPT, GO_TO_PAGE
}
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index de83bbf59..f3cf4361d 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -247,28 +247,6 @@
<item>@string/skip_episode_label</item>
</string-array>
- <string-array name="video_background_behavior_options">
- <item>@string/stop_playback</item>
- <item>@string/player_go_to_picture_in_picture</item>
- <item>@string/continue_playback</item>
- </string-array>
-
- <string-array name="video_background_behavior_values">
- <item>stop</item>
- <item>pip</item>
- <item>continue</item>
- </string-array>
-
- <string-array name="video_background_behavior_options_without_pip">
- <item>@string/stop_playback</item>
- <item>@string/continue_playback</item>
- </string-array>
-
- <string-array name="video_background_behavior_values_without_pip">
- <item>stop</item>
- <item>continue</item>
- </string-array>
-
<string-array name="back_button_behavior_options">
<item>@string/back_button_default</item>
<item>@string/back_button_go_to_page</item>
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 783065178..197d0c636 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -304,7 +304,6 @@
<string name="playback_error_unknown">Unknown Error</string>
<string name="no_media_playing_label">No media playing</string>
<string name="position_default_label" translatable="false">00:00:00</string>
- <string name="player_go_to_picture_in_picture">Picture-in-picture mode</string>
<string name="unknown_media_key">AntennaPod - Unknown media key: %1$d</string>
<string name="error_file_not_found">File not found</string>
<string name="no_media_label">Item does not contain a media file</string>
@@ -513,10 +512,6 @@
<string name="media_player_switch_to_exoplayer">Switch to ExoPlayer</string>
<string name="media_player_switched_to_exoplayer">Switched to ExoPlayer.</string>
<string name="pref_skip_silence_title">Skip Silence in Audio</string>
- <string name="pref_videoBehavior_title">Upon exiting video</string>
- <string name="pref_videoBehavior_sum">Behavior when leaving video playback</string>
- <string name="stop_playback">Stop playback</string>
- <string name="continue_playback">Continue audio playback</string>
<string name="behavior">Behavior</string>
<string name="pref_back_button_behavior_title">Back Button Behavior</string>
<string name="pref_back_button_behavior_sum">Change behavior of the back button.</string>
@@ -794,6 +789,7 @@
<string name="stereo_to_mono">Downmix: Stereo to mono</string>
<string name="sonic_only">Sonic only</string>
<string name="exoplayer_only">ExoPlayer only</string>
+ <string name="player_switch_to_audio_only">Switch to audio only</string>
<!-- proxy settings -->
<string name="proxy_type_label">Type</string>