[Android] DisplaySettings: persist sort setting
Duncan McNamara
git at videolan.org
Mon May 15 12:09:54 UTC 2023
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Fri May 12 14:08:21 2023 +0200| [bc40fddfa83e248c164d4e2d6369c77c04edc786] | committer: Nicolas Pomepuy
DisplaySettings: persist sort setting
Since the addition of DisplaySettingsDialog, sorts have been handled in
the dialog, not in the medialibraryProvider sort method which also saved
the sort values to sharedPrefs. To remedy that, a save method was added
to MedialibraryProvider that is called when changing the sort setting.
Fixes #2922
> https://code.videolan.org/videolan/vlc-android/commit/bc40fddfa83e248c164d4e2d6369c77c04edc786
---
.../vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt | 1 +
.../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt | 1 +
.../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt | 1 +
.../src/org/videolan/vlc/gui/dialogs/DisplaySettingsDialog.kt | 1 +
.../src/org/videolan/vlc/gui/video/VideoGridFragment.kt | 1 +
.../videolan/vlc/providers/medialibrary/MedialibraryProvider.kt | 7 +++++++
6 files changed, 12 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
index e32b854697..192d7abd66 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
@@ -139,6 +139,7 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
@Suppress("UNCHECKED_CAST") val sort = value as Pair<Int, Boolean>
viewModel.providers[currentTab].sort = sort.first
viewModel.providers[currentTab].desc = sort.second
+ viewModel.providers[currentTab].saveSort()
viewModel.refresh()
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
index c7f51a25f4..3f8768e75a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
@@ -231,6 +231,7 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
@Suppress("UNCHECKED_CAST") val sort = value as Pair<Int, Boolean>
viewModel.providers[currentTab].sort = sort.first
viewModel.providers[currentTab].desc = sort.second
+ viewModel.providers[currentTab].saveSort()
viewModel.refresh()
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index af33f7d368..caaf2a98c4 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -177,6 +177,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
@Suppress("UNCHECKED_CAST") val sort = value as Pair<Int, Boolean>
viewModel.providers[currentTab].sort = sort.first
viewModel.providers[currentTab].desc = sort.second
+ viewModel.providers[currentTab].saveSort()
viewModel.refresh()
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/DisplaySettingsDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/DisplaySettingsDialog.kt
index 4e6a0fd27e..89a7cd5c5d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/DisplaySettingsDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/DisplaySettingsDialog.kt
@@ -225,6 +225,7 @@ class DisplaySettingsDialog : VLCBottomSheetDialogFragment() {
container.setOnClickListener {
currentSort = sort
currentSortDesc = desc
+
updateSorts()
lifecycleScope.launch { displaySettingsViewModel.send(CURRENT_SORT, Pair(sort, desc)) }
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index f31e1455dc..2bd4424ee1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -245,6 +245,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
@Suppress("UNCHECKED_CAST") val sort = value as Pair<Int, Boolean>
viewModel.provider.sort = sort.first
viewModel.provider.desc = sort.second
+ viewModel.provider.saveSort()
viewModel.refresh()
}
VIDEO_GROUPING -> {
diff --git a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
index 32e27a883e..c1b4236578 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
@@ -127,6 +127,13 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
}
}
+ fun saveSort() {
+ settings.edit {
+ putInt(sortKey, sort)
+ putBoolean("${sortKey}_desc", desc)
+ }
+ }
+
fun showOnlyFavs(showOnlyFavs:Boolean) {
onlyFavorites = showOnlyFavs
settings.edit {
More information about the Android
mailing list