From fca59aa7aa6da6ff83ecbc08293bad74beb37c00 Mon Sep 17 00:00:00 2001 From: jmir1 Date: Sun, 21 Nov 2021 23:49:26 +0100 Subject: [PATCH] fix ClearDatabaseController --- .../tachiyomi/animesource/LocalAnimeSource.kt | 2 +- .../java/eu/kanade/tachiyomi/source/LocalSource.kt | 2 +- .../ui/setting/database/ClearDatabaseController.kt | 14 ++++++++++++++ .../ui/setting/database/ClearDatabasePresenter.kt | 2 +- .../database/ClearDatabaseSourceItemHolder.kt | 4 ++-- app/src/main/res/values/strings.xml | 7 ++++++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/animesource/LocalAnimeSource.kt b/app/src/main/java/eu/kanade/tachiyomi/animesource/LocalAnimeSource.kt index 60445f0db..9bc1f46c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/animesource/LocalAnimeSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/animesource/LocalAnimeSource.kt @@ -81,7 +81,7 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource { private val json: Json by injectLazy() override val id = ID - override val name = context.getString(R.string.local_source) + override val name = context.getString(R.string.local_anime_source) override val lang = "other" override val supportsLatest = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index f250a5e14..e5e2a561d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -84,7 +84,7 @@ class LocalSource(private val context: Context) : CatalogueSource { private val json: Json by injectLazy() override val id = ID - override val name = context.getString(R.string.local_source) + override val name = context.getString(R.string.local_manga_source) override val lang = "other" override val supportsLatest = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt index 2aa62c4de..1a31dae3b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt @@ -123,10 +123,24 @@ class ClearDatabaseController : fun setItems(items: List>) { launchUI { + val animeItems = adapter?.currentItems?.filterIsInstance() + ?: emptyList() + adapter?.clear() + adapter?.addItems(0, animeItems) adapter?.addItems(adapter?.itemCount ?: 0, items) } } + fun setItemsAnime(items: List>) { + launchUI { + val mangaItems = adapter?.currentItems?.filterIsInstance() + ?: emptyList() + adapter?.clear() + adapter?.addItems(0, items) + adapter?.addItems(adapter?.itemCount ?: 0, mangaItems) + } + } + override fun configureFab(fab: ExtendedFloatingActionButton) { fab.setIconResource(R.drawable.ic_delete_24dp) fab.setText(R.string.action_delete) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabasePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabasePresenter.kt index 8703ea3b6..0b9b69880 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabasePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabasePresenter.kt @@ -23,7 +23,7 @@ class ClearDatabasePresenter : BasePresenter() { super.onCreate(savedState) getDatabaseAnimeSourcesObservable() .subscribeOn(Schedulers.io()) - .subscribeLatestCache(ClearDatabaseController::setItems) + .subscribeLatestCache(ClearDatabaseController::setItemsAnime) getDatabaseSourcesObservable() .subscribeOn(Schedulers.io()) .subscribeLatestCache(ClearDatabaseController::setItems) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseSourceItemHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseSourceItemHolder.kt index dce917299..b5e2af2fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseSourceItemHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseSourceItemHolder.kt @@ -19,7 +19,7 @@ class ClearDatabaseSourceItemHolder(view: View, adapter: FlexibleAdapter<*>) : F fun bind(source: AnimeSource, count: Int) { binding.title.text = source.toString() - binding.description.text = itemView.context.getString(R.string.clear_database_source_item_count, count) + binding.description.text = itemView.context.resources.getQuantityString(R.plurals.clear_database_source_item_count, count) itemView.post { when { @@ -32,7 +32,7 @@ class ClearDatabaseSourceItemHolder(view: View, adapter: FlexibleAdapter<*>) : F fun bind(source: Source, count: Int) { binding.title.text = source.toString() - binding.description.text = itemView.context.getString(R.string.clear_database_source_item_count, count) + binding.description.text = itemView.context.resources.getQuantityString(R.plurals.clear_database_source_item_count, count) itemView.post { when { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 548b5bf7f..fe76042e0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -530,7 +530,10 @@ Clear chapter/episode cache on app close Clear database Delete history for anime and manga that are not saved in your library - %1$d non-library entries in database + + 1 non-library entry in database + %1$d non-library entries in database + Are you sure? Completed episodes and chapters and progress of non-library entries will be lost Entries deleted Database clean @@ -605,6 +608,8 @@ Check website in WebView Local source + Local manga source + Local anime source Other Last used Pinned