[Android] TV: Video playlist mode option
Geoffrey Métais
git at videolan.org
Fri May 24 16:24:07 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 24 10:29:50 2019 +0200| [fe85c9e37c39f9b2ddee15c0b9d84c3fe2d514b9] | committer: Geoffrey Métais
TV: Video playlist mode option
fix #845
> https://code.videolan.org/videolan/vlc-android/commit/fe85c9e37c39f9b2ddee15c0b9d84c3fe2d514b9
---
vlc-android/res/xml/preferences_video.xml | 25 ++++++++++++----------
.../vlc/gui/tv/browser/MediaBrowserTvFragment.kt | 15 ++++++++-----
.../vlc/gui/tv/preferences/PreferencesVideo.kt | 4 +++-
.../vlc/viewmodels/tv/MediaBrowserViewModel.kt | 2 +-
.../videolan/vlc/viewmodels/tv/TvBrowserModel.kt | 2 --
5 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index a40a09eac..31d114ad3 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -4,22 +4,30 @@
android:key="video_category"
android:title="@string/video_prefs_category">
+ <ListPreference
+ android:defaultValue="6"
+ android:entries="@array/video_min_group_length_list"
+ android:entryValues="@array/video_min_group_length_values"
+ android:key="video_min_group_length"
+ android:persistent="true"
+ android:summary="@string/video_min_group_length_summary"
+ android:title="@string/video_min_group_length_title" />
+
<CheckBoxPreference
android:defaultValue="true"
android:key="media_seen"
android:summary="@string/media_seen_summary"
android:title="@string/media_seen" />
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="force_play_all"
+ android:summary="@string/force_play_all_summary"
+ android:title="@string/force_play_all_title" />
<CheckBoxPreference
android:defaultValue="false"
android:key="force_list_portrait"
android:summary="@string/force_list_portrait_summary"
android:title="@string/force_list_portrait" />
-
- <CheckBoxPreference
- android:defaultValue="true"
- android:key="show_video_thumbnails"
- android:summary="@string/show_video_thumbnails_summary"
- android:title="@string/show_video_thumbnails" />
<CheckBoxPreference
android:defaultValue="false"
android:key="save_brightness"
@@ -53,11 +61,6 @@
android:key="audio_boost"
android:summary="@string/audio_boost_summary"
android:title="@string/audio_boost_title" />
- <CheckBoxPreference
- android:defaultValue="false"
- android:key="force_play_all"
- android:summary="@string/force_play_all_summary"
- android:title="@string/force_play_all_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="enable_volume_gesture"
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
index 1e4a105d6..d4cce174a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
@@ -11,6 +11,7 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.media.MediaLibraryItem
+import org.videolan.medialibrary.media.MediaWrapper
import org.videolan.vlc.R
import org.videolan.vlc.gui.tv.MediaTvItemAdapter
import org.videolan.vlc.gui.tv.TvItemAdapter
@@ -31,7 +32,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
override lateinit var adapter: TvItemAdapter
- override fun getTitle() = when (arguments?.getLong(CATEGORY, CATEGORY_SONGS)) {
+ override fun getTitle() = when ((viewModel as MediaBrowserViewModel).category) {
CATEGORY_SONGS -> getString(R.string.tracks)
CATEGORY_ALBUMS -> getString(R.string.albums)
CATEGORY_ARTISTS -> getString(R.string.artists)
@@ -39,7 +40,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
else -> getString(R.string.video)
}
- override fun getColumnNumber() = when (arguments?.getLong(CATEGORY, CATEGORY_SONGS)) {
+ override fun getColumnNumber() = when ((viewModel as MediaBrowserViewModel).category) {
CATEGORY_VIDEOS -> resources.getInteger(R.integer.tv_videos_col_count)
else -> resources.getInteger(R.integer.tv_songs_col_count)
}
@@ -79,11 +80,15 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
headerAdapter.items = headerItems
headerAdapter.notifyDataSetChanged()
})
-
-
}
override fun onClick(v: View, position: Int, item: MediaLibraryItem) {
- launch { TvUtil.openMediaFromPaged(requireActivity(), item, viewModel.provider as MedialibraryProvider<out MediaLibraryItem>) }
+ launch {
+ if ((viewModel as MediaBrowserViewModel).category == CATEGORY_VIDEOS && !Settings.getInstance(requireContext()).getBoolean(FORCE_PLAY_ALL, true)) {
+ TvUtil.playMedia(requireActivity(), item as MediaWrapper)
+ } else {
+ TvUtil.openMediaFromPaged(requireActivity(), item, viewModel.provider as MedialibraryProvider<out MediaLibraryItem>)
+ }
+ }
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.kt b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.kt
index 75c652046..15a70bddf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.kt
@@ -42,6 +42,9 @@ class PreferencesVideo : BasePreferenceFragment() {
override fun getTitleId() = R.string.video_prefs_category
override fun onCreate(savedInstanceState: Bundle?) {
+ Settings.getInstance(activity).run {
+ if (!contains(FORCE_PLAY_ALL)) edit().putBoolean(FORCE_PLAY_ALL, true).apply()
+ }
super.onCreate(savedInstanceState)
findPreference(FORCE_LIST_PORTRAIT).isVisible = false
@@ -51,7 +54,6 @@ class PreferencesVideo : BasePreferenceFragment() {
findPreference(ENABLE_BRIGHTNESS_GESTURE).isVisible = AndroidDevices.hasTsp
findPreference(POPUP_KEEPSCREEN).isVisible = false
findPreference(POPUP_FORCE_LEGACY).isVisible = false
- findPreference(FORCE_PLAY_ALL).isVisible = false
}
override fun onPreferenceTreeClick(preference: Preference): Boolean {
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MediaBrowserViewModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MediaBrowserViewModel.kt
index 644d30453..095e33375 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/tv/MediaBrowserViewModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/tv/MediaBrowserViewModel.kt
@@ -16,7 +16,7 @@ import org.videolan.vlc.viewmodels.MedialibraryViewModel
@ExperimentalCoroutinesApi
-class MediaBrowserViewModel(context: Context, category: Long) : MedialibraryViewModel(context), TvBrowserModel {
+class MediaBrowserViewModel(context: Context, val category: Long) : MedialibraryViewModel(context), TvBrowserModel {
override var nbColumns = 0
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/tv/TvBrowserModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/tv/TvBrowserModel.kt
index 2a266fb75..6d9036044 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/tv/TvBrowserModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/tv/TvBrowserModel.kt
@@ -8,6 +8,4 @@ interface TvBrowserModel {
var currentItem: MediaLibraryItem?
var nbColumns: Int
val provider: HeaderProvider
-
-
}
\ No newline at end of file
More information about the Android
mailing list