diff --git a/app/build.gradle b/app/build.gradle index 302c1a543..a846b49eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -220,12 +220,15 @@ dependencies { implementation 'eu.davidea:flexible-adapter-ui:1.0.0' implementation 'com.nononsenseapps:filepicker:2.5.2' implementation 'com.github.amulyakhare:TextDrawable:558677e' - implementation 'com.afollestad.material-dialogs:core:0.9.6.0' implementation 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0' implementation 'com.github.mthli:Slice:v1.3' implementation 'com.github.chrisbanes:PhotoView:2.3.0' implementation 'com.github.carlosesco:DirectionalViewPager:a844dbca0a' + final material_dialogs_version = '3.3.0' + implementation "com.afollestad.material-dialogs:core:$material_dialogs_version" + implementation "com.afollestad.material-dialogs:input:$material_dialogs_version" + // Conductor implementation 'com.bluelinelabs:conductor:2.1.5' implementation("com.bluelinelabs:conductor-support:2.1.5") { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryCreateDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryCreateDialog.kt index 43783503c..e723f0d6c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryCreateDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryCreateDialog.kt @@ -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(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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt index 0edf1c9e0..693408ec0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryRenameDialog.kt @@ -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(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() } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionTrustDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionTrustDialog.kt index 11e51ea0f..5b63b46fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionTrustDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionTrustDialog.kt @@ -18,18 +18,15 @@ class ExtensionTrustDialog(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 { 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 cc4e5ee3c..a84874971 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 @@ -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(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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt index 1eeb1f13d..4c6eda135 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt @@ -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(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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogController.kt index 2b738b4aa..900ca4f54 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogController.kt @@ -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) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DeleteChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DeleteChaptersDialog.kt index 56f37c0dd..c2ef933c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DeleteChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DeleteChaptersDialog.kt @@ -15,14 +15,12 @@ class DeleteChaptersDialog(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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt index 3820e22b6..74cc94a9f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/DownloadCustomChaptersDialog.kt @@ -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 : 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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt index 1a8c8ca48..41b758d46 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt @@ -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 : 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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt index b8ae96d16..50fcfe500 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackScoreDialog.kt @@ -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 : 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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt index 0a6892b2c..4738e6c6e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackStatusDialog.kt @@ -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 : 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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt index b2bf10e00..0c1c60213 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt index cf665bf2c..5a18f7428 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt @@ -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) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 178ac4cec..77ef11082 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt index 89d61f83d..1e98cbccd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPageSheet.kt @@ -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() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt index 086fb7257..0dd007538 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/RemoveHistoryDialog.kt @@ -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(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) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt index 022893a0f..797a8fa3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/ConfirmDeleteChaptersDialog.kt @@ -18,14 +18,12 @@ class ConfirmDeleteChaptersDialog(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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 7076ab690..d342fafea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -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) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index 6b25a19c8..c74b2139a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 4b6bea146..b9afcf497 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 8195e6b73..363a753a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt index 34a0a0b5f..bf8caac08 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt @@ -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 + 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) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index 02ee2d62b..1f0949b9c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt index b9f14d7c9..694887175 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt @@ -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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLogoutDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLogoutDialog.kt index 7f50caad3..48efea087 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLogoutDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLogoutDialog.kt @@ -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 { diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 26dee4eaa..57206a64e 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -58,6 +58,13 @@ @style/TextAppearance.Widget.Button @style/TextAppearance.Widget.Menu + + ?attr/colorSurface + ?attr/colorOnSurface + ?attr/colorOnSurface + ?attr/colorAccent + @dimen/card_radius + ?attr/colorAccent @color/selectorColorLight @@ -132,7 +139,12 @@ @style/TextAppearance.Widget.Button @style/TextAppearance.Widget.Menu + ?attr/colorSurface + ?attr/colorOnSurface + ?attr/colorOnSurface + ?attr/colorAccent + @dimen/card_radius ?attr/colorAccent @@ -161,9 +173,6 @@ @android:color/transparent - - @color/colorAmoledPrimary - @color/selectorColorDark @color/selectorColorDark