mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Added text to category changing dialog when shown with no categories (#5345)
* Added text to ChangeMangaCategoriesDialog if invoked with empty category list * Change dialog text, add negative button, and change positive button to open CategoryController * Tiny bit of code cleanup and reorganizing
This commit is contained in:
		| @@ -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<T>(bundle: Bundle? = null) : | ||||
|     DialogController(bundle) where T : Controller, T : ChangeMangaCategoriesDialog.Listener { | ||||
| @@ -32,16 +34,30 @@ class ChangeMangaCategoriesDialog<T>(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 { | ||||
|   | ||||
| @@ -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. | ||||
|      */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user