[Android] Allow renaming / ungrouping group from the group toolbar

Nicolas Pomepuy git at videolan.org
Mon Apr 27 16:32:13 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Apr 27 08:09:44 2020 +0200| [d9f304d35d0cf9e1d15bb06778a3cf68fb3146fe] | committer: Geoffrey Métais

Allow renaming / ungrouping group from the group toolbar

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

 .../src/main/res/drawable/ic_delete_toolbar.xml    | 39 +++++++++++++++++++++
 .../src/main/res/drawable/ic_edit_toolbar.xml      | 40 ++++++++++++++++++++++
 .../vlc-android/res/menu/activity_option.xml       | 15 ++++++++
 .../videolan/vlc/gui/video/VideoGridFragment.kt    | 11 ++++++
 4 files changed, 105 insertions(+)

diff --git a/application/resources/src/main/res/drawable/ic_delete_toolbar.xml b/application/resources/src/main/res/drawable/ic_delete_toolbar.xml
new file mode 100644
index 000000000..41c57a690
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_delete_toolbar.xml
@@ -0,0 +1,39 @@
+<!--
+  ~ *************************************************************************
+  ~  ic_delete_toolbar.xml
+  ~ **************************************************************************
+  ~ Copyright © 2020 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="48"
+        android:viewportHeight="48">
+    <path
+            android:pathData="m18,8c-1.1046,0 -2,0.8954 -2,2h-5v4L37,14L37,10L32,10C32,8.8954 31.1046,8 30,8ZM13,16v20c0,2.2091 1.7909,4 4,4h14c2.2091,0 4,-1.7909 4,-4L35,16Z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="4"
+            android:fillColor="?attr/colorControlNormal"
+            android:strokeColor="#00000000"
+            android:fillAlpha="1"
+            android:strokeLineCap="round" />
+</vector>
diff --git a/application/resources/src/main/res/drawable/ic_edit_toolbar.xml b/application/resources/src/main/res/drawable/ic_edit_toolbar.xml
new file mode 100644
index 000000000..66916672b
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_edit_toolbar.xml
@@ -0,0 +1,40 @@
+<!--
+  ~ *************************************************************************
+  ~  ic_edit_toolbar.xml
+  ~ **************************************************************************
+  ~ Copyright © 2020 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="48"
+        android:viewportHeight="48">
+    <path
+            android:pathData="m34.0294,8c-0.5407,0 -1.0612,0.2036 -1.4434,0.5859l-2,2 6.8282,6.8281 2,-2c0.7808,-0.781 0.7808,-2.0471 0,-2.8281l-4,-4C35.0465,8.2179 34.5499,8 34.0294,8ZM27.8361,13.3359 L8.0002,33.1719L8.0002,40h6.8281l19.836,-19.8359z"
+            android:strokeAlpha="1"
+            android:strokeLineJoin="miter"
+            android:strokeWidth="4"
+            android:fillColor="?attr/colorControlNormal"
+            android:strokeColor="#00000000"
+            android:fillType="evenOdd"
+            android:fillAlpha="1"
+            android:strokeLineCap="butt" />
+</vector>
diff --git a/application/vlc-android/res/menu/activity_option.xml b/application/vlc-android/res/menu/activity_option.xml
index c652125e2..d96f6aeb9 100644
--- a/application/vlc-android/res/menu/activity_option.xml
+++ b/application/vlc-android/res/menu/activity_option.xml
@@ -168,4 +168,19 @@
             android:checkable="true"
             vlc:showAsAction="never"
             android:id="@+id/artists_show_all_title" />
+    <item
+            android:orderInCategory="3"
+            android:title="@string/rename_group"
+            android:icon="@drawable/ic_edit_toolbar"
+            android:visible="false"
+            vlc:showAsAction="ifRoom"
+            android:id="@+id/rename_group" />
+
+    <item
+            android:orderInCategory="3"
+            android:title="@string/ungroup"
+            android:icon="@drawable/ic_delete_toolbar"
+            android:visible="false"
+            vlc:showAsAction="ifRoom"
+            android:id="@+id/ungroup" />
 </menu>
\ No newline at end of file
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 25a391f19..cdcb822dd 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
@@ -114,6 +114,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
             (it as? PagedList<MediaLibraryItem>)?.let { videoListAdapter.submitList(it) }
             updateEmptyView()
             restoreMultiSelectHelper()
+            if (viewModel.group != null && it.size < 2) requireActivity().finish()
         })
 
         viewModel.provider.loading.observe(this, Observer { loading ->
@@ -135,6 +136,8 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
         val displayInCards = settings.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
+        menu.findItem(R.id.rename_group).isVisible = viewModel.group != null
+        menu.findItem(R.id.ungroup).isVisible = viewModel.group != null
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -176,6 +179,14 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
                 }
                 true
             }
+            R.id.rename_group -> {
+                viewModel.group?.let { renameGroup(it) }
+                true
+            }
+            R.id.ungroup -> {
+                viewModel.group?.let { viewModel.ungroup(it) }
+                true
+            }
             else -> super.onOptionsItemSelected(item)
         }
     }



More information about the Android mailing list