[Android] Add back the display mode in the main browser fragment
Nicolas Pomepuy
git at videolan.org
Mon May 13 13:13:55 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 30 08:33:28 2024 +0200| [0996c10e29bf1e60064e3916ff1ebd609a9b4c59] | committer: Nicolas Pomepuy
Add back the display mode in the main browser fragment
Fixes #3064
> https://code.videolan.org/videolan/vlc-android/commit/0996c10e29bf1e60064e3916ff1ebd609a9b4c59
---
application/vlc-android/res/menu/activity_option.xml | 14 ++++++++++++++
.../org/videolan/vlc/gui/browser/MainBrowserFragment.kt | 14 ++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/application/vlc-android/res/menu/activity_option.xml b/application/vlc-android/res/menu/activity_option.xml
index 8d65580b38..4864624ff1 100644
--- a/application/vlc-android/res/menu/activity_option.xml
+++ b/application/vlc-android/res/menu/activity_option.xml
@@ -62,6 +62,20 @@
android:checkable="true"
vlc:showAsAction="never"
android:visible="true"/>
+ <item
+ android:orderInCategory="3"
+ android:id="@+id/ml_menu_display_list"
+ android:title="@string/display_in_list"
+ vlc:showAsAction="never"
+ android:icon="@drawable/ic_view_list"
+ android:visible="false"/>
+ <item
+ android:orderInCategory="3"
+ android:id="@+id/ml_menu_display_grid"
+ android:title="@string/display_in_grid"
+ vlc:showAsAction="never"
+ android:icon="@drawable/ic_view_grid"
+ android:visible="false"/>
<item
android:orderInCategory="3"
android:id="@+id/ml_menu_scan"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
index cc6c526335..b969cd9d2a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
@@ -114,11 +114,25 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu)
+ menu.findItem(R.id.ml_menu_display_grid).isVisible = displayInList
+ menu.findItem(R.id.ml_menu_display_list).isVisible = !displayInList
menu.findItem(R.id.add_server_favorite).isVisible = true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
+ R.id.ml_menu_display_list, R.id.ml_menu_display_grid -> {
+ displayInList = item.itemId == R.id.ml_menu_display_list
+ containerAdapterAssociation.keys.forEach {
+ it.inCards = !displayInList
+ }
+ localEntry.displayInCards = !displayInList
+ favoritesEntry.displayInCards = !displayInList
+ networkEntry.displayInCards = !displayInList
+ activity?.invalidateOptionsMenu()
+ Settings.getInstance(requireActivity()).putSingle(displayInListKey, displayInList)
+ true
+ }
R.id.add_server_favorite -> {
showAddServerDialog(null)
true
More information about the Android
mailing list