[Android] Move video group setting to main UI

Nicolas Pomepuy git at videolan.org
Wed Sep 18 11:11:19 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Sep 16 14:42:55 2019 +0200| [0b3468ba5d3adfcc4955359ff63eedc71c6c12d7] | committer: Geoffrey Métais

Move video group setting to main UI

Fixes #1029

> https://code.videolan.org/videolan/vlc-android/commit/0b3468ba5d3adfcc4955359ff63eedc71c6c12d7
---

 vlc-android/res/menu/activity_option.xml                | 17 +++++++++++++++++
 vlc-android/res/values/arrays.xml                       | 16 ----------------
 vlc-android/res/values/strings.xml                      |  1 -
 vlc-android/res/xml/preferences_ui.xml                  |  9 ---------
 .../videolan/vlc/gui/browser/MediaBrowserFragment.kt    | 16 ++++++++++++----
 .../src/org/videolan/vlc/gui/folders/FoldersFragment.kt |  1 +
 .../src/org/videolan/vlc/gui/helpers/Navigator.kt       |  5 +++++
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.kt |  1 +
 8 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/vlc-android/res/menu/activity_option.xml b/vlc-android/res/menu/activity_option.xml
index 2aa9282a5..7d3a0b43c 100644
--- a/vlc-android/res/menu/activity_option.xml
+++ b/vlc-android/res/menu/activity_option.xml
@@ -86,6 +86,23 @@
                     android:visible="false"/>
         </menu>
     </item>
+    <item
+            android:orderInCategory="2"
+            android:title="@string/video_min_group_length_title"
+            android:id="@+id/ml_menu_video_group"
+            vlc:showAsAction="never"
+            android:visible="false">
+        <menu>
+            <item
+                    android:orderInCategory="2"
+                    android:id="@+id/video_min_group_length_disable"
+                    android:title="@string/video_min_group_length_disable" />
+            <item
+                    android:orderInCategory="2"
+                    android:id="@+id/video_min_group_length_folder"
+                    android:title="@string/video_min_group_length_folder" />
+        </menu>
+    </item>
     <item
             android:orderInCategory="3"
             android:id="@+id/ml_menu_refresh"
diff --git a/vlc-android/res/values/arrays.xml b/vlc-android/res/values/arrays.xml
index 51abc8773..bc55f6c38 100644
--- a/vlc-android/res/values/arrays.xml
+++ b/vlc-android/res/values/arrays.xml
@@ -261,22 +261,6 @@
         <item>4</item>
     </string-array>
 
-    <string-array name="video_min_group_length_list" translatable="false">
-        <item>@string/video_min_group_length_disable</item>
-        <item>@string/video_min_group_length_folder</item>
-        <!--<item>@string/video_min_group_length_first</item>-->
-        <!--<item>@string/video_min_group_length_short</item>-->
-        <!--<item>@string/video_min_group_length_long</item>-->
-    </string-array>
-
-    <string-array name="video_min_group_length_values" translatable="false">
-        <item>-1</item>
-        <item>0</item>
-        <!--<item>1</item>-->
-        <!--<item>6</item>-->
-        <!--<item>9</item>-->
-    </string-array>
-
     <string-array name="subtitles_encoding_list" tools:ignore="TypographyDashes">
         <item>Default (Windows-1252)</item>
         <item>Universal (UTF-8)</item>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 66b8d5f2a..67910cfdc 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -313,7 +313,6 @@
 
     <string name="video_prefs_category">Video</string>
     <string name="video_min_group_length_title">Group videos</string>
-    <string name="video_min_group_length_summary">Videos are grouped if their first letters are the same.</string>
     <string name="video_min_group_length_disable">Disable</string>
     <string name="video_min_group_length_folder">Group by folder</string>
     <string name="video_min_group_length_first">First letter only</string>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index 7f666dd3f..6924a359a 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -44,15 +44,6 @@
             android:title="@string/video"
             android:key="ui_video_category">
 
-        <ListPreference
-                android:defaultValue="-1"
-                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
                 app:singleLineTitle="false"
                 android:defaultValue="true"
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index 1e135e5a1..94203d251 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -49,6 +49,7 @@ import org.videolan.vlc.R
 import org.videolan.vlc.gui.AudioPlayerContainerActivity
 import org.videolan.vlc.gui.ContentActivity
 import org.videolan.vlc.gui.InfoActivity
+import org.videolan.vlc.gui.MainActivity
 import org.videolan.vlc.gui.helpers.SparseBooleanArrayParcelable
 import org.videolan.vlc.gui.helpers.UiTools
 import org.videolan.vlc.gui.helpers.UiTools.snackerConfirm
@@ -56,10 +57,7 @@ import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.getW
 import org.videolan.vlc.gui.view.SwipeRefreshLayout
 import org.videolan.vlc.interfaces.Filterable
 import org.videolan.vlc.media.MediaUtils
-import org.videolan.vlc.util.AndroidDevices
-import org.videolan.vlc.util.FileUtils
-import org.videolan.vlc.util.TAG_ITEM
-import org.videolan.vlc.util.Util
+import org.videolan.vlc.util.*
 import org.videolan.vlc.viewmodels.MedialibraryViewModel
 import org.videolan.vlc.viewmodels.SortableModel
 import java.lang.Runnable
@@ -287,6 +285,16 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
                 sortBy(AbstractMedialibrary.SORT_FILESIZE) //TODO
                 return super.onOptionsItemSelected(item)
             }
+            R.id.video_min_group_length_disable -> {
+                Settings.getInstance(requireActivity()).edit().putString("video_min_group_length", "-1").apply()
+                (activity as MainActivity).forceLoadVideoFragment()
+                return true
+            }
+            R.id.video_min_group_length_folder -> {
+                Settings.getInstance(requireActivity()).edit().putString("video_min_group_length", "0").apply()
+                (activity as MainActivity).forceLoadVideoFragment()
+                return true
+            }
             else -> return super.onOptionsItemSelected(item)
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
index a4955626a..1dde24dd2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
@@ -97,6 +97,7 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
     override fun onPrepareOptionsMenu(menu: Menu) {
         super.onPrepareOptionsMenu(menu)
         menu.findItem(R.id.ml_menu_last_playlist)?.isVisible = true
+        menu.findItem(R.id.ml_menu_video_group).isVisible = true
     }
 
     override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
index 97acedda6..6d0fa47d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
@@ -154,6 +154,10 @@ class Navigator: NavigationView.OnNavigationItemSelectedListener, LifecycleObser
         showFragment(fragment, id, tag)
     }
 
+    override fun forceLoadVideoFragment() {
+        showFragment(R.id.nav_video)
+    }
+
     private fun showFragment(fragment: Fragment, id: Int, tag: String = getTag(id)) {
         val fm = activity.supportFragmentManager
         if (currentFragment is BaseBrowserFragment) fm.popBackStackImmediate("root", FragmentManager.POP_BACK_STACK_INCLUSIVE)
@@ -352,4 +356,5 @@ interface INavigator {
     fun displayExtensionItems(extensionId: Int, title: String, items: List<VLCExtensionItem>, showParams: Boolean, refresh: Boolean)
     fun reloadPreferences()
     fun closeDrawer()
+    fun forceLoadVideoFragment()
 }
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index a7751e575..b41936abc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -121,6 +121,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
     override fun onPrepareOptionsMenu(menu: Menu) {
         super.onPrepareOptionsMenu(menu)
         menu.findItem(R.id.ml_menu_last_playlist).isVisible = true
+        menu.findItem(R.id.ml_menu_video_group).isVisible = true
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean {



More information about the Android mailing list