diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/ChangeMangaCategoriesDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/ChangeMangaCategoriesDialog.kt index 395a6e63e..f0dad157b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/ChangeMangaCategoriesDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/ChangeMangaCategoriesDialog.kt @@ -9,6 +9,8 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.ui.base.controller.DialogController +import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction +import eu.kanade.tachiyomi.ui.category.CategoryController class ChangeMangaCategoriesDialog(bundle: Bundle? = null) : DialogController(bundle) where T : Controller, T : ChangeMangaCategoriesDialog.Listener { @@ -32,16 +34,30 @@ class ChangeMangaCategoriesDialog(bundle: Bundle? = null) : override fun onCreateDialog(savedViewState: Bundle?): Dialog { return MaterialDialog(activity!!) .title(R.string.action_move_category) - .listItemsMultiChoice( - items = categories.map { it.name }, - initialSelection = preselected.toIntArray(), - allowEmptySelection = true - ) { _, selections, _ -> - val newCategories = selections.map { categories[it] } - (targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories) - } - .positiveButton(android.R.string.ok) .negativeButton(android.R.string.cancel) + .apply { + if (categories.isNotEmpty()) { + listItemsMultiChoice( + items = categories.map { it.name }, + initialSelection = preselected.toIntArray(), + allowEmptySelection = true + ) { _, selections, _ -> + val newCategories = selections.map { categories[it] } + (targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories) + } + .positiveButton(android.R.string.ok) + } else { + message(R.string.information_empty_category_dialog) + .positiveButton(R.string.action_edit_categories) { + if (targetController is LibraryController) { + val libController = targetController as LibraryController + libController.clearSelection() + } + router.popCurrentController() + router.pushController(CategoryController().withFadeTransaction()) + } + } + } } interface Listener { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index fe0d33185..7ba8bb7b9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -526,6 +526,16 @@ class LibraryController( } } + /** + * Clear all of the manga currently selected, and + * invalidate the action mode to revert the top toolbar + */ + fun clearSelection() { + selectedMangas.clear() + selectionRelay.call(LibrarySelectionEvent.Cleared()) + invalidateActionMode() + } + /** * Move the selected manga to a list of categories. */ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b2f399c7..8487d812a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -729,6 +729,7 @@ Nothing read recently Your library is empty. Add series to your library from Browse. You have no categories. Tap the plus button to create one for organizing your library. + You don\'t have any categories yet. Failed to bypass Cloudflare WebView is required for Tachiyomi