[Android] Repeat is now auto saved and shared between audio and video
Nicolas Pomepuy
git at videolan.org
Tue Sep 10 15:30:39 CEST 2019
vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Sep 10 10:06:26 2019 +0200| [1954a636f80dea32a25580daf56542c81ab987e8] | committer: Geoffrey Métais
Repeat is now auto saved and shared between audio and video
(cherry picked from commit e6e8a001cefdbe0087218bb520f532925bd05198)
> https://code.videolan.org/videolan/vlc-android/commit/1954a636f80dea32a25580daf56542c81ab987e8
---
vlc-android/res/values/strings.xml | 3 ---
vlc-android/res/xml/preferences_audio.xml | 6 ------
vlc-android/res/xml/preferences_video.xml | 7 ------
.../src/org/videolan/vlc/media/PlaylistManager.kt | 25 ++++------------------
4 files changed, 4 insertions(+), 37 deletions(-)
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 8a1a32535..44345b65e 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -374,9 +374,6 @@
<string name="list_title_ellipsize_right">Right</string>
<string name="list_title_ellipsize_middle">Middle</string>
<string name="list_title_ellipsize_marquee">Marquee</string>
- <string name="audio_save_repeat_title">Save repeat mode</string>
- <string name="audio_save_repeat_summary">Remember repeat mode when loading audio playlists</string>
- <string name="video_save_repeat_summary">Remember repeat mode when loading video playlists</string>
<string name="audio_boost_title">Audio-boost</string>
<string name="audio_boost_summary">Allow volume up to 200%</string>
<string name="headset_prefs_category">Headset</string>
diff --git a/vlc-android/res/xml/preferences_audio.xml b/vlc-android/res/xml/preferences_audio.xml
index 7280eaa91..0ecd2b773 100644
--- a/vlc-android/res/xml/preferences_audio.xml
+++ b/vlc-android/res/xml/preferences_audio.xml
@@ -30,12 +30,6 @@
android:defaultValue="false"
android:key="audio_digital_output"
android:title="@string/audio_digital_title"/>
- <CheckBoxPreference
- app:singleLineTitle="false"
- android:defaultValue="false"
- android:key="audio_save_repeat"
- android:summary="@string/audio_save_repeat_summary"
- android:title="@string/audio_save_repeat_title"/>
<PreferenceCategory
android:title="@string/headset_prefs_category"
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index d3b537061..193d674f5 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -48,13 +48,6 @@
android:summary="@string/confirm_resume_summary"
android:title="@string/confirm_resume_title"/>
- <CheckBoxPreference
- app:singleLineTitle="false"
- android:defaultValue="false"
- android:key="video_save_repeat"
- android:summary="@string/video_save_repeat_summary"
- android:title="@string/audio_save_repeat_title" />
-
<PreferenceCategory android:title="@string/controls_prefs_category">
<CheckBoxPreference
app:singleLineTitle="false"
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index c62eb61e3..4cf0f7c81 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -30,8 +30,7 @@ import kotlin.math.max
private const val TAG = "VLC/PlaylistManager"
private const val PREVIOUS_LIMIT_DELAY = 5000L
-private const val AUDIO_REPEAT_MODE_KEY = "audio_repeat_mode"
-private const val VIDEO_REPEAT_MODE_KEY = "video_repeat_mode"
+private const val PLAYLIST_REPEAT_MODE_KEY = "audio_repeat_mode" //we keep the old string for migration reasons
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@@ -76,18 +75,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
fun isValidPosition(position: Int) = position in 0 until mediaList.size()
- var wasAudio: Boolean? = null
-
- private fun computeRepeating() {
- //Audio mode changed => resetting
- if (isAudioList() != wasAudio) repeating = REPEAT_NONE
- wasAudio = isAudioList()
- //Load saved mode if repeat save options are used
- if (isAudioList())
- if (settings.getBoolean("audio_save_repeat", false)) repeating = settings.getInt(AUDIO_REPEAT_MODE_KEY, REPEAT_NONE)
- else
- if (settings.getBoolean("video_save_repeat", false)) repeating = settings.getInt(VIDEO_REPEAT_MODE_KEY, REPEAT_NONE)
- if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "computeRepeating. isAudio: ${isAudioList()} repeating: $repeating")
+ init {
+ repeating = settings.getInt(PLAYLIST_REPEAT_MODE_KEY, REPEAT_NONE)
}
/**
@@ -173,7 +162,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
// load playlist
shuffling = settings.getBoolean(if (audio) "audio_shuffling" else "media_shuffling", false)
- repeating = settings.getInt(if (audio) "audio_repeating" else "media_repeating", REPEAT_NONE)
val position = max(0, settings.getInt(if (audio) "position_in_audio_list" else "position_in_media_list", 0))
savedTime = settings.getLong(if (audio) "position_in_song" else "position_in_media", -1)
if (!audio && position < playList.size && settings.getBoolean(VIDEO_PAUSED, false)) {
@@ -267,10 +255,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
@MainThread
fun setRepeatType(repeatType: Int) {
repeating = repeatType
- if (isAudioList() && settings.getBoolean("audio_save_repeat", false))
- settings.edit().putInt(AUDIO_REPEAT_MODE_KEY, repeating).apply()
- else if (!isAudioList() && settings.getBoolean("video_save_repeat", false))
- settings.edit().putInt(VIDEO_REPEAT_MODE_KEY, repeating).apply()
+ settings.edit().putInt(PLAYLIST_REPEAT_MODE_KEY, repeating).apply()
savePosition()
launch { determinePrevAndNextIndices() }
}
@@ -345,7 +330,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
@MainThread
fun switchToVideo(): Boolean {
val media = getCurrentMedia()
- computeRepeating()
if (media === null || media.hasFlag(AbstractMediaWrapper.MEDIA_FORCE_AUDIO) || !player.canSwitchToVideo())
return false
val hasRenderer = player.hasRenderer
@@ -650,7 +634,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
val editor = settings.edit()
val audio = isAudioList()
editor.putBoolean(if (audio) "audio_shuffling" else "media_shuffling", shuffling)
- editor.putInt(if (audio) "audio_repeating" else "media_repeating", repeating)
editor.putInt(if (audio) "position_in_audio_list" else "position_in_media_list", if (reset) 0 else currentIndex)
editor.putLong(if (audio) "position_in_song" else "position_in_media", if (reset) 0L else player.getCurrentTime())
if (!audio) {
More information about the Android
mailing list