瀏覽代碼

Show message when searching with no pinned sources

arkon 4 年之前
父節點
當前提交
e95a5be21d

+ 11 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt

@@ -11,6 +11,7 @@ import androidx.appcompat.widget.SearchView
 import androidx.recyclerview.widget.LinearLayoutManager
 import eu.kanade.tachiyomi.R
 import eu.kanade.tachiyomi.data.database.models.Manga
+import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
 import eu.kanade.tachiyomi.source.CatalogueSource
 import eu.kanade.tachiyomi.ui.base.controller.NucleusController
@@ -22,6 +23,8 @@ import kotlinx.coroutines.flow.launchIn
 import kotlinx.coroutines.flow.onEach
 import reactivecircus.flowbinding.appcompat.QueryTextEvent
 import reactivecircus.flowbinding.appcompat.queryTextEvents
+import uy.kohesive.injekt.api.get
+import uy.kohesive.injekt.injectLazy
 
 /**
  * This controller shows and manages the different search result in global search.
@@ -35,6 +38,8 @@ open class GlobalSearchController(
     GlobalSearchCardAdapter.OnMangaClickListener,
     GlobalSearchAdapter.OnTitleClickListener {
 
+    private val preferences: PreferencesHelper by injectLazy()
+
     /**
      * Adapter containing search results grouped by lang.
      */
@@ -180,6 +185,12 @@ open class GlobalSearchController(
      * @param searchResult result of search.
      */
     fun setItems(searchResult: List<GlobalSearchItem>) {
+        if (searchResult.isEmpty() && preferences.searchPinnedSourcesOnly()) {
+            binding.emptyView.show(R.string.no_pinned_sources)
+        } else {
+            binding.emptyView.hide()
+        }
+
         adapter?.updateDataSet(searchResult)
     }
 

+ 7 - 0
app/src/main/res/layout/global_search_controller.xml

@@ -33,4 +33,11 @@
 
     </FrameLayout>
 
+    <eu.kanade.tachiyomi.widget.EmptyView
+        android:id="@+id/empty_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:visibility="gone" />
+
 </FrameLayout>

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

@@ -454,6 +454,7 @@
     <string name="latest">Latest</string>
     <string name="browse">Browse</string>
     <string name="local_source_help_guide">Local source guide</string>
+    <string name="no_pinned_sources">You have no pinned sources</string>
 
     <!-- Manga activity -->
     <string name="manga_not_in_db">This manga has been removed from the database.</string>