Browse Source

Use FAB for catalogue filter

arkon 5 years ago
parent
commit
9a28cbc1e4

+ 6 - 14
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt

@@ -125,7 +125,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
         setupRecycler(view)
 
         // Prepare filter sheet
-        initFilterSheet()
+        if (presenter.sourceFilters.isNotEmpty()) {
+            initFilterSheet()
+
+            binding.fabFilter.setOnClickListener { filterSheet?.show() }
+            binding.fabFilter.visible()
+        }
 
         binding.progress.visible()
     }
@@ -245,18 +250,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
                 }
         )
 
-        // Setup filters button
-        menu.findItem(R.id.action_set_filter).apply {
-            icon.mutate()
-            if (presenter.sourceFilters.isEmpty()) {
-                isEnabled = false
-                icon.alpha = 128
-            } else {
-                isEnabled = true
-                icon.alpha = 255
-            }
-        }
-
         // Show next display mode
         menu.findItem(R.id.action_display_mode).apply {
             val icon = if (presenter.isListMode)
@@ -278,7 +271,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
         when (item.itemId) {
             R.id.action_search -> expandActionViewFromInteraction = true
             R.id.action_display_mode -> swapDisplayMode()
-            R.id.action_set_filter -> filterSheet?.show()
             R.id.action_open_in_web_view -> openInWebView()
         }
         return super.onOptionsItemSelected(item)

+ 0 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/latest/LatestUpdatesController.kt

@@ -23,6 +23,5 @@ class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle
     override fun onPrepareOptionsMenu(menu: Menu) {
         super.onPrepareOptionsMenu(menu)
         menu.findItem(R.id.action_search).isVisible = false
-        menu.findItem(R.id.action_set_filter).isVisible = false
     }
 }

+ 9 - 0
app/src/main/res/layout/catalogue_controller.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
@@ -26,6 +27,14 @@
 
         </LinearLayout>
 
+        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
+            android:id="@+id/fab_filter"
+            style="@style/Theme.Widget.FAB"
+            android:text="@string/action_filter"
+            android:visibility="gone"
+            app:icon="@drawable/ic_filter_list_24dp"
+            app:layout_anchor="@id/catalogue_view" />
+
         <eu.kanade.tachiyomi.widget.EmptyView
             android:id="@+id/empty_view"
             android:layout_width="match_parent"

+ 0 - 7
app/src/main/res/menu/catalogue_list.xml

@@ -11,13 +11,6 @@
         app:iconTint="?attr/colorOnPrimary"
         app:showAsAction="collapseActionView|ifRoom" />
 
-    <item
-        android:id="@+id/action_set_filter"
-        android:icon="@drawable/ic_filter_list_24dp"
-        android:title="@string/action_set_filter"
-        app:iconTint="?attr/colorOnPrimary"
-        app:showAsAction="ifRoom" />
-
     <item
         android:id="@+id/action_display_mode"
         android:title="@string/action_display_mode"

+ 0 - 1
app/src/main/res/values/strings.xml

@@ -85,7 +85,6 @@
     <string name="action_display_list">List</string>
     <string name="action_display_download_badge">Download badges</string>
     <string name="action_hide">Hide</string>
-    <string name="action_set_filter">Set filter</string>
     <string name="action_cancel">Cancel</string>
     <string name="action_cancel_all">Cancel all</string>
     <string name="action_sort">Sort</string>