Просмотр исходного кода

Adjust snackbar durations (closes #5932)

arkon 3 лет назад
Родитель
Сommit
0ec7121b8f

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt

@@ -195,7 +195,7 @@ class CategoryController :
                     (activity as? MainActivity)?.binding?.rootCoordinator!!,
                     R.string.snack_categories_deleted,
                     R.string.action_undo,
-                    3000
+                    4000
                 )
 
                 mode.finish()

+ 4 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt

@@ -612,6 +612,9 @@ class MangaController :
      */
     private fun toggleFavorite() {
         val isNowFavorite = presenter.toggleFavorite()
+        if (isNowFavorite) {
+            addSnackbar?.dismiss()
+        }
         if (activity != null && !isNowFavorite && presenter.hasDownloads()) {
             (activity as? MainActivity)?.binding?.rootCoordinator?.snack(activity!!.getString(R.string.delete_downloads_for_manga)) {
                 setAction(R.string.action_delete) {
@@ -619,7 +622,6 @@ class MangaController :
                 }
             }
         }
-
         mangaInfoAdapter?.notifyDataSetChanged()
     }
 
@@ -1115,7 +1117,7 @@ class MangaController :
         val manga = presenter.manga
         presenter.downloadChapters(chapters)
         if (view != null && !manga.favorite) {
-            addSnackbar = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
+            addSnackbar = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(view.context.getString(R.string.snack_add_to_library)) {
                 setAction(R.string.action_add) {
                     if (!manga.favorite) {
                         addToLibrary(manga)

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt

@@ -49,7 +49,7 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2)
  */
 inline fun View.snack(
     message: String,
-    length: Int = Snackbar.LENGTH_LONG,
+    length: Int = 10_000,
     f: Snackbar.() -> Unit = {}
 ): Snackbar {
     val snack = Snackbar.make(this, message, length)