Commit 421af442 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Move grid / list display setting to the video UI

Fixes #1041
parent e3d5bb79
......@@ -324,8 +324,6 @@
<string name="video_transition_summary">Show new video title on transition</string>
<string name="media_seen">Show seen video marker</string>
<string name="media_seen_summary">Mark a video as seen when you play it until the end</string>
<string name="force_list_portrait">No grid in portrait mode</string>
<string name="force_list_portrait_summary">Show videos in list instead of grid in portrait mode</string>
<string name="force_play_all_summary">Play all videos, starting with the one you clicked on</string>
<string name="force_play_all_title">Video playlist mode</string>
<string name="save_brightness_summary">Remember brightness level in video player</string>
......
......@@ -50,12 +50,6 @@
android:key="force_play_all"
android:summary="@string/force_play_all_summary"
android:title="@string/force_play_all_title"/>
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="false"
android:key="force_list_portrait"
android:summary="@string/force_list_portrait_summary"
android:title="@string/force_list_portrait"/>
<CheckBoxPreference
app:singleLineTitle="false"
android:defaultValue="true"
......
......@@ -52,7 +52,6 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
}
super.onCreate(savedInstanceState)
findPreference<Preference>("ui_audio_category")?.isVisible = false
findPreference<Preference>(FORCE_LIST_PORTRAIT)?.isVisible = false
findPreference<Preference>(PREF_TV_UI)?.isVisible = AndroidDevices.hasTsp
findPreference<Preference>(KEY_APP_THEME)?.isVisible = false
prepareLocaleList()
......
......@@ -22,7 +22,6 @@ package org.videolan.vlc.gui.video
import android.annotation.TargetApi
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.Handler
......@@ -78,7 +77,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
private lateinit var binding: VideoGridBinding
private var gridItemDecoration: RecyclerView.ItemDecoration? = null
class VideoGridFragmentHandler(private val videoGridFragment: WeakReference<VideoGridFragment>) : Handler() {
override fun handleMessage(msg: Message?) {
......@@ -104,7 +102,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
val seenMarkVisible = preferences.getBoolean("media_seen", true)
videoListAdapter = VideoListAdapter(this, seenMarkVisible)
multiSelectHelper = videoListAdapter.multiSelectHelper
val folder = if (savedInstanceState != null ) savedInstanceState.getParcelable<AbstractFolder>(KEY_FOLDER)
val folder = if (savedInstanceState != null) savedInstanceState.getParcelable<AbstractFolder>(KEY_FOLDER)
else arguments?.getParcelable(KEY_FOLDER)
viewModel = getViewModel(folder)
viewModel.provider.pagedList.observe(this, this)
......@@ -122,6 +120,9 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
super.onPrepareOptionsMenu(menu)
menu.findItem(R.id.ml_menu_last_playlist).isVisible = true
menu.findItem(R.id.ml_menu_video_group).isVisible = true
val displayInCards = Settings.getInstance(requireActivity()).getBoolean("video_display_in_cards", true)
menu.findItem(R.id.ml_menu_display_grid).isVisible = displayInCards
menu.findItem(R.id.ml_menu_display_list).isVisible = !displayInCards
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
......@@ -130,6 +131,12 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
MediaUtils.loadlastPlaylist(activity, PLAYLIST_TYPE_VIDEO)
true
}
R.id.ml_menu_display_list, R.id.ml_menu_display_grid -> {
val displayInCards = Settings.getInstance(requireActivity()).getBoolean("video_display_in_cards", true)
Settings.getInstance(requireActivity()).edit().putBoolean("video_display_in_cards", !displayInCards).apply()
(activity as MainActivity).forceLoadVideoFragment()
true
}
else -> super.onOptionsItemSelected(item)
}
}
......@@ -201,7 +208,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
val res = resources
if (gridItemDecoration == null)
gridItemDecoration = ItemOffsetDecoration(resources, R.dimen.left_right_1610_margin, R.dimen.top_bottom_1610_margin)
val listMode = res.getBoolean(R.bool.list_mode) || res.configuration.orientation == Configuration.ORIENTATION_PORTRAIT && Settings.getInstance(requireContext()).getBoolean(FORCE_LIST_PORTRAIT, false)
val listMode = Settings.getInstance(requireContext()).getBoolean("video_display_in_cards", false)
// Select between grid or list
binding.videoGrid.removeItemDecoration(gridItemDecoration!!)
......@@ -217,7 +224,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
if (videoListAdapter.isListMode != listMode) videoListAdapter.isListMode = listMode
}
private fun playVideo(media: AbstractMediaWrapper, fromStart: Boolean) {
media.removeFlags(AbstractMediaWrapper.MEDIA_FORCE_AUDIO)
if (fromStart) media.addFlags(AbstractMediaWrapper.MEDIA_FROM_START)
......@@ -336,7 +342,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
return true
}
override fun onImageClick(v: View, position: Int, item: MediaLibraryItem) {}
override fun onCtxClick(v: View, position: Int, item: MediaLibraryItem) {
......@@ -348,7 +353,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
showContext(requireActivity(), this, position, item.getTitle(), flags)
}
override fun onMainActionClick(v: View, position: Int, item: MediaLibraryItem) {}
override fun onUpdateFinished(adapter: RecyclerView.Adapter<*>) {
......
......@@ -35,7 +35,6 @@ const val KEY_APP_THEME = "app_theme"
const val KEY_BLACK_THEME = "enable_black_theme"
const val KEY_DAYNIGHT = "daynight"
const val SHOW_VIDEO_THUMBNAILS = "show_video_thumbnails"
const val FORCE_LIST_PORTRAIT = "force_list_portrait"
//UI
const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment