[Android] Browse screen: move the server addition to the overflow

Nicolas Pomepuy git at videolan.org
Fri May 6 09:45:34 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Apr 28 08:33:34 2022 +0200| [cebd18aae5733e1b296f8a9908a63f7e98a60445] | committer: Duncan McNamara

Browse screen: move the server addition to the overflow

Fixes #2499

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

 .../resources/src/main/res/values/strings.xml       |  1 +
 .../vlc-android/res/menu/activity_option.xml        |  6 ++++++
 .../videolan/vlc/gui/browser/MainBrowserFragment.kt | 21 ++++++++++-----------
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 0ec15947b..8c770a5f9 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -946,5 +946,6 @@
     <string name="fold_optimize">Optimize for folding screens</string>
     <string name="foldable">Foldable screen</string>
     <string name="undo">Undo</string>
+    <string name="add_server_favorite">Add a server favorite</string>
 
 </resources>
diff --git a/application/vlc-android/res/menu/activity_option.xml b/application/vlc-android/res/menu/activity_option.xml
index 6f06db4dd..50344c060 100644
--- a/application/vlc-android/res/menu/activity_option.xml
+++ b/application/vlc-android/res/menu/activity_option.xml
@@ -145,6 +145,12 @@
                     android:title="@string/all_subfolders" />
         </menu>
     </item>
+    <item
+            android:orderInCategory="3"
+            android:id="@+id/add_server_favorite"
+            android:title="@string/add_server_favorite"
+            vlc:showAsAction="never"
+            android:visible="false"/>
     <item
             android:orderInCategory="4"
             android:id="@+id/ml_menu_refresh"
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 ec9d25caa..c760e35b4 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
@@ -31,7 +31,9 @@ import androidx.appcompat.view.ActionMode
 import androidx.core.net.toUri
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.lifecycleScope
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaWrapperImpl
@@ -80,7 +82,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
     private var displayInList = false
     private val displayInListKey = "main_browser_fragment_display_mode"
 
-    override fun hasFAB() = true
+    override fun hasFAB() = false
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         return inflater.inflate(R.layout.main_browser_fragment, container, false)
@@ -111,6 +113,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
 
         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 {
@@ -127,6 +130,10 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
                 Settings.getInstance(requireActivity()).putSingle(displayInListKey, displayInList)
                 true
             }
+            R.id.add_server_favorite -> {
+                showAddServerDialog(null)
+                true
+            }
             else -> super.onOptionsItemSelected(item)
         }
     }
@@ -275,15 +282,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
         }
     }
 
-    override fun onStart() {
-        super.onStart()
-        fabPlay?.setImageResource(R.drawable.ic_fab_add)
-        fabPlay?.setOnClickListener(this)
-    }
-
-    override fun onClick(v: View) {
-        if (v.id == R.id.fab || v.id == R.id.fab_large) showAddServerDialog(null)
-    }
+    override fun onClick(v: View) { }
 
     private fun showAddServerDialog(mw: MediaWrapper?) {
         val fm = try {



More information about the Android mailing list