mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Update Material Dialogs
This commit is contained in:
		| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.category | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.input.input | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.ui.base.controller.DialogController | ||||
| @@ -29,15 +30,18 @@ class CategoryCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle) | ||||
|      * @return a new dialog instance. | ||||
|      */ | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.action_add_category) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .alwaysCallInputCallback() | ||||
|                 .input(resources?.getString(R.string.name), currentName, false) { _, input -> | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|                 .input( | ||||
|                     hint = resources?.getString(R.string.name), | ||||
|                     prefill = currentName | ||||
|                 ) { _, input -> | ||||
|                     currentName = input.toString() | ||||
|                 } | ||||
|                 .onPositive { _, _ -> (targetController as? Listener)?.createCategory(currentName) } | ||||
|                 .build() | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     (targetController as? Listener)?.createCategory(currentName) | ||||
|                 } | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.category | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.input.input | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Category | ||||
| @@ -34,15 +35,16 @@ class CategoryRenameDialog<T>(bundle: Bundle? = null) : DialogController(bundle) | ||||
|      * @return a new dialog instance. | ||||
|      */ | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.action_rename_category) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .alwaysCallInputCallback() | ||||
|                 .input(resources!!.getString(R.string.name), currentName, false) { _, input -> | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|                 .input( | ||||
|                     hint = resources?.getString(R.string.name), | ||||
|                     prefill = currentName | ||||
|                 ) { _, input -> | ||||
|                     currentName = input.toString() | ||||
|                 } | ||||
|                 .onPositive { _, _ -> onPositive() } | ||||
|                 .build() | ||||
|                 .positiveButton(android.R.string.ok) { onPositive() } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -18,18 +18,15 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle) | ||||
|     } | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.untrusted_extension) | ||||
|                 .content(R.string.untrusted_extension_message) | ||||
|                 .positiveText(R.string.ext_trust) | ||||
|                 .negativeText(R.string.ext_uninstall) | ||||
|                 .onPositive { _, _ -> | ||||
|                 .message(R.string.untrusted_extension_message) | ||||
|                 .positiveButton(R.string.ext_trust) { | ||||
|                     (targetController as? Listener)?.trustSignature(args.getString(SIGNATURE_KEY)!!) | ||||
|                 } | ||||
|                 .onNegative { _, _ -> | ||||
|                 .negativeButton(R.string.ext_uninstall) { | ||||
|                     (targetController as? Listener)?.uninstallExtension(args.getString(PKGNAME_KEY)!!) | ||||
|                 } | ||||
|                 .build() | ||||
|     } | ||||
|  | ||||
|     private companion object { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItemsMultiChoice | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Category | ||||
| @@ -31,17 +32,18 @@ class ChangeMangaCategoriesDialog<T>(bundle: Bundle? = null) : | ||||
|     } | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.action_move_category) | ||||
|                 .items(categories.map { it.name }) | ||||
|                 .itemsCallbackMultiChoice(preselected) { dialog, _, _ -> | ||||
|                     val newCategories = dialog.selectedIndices?.map { categories[it] }.orEmpty() | ||||
|                 .listItemsMultiChoice( | ||||
|                     items = categories.map { it.name }, | ||||
|                     initialSelection = preselected.toIntArray(), | ||||
|                     allowEmptySelection = true | ||||
|                 ) { _, selections, _ -> | ||||
|                     val newCategories = selections.map { categories[it] } | ||||
|                     (targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories) | ||||
|                     true | ||||
|                 } | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .build() | ||||
|                 .positiveButton(android.R.string.ok) | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| @@ -25,16 +26,17 @@ class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) : | ||||
|             setOptionDescription(R.string.also_delete_chapters) | ||||
|         } | ||||
|  | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.action_remove) | ||||
|                 .customView(view, true) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> | ||||
|                 .customView( | ||||
|                     view = view, | ||||
|                     horizontalPadding = true | ||||
|                 ) | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     val deleteChapters = view.isChecked() | ||||
|                     (targetController as? Listener)?.deleteMangasFromLibrary(mangas, deleteChapters) | ||||
|                 } | ||||
|                 .build() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import android.content.Context | ||||
| import android.os.Bundle | ||||
| import android.util.AttributeSet | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import eu.kanade.tachiyomi.BuildConfig | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.ui.base.controller.DialogController | ||||
| @@ -15,11 +16,10 @@ class ChangelogDialogController : DialogController() { | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         val activity = activity!! | ||||
|         val view = WhatsNewRecyclerView(activity) | ||||
|         return MaterialDialog.Builder(activity) | ||||
|                 .title(if (BuildConfig.DEBUG) R.string.notices else R.string.changelog) | ||||
|                 .customView(view, false) | ||||
|                 .positiveText(R.string.action_close) | ||||
|                 .build() | ||||
|         return MaterialDialog(activity) | ||||
|             .title(res = if (BuildConfig.DEBUG) R.string.notices else R.string.changelog) | ||||
|             .customView(view = view) | ||||
|             .positiveButton(R.string.action_close) | ||||
|     } | ||||
|  | ||||
|     class WhatsNewRecyclerView(context: Context) : ChangeLogRecyclerView(context) { | ||||
|   | ||||
| @@ -15,14 +15,12 @@ class DeleteChaptersDialog<T>(bundle: Bundle? = null) : DialogController(bundle) | ||||
|     } | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|                 .content(R.string.confirm_delete_chapters) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .message(R.string.confirm_delete_chapters) | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     (targetController as? Listener)?.deleteChapters() | ||||
|                 } | ||||
|                 .show() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.ui.base.controller.DialogController | ||||
| @@ -55,15 +56,13 @@ class DownloadCustomChaptersDialog<T> : DialogController | ||||
|  | ||||
|         // Build dialog. | ||||
|         // when positive dialog is pressed call custom listener. | ||||
|         return MaterialDialog.Builder(activity) | ||||
|         return MaterialDialog(activity) | ||||
|                 .title(R.string.custom_download) | ||||
|                 .customView(view, true) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> | ||||
|                 .customView(view = view, scrollable = true) | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     (targetController as? Listener)?.downloadCustomChapters(view.amount) | ||||
|                 } | ||||
|                 .build() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -4,6 +4,8 @@ import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import android.widget.NumberPicker | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.afollestad.materialdialogs.customview.getCustomView | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Track | ||||
| @@ -34,38 +36,32 @@ class SetTrackChaptersDialog<T> : DialogController | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         val item = item | ||||
|  | ||||
|         val dialog = MaterialDialog.Builder(activity!!) | ||||
|         val dialog = MaterialDialog(activity!!) | ||||
|                 .title(R.string.chapters) | ||||
|                 .customView(R.layout.track_chapters_dialog, false) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { dialog, _ -> | ||||
|                     val view = dialog.customView | ||||
|                     if (view != null) { | ||||
|                         // Remove focus to update selected number | ||||
|                         val np: NumberPicker = view.findViewById(R.id.chapters_picker) | ||||
|                         np.clearFocus() | ||||
|                 .customView(R.layout.track_chapters_dialog, dialogWrapContent = false) | ||||
|                 .positiveButton(android.R.string.ok) { dialog -> | ||||
|                     val view = dialog.getCustomView() | ||||
|                     // Remove focus to update selected number | ||||
|                     val np: NumberPicker = view.findViewById(R.id.chapters_picker) | ||||
|                     np.clearFocus() | ||||
|  | ||||
|                         (targetController as? Listener)?.setChaptersRead(item, np.value) | ||||
|                     } | ||||
|                     (targetController as? Listener)?.setChaptersRead(item, np.value) | ||||
|                 } | ||||
|                 .build() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|  | ||||
|         val view = dialog.customView | ||||
|         if (view != null) { | ||||
|             val np: NumberPicker = view.findViewById(R.id.chapters_picker) | ||||
|             // Set initial value | ||||
|             np.value = item.track?.last_chapter_read ?: 0 | ||||
|         val view = dialog.getCustomView() | ||||
|         val np: NumberPicker = view.findViewById(R.id.chapters_picker) | ||||
|         // Set initial value | ||||
|         np.value = item.track?.last_chapter_read ?: 0 | ||||
|  | ||||
|             // Enforce maximum value if tracker has total number of chapters set | ||||
|             if (item.track != null && item.track.total_chapters > 0) { | ||||
|                 np.maxValue = item.track.total_chapters | ||||
|             } | ||||
|  | ||||
|             // Don't allow to go from 0 to 9999 | ||||
|             np.wrapSelectorWheel = false | ||||
|         // Enforce maximum value if tracker has total number of chapters set | ||||
|         if (item.track != null && item.track.total_chapters > 0) { | ||||
|             np.maxValue = item.track.total_chapters | ||||
|         } | ||||
|  | ||||
|         // Don't allow to go from 0 to 9999 | ||||
|         np.wrapSelectorWheel = false | ||||
|  | ||||
|         return dialog | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,8 @@ import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import android.widget.NumberPicker | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.afollestad.materialdialogs.customview.getCustomView | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Track | ||||
| @@ -34,36 +36,30 @@ class SetTrackScoreDialog<T> : DialogController | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         val item = item | ||||
|  | ||||
|         val dialog = MaterialDialog.Builder(activity!!) | ||||
|         val dialog = MaterialDialog(activity!!) | ||||
|                 .title(R.string.score) | ||||
|                 .customView(R.layout.track_score_dialog, false) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { dialog, _ -> | ||||
|                     val view = dialog.customView | ||||
|                     if (view != null) { | ||||
|                         // Remove focus to update selected number | ||||
|                         val np: NumberPicker = view.findViewById(R.id.score_picker) | ||||
|                         np.clearFocus() | ||||
|                 .customView(R.layout.track_score_dialog, dialogWrapContent = false) | ||||
|                 .positiveButton(android.R.string.ok) { dialog -> | ||||
|                     val view = dialog.getCustomView() | ||||
|                     // Remove focus to update selected number | ||||
|                     val np: NumberPicker = view.findViewById(R.id.score_picker) | ||||
|                     np.clearFocus() | ||||
|  | ||||
|                         (targetController as? Listener)?.setScore(item, np.value) | ||||
|                     } | ||||
|                     (targetController as? Listener)?.setScore(item, np.value) | ||||
|                 } | ||||
|                 .show() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|  | ||||
|         val view = dialog.customView | ||||
|         if (view != null) { | ||||
|             val np: NumberPicker = view.findViewById(R.id.score_picker) | ||||
|             val scores = item.service.getScoreList().toTypedArray() | ||||
|             np.maxValue = scores.size - 1 | ||||
|             np.displayedValues = scores | ||||
|         val view = dialog.getCustomView() | ||||
|         val np: NumberPicker = view.findViewById(R.id.score_picker) | ||||
|         val scores = item.service.getScoreList().toTypedArray() | ||||
|         np.maxValue = scores.size - 1 | ||||
|         np.displayedValues = scores | ||||
|  | ||||
|             // Set initial value | ||||
|             val displayedScore = item.service.displayScore(item.track!!) | ||||
|             if (displayedScore != "-") { | ||||
|                 val index = scores.indexOf(displayedScore) | ||||
|                 np.value = if (index != -1) index else 0 | ||||
|             } | ||||
|         // Set initial value | ||||
|         val displayedScore = item.service.displayScore(item.track!!) | ||||
|         if (displayedScore != "-") { | ||||
|             val index = scores.indexOf(displayedScore) | ||||
|             np.value = if (index != -1) index else 0 | ||||
|         } | ||||
|  | ||||
|         return dialog | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItemsSingleChoice | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Track | ||||
| @@ -36,15 +37,17 @@ class SetTrackStatusDialog<T> : DialogController | ||||
|         val statusString = statusList.map { item.service.getStatus(it) } | ||||
|         val selectedIndex = statusList.indexOf(item.track?.status) | ||||
|  | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.status) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .items(statusString) | ||||
|                 .itemsCallbackSingleChoice(selectedIndex) { _, _, i, _ -> | ||||
|                     (targetController as? Listener)?.setStatus(item, i) | ||||
|                     true | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|                 .listItemsSingleChoice( | ||||
|                     items = statusString, | ||||
|                     initialSelection = selectedIndex, | ||||
|                     waitForPositiveButton = false | ||||
|                 ) { dialog, position, _ -> | ||||
|                     (targetController as? Listener)?.setStatus(item, position) | ||||
|                     dialog.dismiss() | ||||
|                 } | ||||
|                 .build() | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import android.view.View | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Track | ||||
| import eu.kanade.tachiyomi.data.track.TrackManager | ||||
| @@ -52,14 +53,11 @@ class TrackSearchDialog : DialogController { | ||||
|     } | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         val dialog = MaterialDialog.Builder(activity!!) | ||||
|                 .customView(R.layout.track_search_dialog, false) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .onPositive { _, _ -> onPositiveButtonClick() } | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .neutralText(R.string.action_remove) | ||||
|                 .onNeutral { _, _ -> onRemoveButtonClick() } | ||||
|                 .build() | ||||
|         val dialog = MaterialDialog(activity!!) | ||||
|                 .customView(R.layout.track_search_dialog) | ||||
|                 .positiveButton(android.R.string.ok) { onPositiveButtonClick() } | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|                 .neutralButton(R.string.action_remove) { onRemoveButtonClick() } | ||||
|  | ||||
|         dialogView = dialog.view | ||||
|         onViewCreated(dialog.view, savedViewState) | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItemsMultiChoice | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| @@ -79,27 +80,23 @@ class SearchController( | ||||
|  | ||||
|             val preselected = MigrationFlags.getEnabledFlagsPositions(prefValue) | ||||
|  | ||||
|             return MaterialDialog.Builder(activity!!) | ||||
|                     .content(R.string.migration_dialog_what_to_include) | ||||
|                     .items(MigrationFlags.titles.map { resources?.getString(it) }) | ||||
|                     .alwaysCallMultiChoiceCallback() | ||||
|                     .itemsCallbackMultiChoice(preselected.toTypedArray()) { _, positions, _ -> | ||||
|             return MaterialDialog(activity!!) | ||||
|                     .message(R.string.migration_dialog_what_to_include) | ||||
|                     .listItemsMultiChoice( | ||||
|                         items = MigrationFlags.titles.map { resources?.getString(it) as CharSequence }, | ||||
|                         initialSelection = preselected.toIntArray() | ||||
|                     ) { _, positions, _ -> | ||||
|                         // Save current settings for the next time | ||||
|                         val newValue = MigrationFlags.getFlagsFromPositions(positions) | ||||
|                         val newValue = MigrationFlags.getFlagsFromPositions(positions.toTypedArray()) | ||||
|                         preferences.migrateFlags().set(newValue) | ||||
|  | ||||
|                         true | ||||
|                     } | ||||
|                     .positiveText(R.string.migrate) | ||||
|                     .negativeText(R.string.copy) | ||||
|                     .neutralText(android.R.string.cancel) | ||||
|                     .onPositive { _, _ -> | ||||
|                     .positiveButton(R.string.migrate) { | ||||
|                         (targetController as? SearchController)?.migrateManga() | ||||
|                     } | ||||
|                     .onNegative { _, _ -> | ||||
|                     .negativeButton(R.string.copy) { | ||||
|                         (targetController as? SearchController)?.copyManga() | ||||
|                     } | ||||
|                     .build() | ||||
|                     .neutralButton(android.R.string.cancel) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -165,12 +165,10 @@ class AboutController : SettingsController() { | ||||
|         }) | ||||
|  | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             return MaterialDialog.Builder(activity!!) | ||||
|                     .title(R.string.update_check_notification_update_available) | ||||
|                     .content(args.getString(BODY_KEY) ?: "") | ||||
|                     .positiveText(R.string.update_check_confirm) | ||||
|                     .negativeText(R.string.update_check_ignore) | ||||
|                     .onPositive { _, _ -> | ||||
|             return MaterialDialog(activity!!) | ||||
|                     .title(res = R.string.update_check_notification_update_available) | ||||
|                     .message(text = args.getString(BODY_KEY) ?: "") | ||||
|                     .positiveButton(R.string.update_check_confirm) { | ||||
|                         val appContext = applicationContext | ||||
|                         if (appContext != null) { | ||||
|                             // Start download | ||||
| @@ -178,7 +176,7 @@ class AboutController : SettingsController() { | ||||
|                             UpdaterService.downloadUpdate(appContext, url) | ||||
|                         } | ||||
|                     } | ||||
|                     .build() | ||||
|                     .negativeButton(R.string.update_check_ignore) | ||||
|         } | ||||
|  | ||||
|         private companion object { | ||||
|   | ||||
| @@ -46,14 +46,13 @@ class ReaderPageSheet( | ||||
|     private fun setAsCover() { | ||||
|         if (page.status != Page.READY) return | ||||
|  | ||||
|         MaterialDialog.Builder(activity) | ||||
|                 .content(activity.getString(R.string.confirm_set_image_as_cover)) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> | ||||
|         MaterialDialog(activity) | ||||
|                 .message(R.string.confirm_set_image_as_cover) | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     activity.setAsCover(page) | ||||
|                     dismiss() | ||||
|                 } | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|                 .show() | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.recent.history | ||||
| import android.app.Dialog | ||||
| import android.os.Bundle | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.bluelinelabs.conductor.Controller | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.models.History | ||||
| @@ -32,13 +33,11 @@ class RemoveHistoryDialog<T>(bundle: Bundle? = null) : DialogController(bundle) | ||||
|             setOptionDescription(R.string.dialog_with_checkbox_reset) | ||||
|         } | ||||
|  | ||||
|         return MaterialDialog.Builder(activity) | ||||
|         return MaterialDialog(activity) | ||||
|                 .title(R.string.action_remove) | ||||
|                 .customView(dialogCheckboxView, true) | ||||
|                 .positiveText(R.string.action_remove) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> onPositive(dialogCheckboxView.isChecked()) } | ||||
|                 .build() | ||||
|                 .customView(view = dialogCheckboxView, horizontalPadding = true) | ||||
|                 .positiveButton(R.string.action_remove) { onPositive(dialogCheckboxView.isChecked()) } | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     private fun onPositive(checked: Boolean) { | ||||
|   | ||||
| @@ -18,14 +18,12 @@ class ConfirmDeleteChaptersDialog<T>(bundle: Bundle? = null) : DialogController( | ||||
|     } | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|                 .content(R.string.confirm_delete_chapters) | ||||
|                 .positiveText(android.R.string.ok) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .onPositive { _, _ -> | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .message(R.string.confirm_delete_chapters) | ||||
|                 .positiveButton(android.R.string.ok) { | ||||
|                     (targetController as? Listener)?.deleteChapters(chaptersToDelete) | ||||
|                 } | ||||
|                 .build() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
| @@ -137,14 +137,12 @@ class SettingsAdvancedController : SettingsController() { | ||||
|  | ||||
|     class ClearDatabaseDialogController : DialogController() { | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             return MaterialDialog.Builder(activity!!) | ||||
|                     .content(R.string.clear_database_confirmation) | ||||
|                     .positiveText(android.R.string.ok) | ||||
|                     .negativeText(android.R.string.cancel) | ||||
|                     .onPositive { _, _ -> | ||||
|             return MaterialDialog(activity!!) | ||||
|                     .message(R.string.clear_database_confirmation) | ||||
|                     .positiveButton(android.R.string.ok) { | ||||
|                         (targetController as? SettingsAdvancedController)?.clearDatabase() | ||||
|                     } | ||||
|                     .build() | ||||
|                     .negativeButton(android.R.string.cancel) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -13,6 +13,7 @@ import android.os.Bundle | ||||
| import android.view.View | ||||
| import androidx.preference.PreferenceScreen | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItemsMultiChoice | ||||
| import com.hippo.unifile.UniFile | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.backup.BackupConst | ||||
| @@ -231,12 +232,14 @@ class SettingsBackupController : SettingsController() { | ||||
|                     R.string.track, R.string.history) | ||||
|                     .map { activity.getString(it) } | ||||
|  | ||||
|             return MaterialDialog.Builder(activity) | ||||
|             return MaterialDialog(activity) | ||||
|                     .title(R.string.pref_create_backup) | ||||
|                     .content(R.string.backup_choice) | ||||
|                     .items(options) | ||||
|                     .itemsDisabledIndices(0) | ||||
|                     .itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4)) { _, positions, _ -> | ||||
|                     .message(R.string.backup_choice) | ||||
|                     .listItemsMultiChoice( | ||||
|                         items = options, | ||||
|                         disabledIndices = intArrayOf(0), | ||||
|                         initialSelection = intArrayOf(0, 1, 2, 3, 4) | ||||
|                     ) { _, positions, _ -> | ||||
|                         var flags = 0 | ||||
|                         for (i in 1 until positions.size) { | ||||
|                             when (positions[i]) { | ||||
| @@ -248,11 +251,9 @@ class SettingsBackupController : SettingsController() { | ||||
|                         } | ||||
|  | ||||
|                         (targetController as? SettingsBackupController)?.createBackup(flags) | ||||
|                         true | ||||
|                     } | ||||
|                     .positiveText(R.string.action_create) | ||||
|                     .negativeText(android.R.string.cancel) | ||||
|                     .build() | ||||
|                     .positiveButton(R.string.action_create) | ||||
|                     .negativeButton(android.R.string.cancel) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -262,11 +263,10 @@ class SettingsBackupController : SettingsController() { | ||||
|         }) | ||||
|  | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             return MaterialDialog.Builder(activity!!) | ||||
|             return MaterialDialog(activity!!) | ||||
|                     .title(R.string.pref_restore_backup) | ||||
|                     .content(R.string.backup_restore_content) | ||||
|                     .positiveText(R.string.action_restore) | ||||
|                     .onPositive { _, _ -> | ||||
|                     .message(R.string.backup_restore_content) | ||||
|                     .positiveButton(R.string.action_restore) { | ||||
|                         val context = applicationContext | ||||
|                         if (context != null) { | ||||
|                             (targetController as SettingsBackupController).notifier.showRestoreProgress() | ||||
| @@ -274,7 +274,6 @@ class SettingsBackupController : SettingsController() { | ||||
|                             isRestoreStarted = true | ||||
|                         } | ||||
|                     } | ||||
|                     .build() | ||||
|         } | ||||
|  | ||||
|         private companion object { | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import android.os.Environment | ||||
| import androidx.core.content.ContextCompat | ||||
| import androidx.preference.PreferenceScreen | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItemsSingleChoice | ||||
| import com.hippo.unifile.UniFile | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.DatabaseHelper | ||||
| @@ -155,21 +156,21 @@ class SettingsDownloadController : SettingsController() { | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             val activity = activity!! | ||||
|             val currentDir = preferences.downloadsDirectory().getOrDefault() | ||||
|             val externalDirs = getExternalDirs() + File(activity.getString(R.string.custom_dir)) | ||||
|             val selectedIndex = externalDirs.map(File::toString).indexOfFirst { it in currentDir } | ||||
|             val externalDirs = (getExternalDirs() + File(activity.getString(R.string.custom_dir))).map(File::toString) | ||||
|             val selectedIndex = externalDirs.indexOfFirst { it in currentDir } | ||||
|  | ||||
|             return MaterialDialog.Builder(activity) | ||||
|                     .items(externalDirs) | ||||
|                     .itemsCallbackSingleChoice(selectedIndex) { _, _, which, text -> | ||||
|             return MaterialDialog(activity) | ||||
|                     .listItemsSingleChoice( | ||||
|                         items = externalDirs, | ||||
|                         initialSelection = selectedIndex | ||||
|                     ) { _, position, text -> | ||||
|                         val target = targetController as? SettingsDownloadController | ||||
|                         if (which == externalDirs.lastIndex) { | ||||
|                         if (position == externalDirs.lastIndex) { | ||||
|                             target?.customDirectorySelected(currentDir) | ||||
|                         } else { | ||||
|                             target?.predefinedDirectorySelected(text.toString()) | ||||
|                         } | ||||
|                         true | ||||
|                     } | ||||
|                     .build() | ||||
|         } | ||||
|  | ||||
|         private fun getExternalDirs(): List<File> { | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import android.os.Handler | ||||
| import android.view.View | ||||
| import androidx.preference.PreferenceScreen | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.database.DatabaseHelper | ||||
| import eu.kanade.tachiyomi.data.database.models.Category | ||||
| @@ -196,16 +197,14 @@ class SettingsLibraryController : SettingsController() { | ||||
|         private var landscape = preferences.landscapeColumns().getOrDefault() | ||||
|  | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             val dialog = MaterialDialog.Builder(activity!!) | ||||
|             val dialog = MaterialDialog(activity!!) | ||||
|                     .title(R.string.pref_library_columns) | ||||
|                     .customView(R.layout.pref_library_columns, false) | ||||
|                     .positiveText(android.R.string.ok) | ||||
|                     .negativeText(android.R.string.cancel) | ||||
|                     .onPositive { _, _ -> | ||||
|                     .customView(R.layout.pref_library_columns) | ||||
|                     .positiveButton(android.R.string.ok) { | ||||
|                         preferences.portraitColumns().set(portrait) | ||||
|                         preferences.landscapeColumns().set(landscape) | ||||
|                     } | ||||
|                     .build() | ||||
|                     .negativeButton(android.R.string.cancel) | ||||
|  | ||||
|             onViewCreated(dialog.view) | ||||
|             return dialog | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import android.view.ViewGroup | ||||
| import androidx.appcompat.widget.SearchView | ||||
| import androidx.recyclerview.widget.LinearLayoutManager | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItems | ||||
| import com.bluelinelabs.conductor.ControllerChangeHandler | ||||
| import com.bluelinelabs.conductor.ControllerChangeType | ||||
| import com.bluelinelabs.conductor.RouterTransaction | ||||
| @@ -121,18 +122,22 @@ class SourceController : NucleusController<SourceMainControllerBinding, SourcePr | ||||
|  | ||||
|         val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false | ||||
|  | ||||
|         MaterialDialog.Builder(activity) | ||||
|                 .title(item.source.name) | ||||
|                 .items( | ||||
|                     activity.getString(R.string.action_hide), | ||||
|                     activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin) | ||||
|                 ) | ||||
|                 .itemsCallback { _, _, which, _ -> | ||||
|         MaterialDialog(activity) | ||||
|                 .title(text = item.source.name) | ||||
|                 .listItems( | ||||
|                     items = listOf( | ||||
|                         activity.getString(R.string.action_hide), | ||||
|                         activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin) | ||||
|                     ), | ||||
|                     waitForPositiveButton = false | ||||
|                 ) { dialog, which, _ -> | ||||
|                     when (which) { | ||||
|                         0 -> hideCatalogue(item.source) | ||||
|                         1 -> pinCatalogue(item.source, isPinned) | ||||
|                     } | ||||
|                 }.show() | ||||
|                     dialog.dismiss() | ||||
|                 } | ||||
|                 .show() | ||||
|     } | ||||
|  | ||||
|     private fun hideCatalogue(source: Source) { | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager | ||||
| import androidx.recyclerview.widget.LinearLayoutManager | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.list.listItems | ||||
| import com.f2prateek.rx.preferences.Preference | ||||
| import com.google.android.material.snackbar.Snackbar | ||||
| import eu.davidea.flexibleadapter.FlexibleAdapter | ||||
| @@ -498,9 +499,11 @@ open class BrowseSourceController(bundle: Bundle) : | ||||
|         val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return | ||||
|  | ||||
|         if (manga.favorite) { | ||||
|             MaterialDialog.Builder(activity) | ||||
|                     .items(activity.getString(R.string.remove_from_library)) | ||||
|                     .itemsCallback { _, _, which, _ -> | ||||
|             MaterialDialog(activity) | ||||
|                     .listItems( | ||||
|                         items = listOf(activity.getString(R.string.remove_from_library)), | ||||
|                         waitForPositiveButton = false | ||||
|                     ) { _, which, _ -> | ||||
|                         when (which) { | ||||
|                             0 -> { | ||||
|                                 presenter.changeMangaFavorite(manga) | ||||
| @@ -508,7 +511,8 @@ open class BrowseSourceController(bundle: Bundle) : | ||||
|                                 activity.toast(activity.getString(R.string.manga_removed_library)) | ||||
|                             } | ||||
|                         } | ||||
|                     }.show() | ||||
|                     } | ||||
|                     .show() | ||||
|         } else { | ||||
|             val categories = presenter.getCategories() | ||||
|             val defaultCategoryId = preferences.defaultCategory() | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import android.text.method.PasswordTransformationMethod | ||||
| import android.view.View | ||||
| import androidx.annotation.StringRes | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.afollestad.materialdialogs.customview.customView | ||||
| import com.bluelinelabs.conductor.ControllerChangeHandler | ||||
| import com.bluelinelabs.conductor.ControllerChangeType | ||||
| import com.dd.processbutton.iml.ActionProcessButton | ||||
| @@ -35,16 +36,14 @@ abstract class LoginDialogPreference( | ||||
|     var requestSubscription: Subscription? = null | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         var dialogBuilder = MaterialDialog.Builder(activity!!) | ||||
|                 .customView(R.layout.pref_account_login, false) | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|         var dialog = MaterialDialog(activity!!) | ||||
|                 .customView(R.layout.pref_account_login) | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|  | ||||
|         if (titleRes != null) { | ||||
|             dialogBuilder = dialogBuilder.title(activity!!.getString(titleRes, titleFormatArgs)) | ||||
|             dialog = dialog.title(text = activity!!.getString(titleRes, titleFormatArgs)) | ||||
|         } | ||||
|  | ||||
|         val dialog = dialogBuilder.build() | ||||
|  | ||||
|         onViewCreated(dialog.view) | ||||
|  | ||||
|         return dialog | ||||
|   | ||||
| @@ -18,16 +18,14 @@ class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) { | ||||
|     constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) }) | ||||
|  | ||||
|     override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|         return MaterialDialog.Builder(activity!!) | ||||
|                 .title(activity!!.getString(R.string.logout_title, service.name)) | ||||
|                 .positiveText(R.string.logout) | ||||
|                 .onPositive { _, _ -> | ||||
|         return MaterialDialog(activity!!) | ||||
|                 .title(R.string.logout_title, service.name) | ||||
|                 .positiveButton(R.string.logout) { | ||||
|                     service.logout() | ||||
|                     (targetController as? Listener)?.trackLogoutDialogClosed(service) | ||||
|                     activity?.toast(R.string.logout_success) | ||||
|                 } | ||||
|                 .negativeText(android.R.string.cancel) | ||||
|                 .build() | ||||
|                 .negativeButton(android.R.string.cancel) | ||||
|     } | ||||
|  | ||||
|     interface Listener { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user