Update Material Dialogs

This commit is contained in:
arkon 2020-04-20 17:59:19 -04:00
parent f69f78db34
commit 932a47a8a7
27 changed files with 218 additions and 215 deletions

View File

@ -220,12 +220,15 @@ dependencies {
implementation 'eu.davidea:flexible-adapter-ui:1.0.0' implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
implementation 'com.nononsenseapps:filepicker:2.5.2' implementation 'com.nononsenseapps:filepicker:2.5.2'
implementation 'com.github.amulyakhare:TextDrawable:558677e' 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.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0'
implementation 'com.github.mthli:Slice:v1.3' implementation 'com.github.mthli:Slice:v1.3'
implementation 'com.github.chrisbanes:PhotoView:2.3.0' implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.github.carlosesco:DirectionalViewPager:a844dbca0a' 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 // Conductor
implementation 'com.bluelinelabs:conductor:2.1.5' implementation 'com.bluelinelabs:conductor:2.1.5'
implementation("com.bluelinelabs:conductor-support:2.1.5") { implementation("com.bluelinelabs:conductor-support:2.1.5") {

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.category
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.DialogController 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. * @return a new dialog instance.
*/ */
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.action_add_category) .title(R.string.action_add_category)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.alwaysCallInputCallback() .input(
.input(resources?.getString(R.string.name), currentName, false) { _, input -> hint = resources?.getString(R.string.name),
prefill = currentName
) { _, input ->
currentName = input.toString() currentName = input.toString()
} }
.onPositive { _, _ -> (targetController as? Listener)?.createCategory(currentName) } .positiveButton(android.R.string.ok) {
.build() (targetController as? Listener)?.createCategory(currentName)
}
} }
interface Listener { interface Listener {

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.category
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Category 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. * @return a new dialog instance.
*/ */
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.action_rename_category) .title(R.string.action_rename_category)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.alwaysCallInputCallback() .input(
.input(resources!!.getString(R.string.name), currentName, false) { _, input -> hint = resources?.getString(R.string.name),
prefill = currentName
) { _, input ->
currentName = input.toString() currentName = input.toString()
} }
.onPositive { _, _ -> onPositive() } .positiveButton(android.R.string.ok) { onPositive() }
.build()
} }
/** /**

View File

@ -18,18 +18,15 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
} }
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.untrusted_extension) .title(R.string.untrusted_extension)
.content(R.string.untrusted_extension_message) .message(R.string.untrusted_extension_message)
.positiveText(R.string.ext_trust) .positiveButton(R.string.ext_trust) {
.negativeText(R.string.ext_uninstall)
.onPositive { _, _ ->
(targetController as? Listener)?.trustSignature(args.getString(SIGNATURE_KEY)!!) (targetController as? Listener)?.trustSignature(args.getString(SIGNATURE_KEY)!!)
} }
.onNegative { _, _ -> .negativeButton(R.string.ext_uninstall) {
(targetController as? Listener)?.uninstallExtension(args.getString(PKGNAME_KEY)!!) (targetController as? Listener)?.uninstallExtension(args.getString(PKGNAME_KEY)!!)
} }
.build()
} }
private companion object { private companion object {

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
@ -31,17 +32,18 @@ class ChangeMangaCategoriesDialog<T>(bundle: Bundle? = null) :
} }
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.action_move_category) .title(R.string.action_move_category)
.items(categories.map { it.name }) .listItemsMultiChoice(
.itemsCallbackMultiChoice(preselected) { dialog, _, _ -> items = categories.map { it.name },
val newCategories = dialog.selectedIndices?.map { categories[it] }.orEmpty() initialSelection = preselected.toIntArray(),
allowEmptySelection = true
) { _, selections, _ ->
val newCategories = selections.map { categories[it] }
(targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories) (targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories)
true
} }
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.build()
} }
interface Listener { interface Listener {

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -25,16 +26,17 @@ class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
setOptionDescription(R.string.also_delete_chapters) setOptionDescription(R.string.also_delete_chapters)
} }
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.action_remove) .title(R.string.action_remove)
.customView(view, true) .customView(
.positiveText(android.R.string.ok) view = view,
.negativeText(android.R.string.cancel) horizontalPadding = true
.onPositive { _, _ -> )
.positiveButton(android.R.string.ok) {
val deleteChapters = view.isChecked() val deleteChapters = view.isChecked()
(targetController as? Listener)?.deleteMangasFromLibrary(mangas, deleteChapters) (targetController as? Listener)?.deleteMangasFromLibrary(mangas, deleteChapters)
} }
.build() .negativeButton(android.R.string.cancel)
} }
interface Listener { interface Listener {

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.AttributeSet import android.util.AttributeSet
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
@ -15,11 +16,10 @@ class ChangelogDialogController : DialogController() {
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val activity = activity!! val activity = activity!!
val view = WhatsNewRecyclerView(activity) val view = WhatsNewRecyclerView(activity)
return MaterialDialog.Builder(activity) return MaterialDialog(activity)
.title(if (BuildConfig.DEBUG) R.string.notices else R.string.changelog) .title(res = if (BuildConfig.DEBUG) R.string.notices else R.string.changelog)
.customView(view, false) .customView(view = view)
.positiveText(R.string.action_close) .positiveButton(R.string.action_close)
.build()
} }
class WhatsNewRecyclerView(context: Context) : ChangeLogRecyclerView(context) { class WhatsNewRecyclerView(context: Context) : ChangeLogRecyclerView(context) {

View File

@ -15,14 +15,12 @@ class DeleteChaptersDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
} }
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.content(R.string.confirm_delete_chapters) .message(R.string.confirm_delete_chapters)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
(targetController as? Listener)?.deleteChapters() (targetController as? Listener)?.deleteChapters()
} }
.show() .negativeButton(android.R.string.cancel)
} }
interface Listener { interface Listener {

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
@ -55,15 +56,13 @@ class DownloadCustomChaptersDialog<T> : DialogController
// Build dialog. // Build dialog.
// when positive dialog is pressed call custom listener. // when positive dialog is pressed call custom listener.
return MaterialDialog.Builder(activity) return MaterialDialog(activity)
.title(R.string.custom_download) .title(R.string.custom_download)
.customView(view, true) .customView(view = view, scrollable = true)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
(targetController as? Listener)?.downloadCustomChapters(view.amount) (targetController as? Listener)?.downloadCustomChapters(view.amount)
} }
.build() .negativeButton(android.R.string.cancel)
} }
interface Listener { interface Listener {

View File

@ -4,6 +4,8 @@ import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.widget.NumberPicker import android.widget.NumberPicker
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.customview.getCustomView
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
@ -34,25 +36,20 @@ class SetTrackChaptersDialog<T> : DialogController
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val item = item val item = item
val dialog = MaterialDialog.Builder(activity!!) val dialog = MaterialDialog(activity!!)
.title(R.string.chapters) .title(R.string.chapters)
.customView(R.layout.track_chapters_dialog, false) .customView(R.layout.track_chapters_dialog, dialogWrapContent = false)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) { dialog ->
.negativeText(android.R.string.cancel) val view = dialog.getCustomView()
.onPositive { dialog, _ ->
val view = dialog.customView
if (view != null) {
// Remove focus to update selected number // Remove focus to update selected number
val np: NumberPicker = view.findViewById(R.id.chapters_picker) val np: NumberPicker = view.findViewById(R.id.chapters_picker)
np.clearFocus() np.clearFocus()
(targetController as? Listener)?.setChaptersRead(item, np.value) (targetController as? Listener)?.setChaptersRead(item, np.value)
} }
} .negativeButton(android.R.string.cancel)
.build()
val view = dialog.customView val view = dialog.getCustomView()
if (view != null) {
val np: NumberPicker = view.findViewById(R.id.chapters_picker) val np: NumberPicker = view.findViewById(R.id.chapters_picker)
// Set initial value // Set initial value
np.value = item.track?.last_chapter_read ?: 0 np.value = item.track?.last_chapter_read ?: 0
@ -64,7 +61,6 @@ class SetTrackChaptersDialog<T> : DialogController
// Don't allow to go from 0 to 9999 // Don't allow to go from 0 to 9999
np.wrapSelectorWheel = false np.wrapSelectorWheel = false
}
return dialog return dialog
} }

View File

@ -4,6 +4,8 @@ import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.widget.NumberPicker import android.widget.NumberPicker
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.customview.getCustomView
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
@ -34,25 +36,20 @@ class SetTrackScoreDialog<T> : DialogController
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val item = item val item = item
val dialog = MaterialDialog.Builder(activity!!) val dialog = MaterialDialog(activity!!)
.title(R.string.score) .title(R.string.score)
.customView(R.layout.track_score_dialog, false) .customView(R.layout.track_score_dialog, dialogWrapContent = false)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) { dialog ->
.negativeText(android.R.string.cancel) val view = dialog.getCustomView()
.onPositive { dialog, _ ->
val view = dialog.customView
if (view != null) {
// Remove focus to update selected number // Remove focus to update selected number
val np: NumberPicker = view.findViewById(R.id.score_picker) val np: NumberPicker = view.findViewById(R.id.score_picker)
np.clearFocus() np.clearFocus()
(targetController as? Listener)?.setScore(item, np.value) (targetController as? Listener)?.setScore(item, np.value)
} }
} .negativeButton(android.R.string.cancel)
.show()
val view = dialog.customView val view = dialog.getCustomView()
if (view != null) {
val np: NumberPicker = view.findViewById(R.id.score_picker) val np: NumberPicker = view.findViewById(R.id.score_picker)
val scores = item.service.getScoreList().toTypedArray() val scores = item.service.getScoreList().toTypedArray()
np.maxValue = scores.size - 1 np.maxValue = scores.size - 1
@ -64,7 +61,6 @@ class SetTrackScoreDialog<T> : DialogController
val index = scores.indexOf(displayedScore) val index = scores.indexOf(displayedScore)
np.value = if (index != -1) index else 0 np.value = if (index != -1) index else 0
} }
}
return dialog return dialog
} }

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Track 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 statusString = statusList.map { item.service.getStatus(it) }
val selectedIndex = statusList.indexOf(item.track?.status) val selectedIndex = statusList.indexOf(item.track?.status)
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.status) .title(R.string.status)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.items(statusString) .listItemsSingleChoice(
.itemsCallbackSingleChoice(selectedIndex) { _, _, i, _ -> items = statusString,
(targetController as? Listener)?.setStatus(item, i) initialSelection = selectedIndex,
true waitForPositiveButton = false
) { dialog, position, _ ->
(targetController as? Listener)?.setStatus(item, position)
dialog.dismiss()
} }
.build()
} }
interface Listener { interface Listener {

View File

@ -4,6 +4,7 @@ import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
@ -52,14 +53,11 @@ class TrackSearchDialog : DialogController {
} }
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val dialog = MaterialDialog.Builder(activity!!) val dialog = MaterialDialog(activity!!)
.customView(R.layout.track_search_dialog, false) .customView(R.layout.track_search_dialog)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) { onPositiveButtonClick() }
.onPositive { _, _ -> onPositiveButtonClick() } .negativeButton(android.R.string.cancel)
.negativeText(android.R.string.cancel) .neutralButton(R.string.action_remove) { onRemoveButtonClick() }
.neutralText(R.string.action_remove)
.onNeutral { _, _ -> onRemoveButtonClick() }
.build()
dialogView = dialog.view dialogView = dialog.view
onViewCreated(dialog.view, savedViewState) onViewCreated(dialog.view, savedViewState)

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -79,27 +80,23 @@ class SearchController(
val preselected = MigrationFlags.getEnabledFlagsPositions(prefValue) val preselected = MigrationFlags.getEnabledFlagsPositions(prefValue)
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.content(R.string.migration_dialog_what_to_include) .message(R.string.migration_dialog_what_to_include)
.items(MigrationFlags.titles.map { resources?.getString(it) }) .listItemsMultiChoice(
.alwaysCallMultiChoiceCallback() items = MigrationFlags.titles.map { resources?.getString(it) as CharSequence },
.itemsCallbackMultiChoice(preselected.toTypedArray()) { _, positions, _ -> initialSelection = preselected.toIntArray()
) { _, positions, _ ->
// Save current settings for the next time // Save current settings for the next time
val newValue = MigrationFlags.getFlagsFromPositions(positions) val newValue = MigrationFlags.getFlagsFromPositions(positions.toTypedArray())
preferences.migrateFlags().set(newValue) preferences.migrateFlags().set(newValue)
true
} }
.positiveText(R.string.migrate) .positiveButton(R.string.migrate) {
.negativeText(R.string.copy)
.neutralText(android.R.string.cancel)
.onPositive { _, _ ->
(targetController as? SearchController)?.migrateManga() (targetController as? SearchController)?.migrateManga()
} }
.onNegative { _, _ -> .negativeButton(R.string.copy) {
(targetController as? SearchController)?.copyManga() (targetController as? SearchController)?.copyManga()
} }
.build() .neutralButton(android.R.string.cancel)
} }
} }
} }

View File

@ -165,12 +165,10 @@ class AboutController : SettingsController() {
}) })
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.update_check_notification_update_available) .title(res = R.string.update_check_notification_update_available)
.content(args.getString(BODY_KEY) ?: "") .message(text = args.getString(BODY_KEY) ?: "")
.positiveText(R.string.update_check_confirm) .positiveButton(R.string.update_check_confirm) {
.negativeText(R.string.update_check_ignore)
.onPositive { _, _ ->
val appContext = applicationContext val appContext = applicationContext
if (appContext != null) { if (appContext != null) {
// Start download // Start download
@ -178,7 +176,7 @@ class AboutController : SettingsController() {
UpdaterService.downloadUpdate(appContext, url) UpdaterService.downloadUpdate(appContext, url)
} }
} }
.build() .negativeButton(R.string.update_check_ignore)
} }
private companion object { private companion object {

View File

@ -46,14 +46,13 @@ class ReaderPageSheet(
private fun setAsCover() { private fun setAsCover() {
if (page.status != Page.READY) return if (page.status != Page.READY) return
MaterialDialog.Builder(activity) MaterialDialog(activity)
.content(activity.getString(R.string.confirm_set_image_as_cover)) .message(R.string.confirm_set_image_as_cover)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
activity.setAsCover(page) activity.setAsCover(page)
dismiss() dismiss()
} }
.negativeButton(android.R.string.cancel)
.show() .show()
} }

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.recent.history
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.History 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) setOptionDescription(R.string.dialog_with_checkbox_reset)
} }
return MaterialDialog.Builder(activity) return MaterialDialog(activity)
.title(R.string.action_remove) .title(R.string.action_remove)
.customView(dialogCheckboxView, true) .customView(view = dialogCheckboxView, horizontalPadding = true)
.positiveText(R.string.action_remove) .positiveButton(R.string.action_remove) { onPositive(dialogCheckboxView.isChecked()) }
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.onPositive { _, _ -> onPositive(dialogCheckboxView.isChecked()) }
.build()
} }
private fun onPositive(checked: Boolean) { private fun onPositive(checked: Boolean) {

View File

@ -18,14 +18,12 @@ class ConfirmDeleteChaptersDialog<T>(bundle: Bundle? = null) : DialogController(
} }
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.content(R.string.confirm_delete_chapters) .message(R.string.confirm_delete_chapters)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
(targetController as? Listener)?.deleteChapters(chaptersToDelete) (targetController as? Listener)?.deleteChapters(chaptersToDelete)
} }
.build() .negativeButton(android.R.string.cancel)
} }
interface Listener { interface Listener {

View File

@ -137,14 +137,12 @@ class SettingsAdvancedController : SettingsController() {
class ClearDatabaseDialogController : DialogController() { class ClearDatabaseDialogController : DialogController() {
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.content(R.string.clear_database_confirmation) .message(R.string.clear_database_confirmation)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
(targetController as? SettingsAdvancedController)?.clearDatabase() (targetController as? SettingsAdvancedController)?.clearDatabase()
} }
.build() .negativeButton(android.R.string.cancel)
} }
} }

View File

@ -13,6 +13,7 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.hippo.unifile.UniFile import com.hippo.unifile.UniFile
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.backup.BackupConst import eu.kanade.tachiyomi.data.backup.BackupConst
@ -231,12 +232,14 @@ class SettingsBackupController : SettingsController() {
R.string.track, R.string.history) R.string.track, R.string.history)
.map { activity.getString(it) } .map { activity.getString(it) }
return MaterialDialog.Builder(activity) return MaterialDialog(activity)
.title(R.string.pref_create_backup) .title(R.string.pref_create_backup)
.content(R.string.backup_choice) .message(R.string.backup_choice)
.items(options) .listItemsMultiChoice(
.itemsDisabledIndices(0) items = options,
.itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4)) { _, positions, _ -> disabledIndices = intArrayOf(0),
initialSelection = intArrayOf(0, 1, 2, 3, 4)
) { _, positions, _ ->
var flags = 0 var flags = 0
for (i in 1 until positions.size) { for (i in 1 until positions.size) {
when (positions[i]) { when (positions[i]) {
@ -248,11 +251,9 @@ class SettingsBackupController : SettingsController() {
} }
(targetController as? SettingsBackupController)?.createBackup(flags) (targetController as? SettingsBackupController)?.createBackup(flags)
true
} }
.positiveText(R.string.action_create) .positiveButton(R.string.action_create)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.build()
} }
} }
@ -262,11 +263,10 @@ class SettingsBackupController : SettingsController() {
}) })
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(R.string.pref_restore_backup) .title(R.string.pref_restore_backup)
.content(R.string.backup_restore_content) .message(R.string.backup_restore_content)
.positiveText(R.string.action_restore) .positiveButton(R.string.action_restore) {
.onPositive { _, _ ->
val context = applicationContext val context = applicationContext
if (context != null) { if (context != null) {
(targetController as SettingsBackupController).notifier.showRestoreProgress() (targetController as SettingsBackupController).notifier.showRestoreProgress()
@ -274,7 +274,6 @@ class SettingsBackupController : SettingsController() {
isRestoreStarted = true isRestoreStarted = true
} }
} }
.build()
} }
private companion object { private companion object {

View File

@ -10,6 +10,7 @@ import android.os.Environment
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.hippo.unifile.UniFile import com.hippo.unifile.UniFile
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
@ -155,21 +156,21 @@ class SettingsDownloadController : SettingsController() {
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val activity = activity!! val activity = activity!!
val currentDir = preferences.downloadsDirectory().getOrDefault() val currentDir = preferences.downloadsDirectory().getOrDefault()
val externalDirs = getExternalDirs() + File(activity.getString(R.string.custom_dir)) val externalDirs = (getExternalDirs() + File(activity.getString(R.string.custom_dir))).map(File::toString)
val selectedIndex = externalDirs.map(File::toString).indexOfFirst { it in currentDir } val selectedIndex = externalDirs.indexOfFirst { it in currentDir }
return MaterialDialog.Builder(activity) return MaterialDialog(activity)
.items(externalDirs) .listItemsSingleChoice(
.itemsCallbackSingleChoice(selectedIndex) { _, _, which, text -> items = externalDirs,
initialSelection = selectedIndex
) { _, position, text ->
val target = targetController as? SettingsDownloadController val target = targetController as? SettingsDownloadController
if (which == externalDirs.lastIndex) { if (position == externalDirs.lastIndex) {
target?.customDirectorySelected(currentDir) target?.customDirectorySelected(currentDir)
} else { } else {
target?.predefinedDirectorySelected(text.toString()) target?.predefinedDirectorySelected(text.toString())
} }
true
} }
.build()
} }
private fun getExternalDirs(): List<File> { private fun getExternalDirs(): List<File> {

View File

@ -6,6 +6,7 @@ import android.os.Handler
import android.view.View import android.view.View
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
@ -196,16 +197,14 @@ class SettingsLibraryController : SettingsController() {
private var landscape = preferences.landscapeColumns().getOrDefault() private var landscape = preferences.landscapeColumns().getOrDefault()
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val dialog = MaterialDialog.Builder(activity!!) val dialog = MaterialDialog(activity!!)
.title(R.string.pref_library_columns) .title(R.string.pref_library_columns)
.customView(R.layout.pref_library_columns, false) .customView(R.layout.pref_library_columns)
.positiveText(android.R.string.ok) .positiveButton(android.R.string.ok) {
.negativeText(android.R.string.cancel)
.onPositive { _, _ ->
preferences.portraitColumns().set(portrait) preferences.portraitColumns().set(portrait)
preferences.landscapeColumns().set(landscape) preferences.landscapeColumns().set(landscape)
} }
.build() .negativeButton(android.R.string.cancel)
onViewCreated(dialog.view) onViewCreated(dialog.view)
return dialog return dialog

View File

@ -10,6 +10,7 @@ import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItems
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
@ -121,18 +122,22 @@ class SourceController : NucleusController<SourceMainControllerBinding, SourcePr
val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
MaterialDialog.Builder(activity) MaterialDialog(activity)
.title(item.source.name) .title(text = item.source.name)
.items( .listItems(
items = listOf(
activity.getString(R.string.action_hide), activity.getString(R.string.action_hide),
activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin) activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin)
) ),
.itemsCallback { _, _, which, _ -> waitForPositiveButton = false
) { dialog, which, _ ->
when (which) { when (which) {
0 -> hideCatalogue(item.source) 0 -> hideCatalogue(item.source)
1 -> pinCatalogue(item.source, isPinned) 1 -> pinCatalogue(item.source, isPinned)
} }
}.show() dialog.dismiss()
}
.show()
} }
private fun hideCatalogue(source: Source) { private fun hideCatalogue(source: Source) {

View File

@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItems
import com.f2prateek.rx.preferences.Preference import com.f2prateek.rx.preferences.Preference
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -498,9 +499,11 @@ open class BrowseSourceController(bundle: Bundle) :
val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return
if (manga.favorite) { if (manga.favorite) {
MaterialDialog.Builder(activity) MaterialDialog(activity)
.items(activity.getString(R.string.remove_from_library)) .listItems(
.itemsCallback { _, _, which, _ -> items = listOf(activity.getString(R.string.remove_from_library)),
waitForPositiveButton = false
) { _, which, _ ->
when (which) { when (which) {
0 -> { 0 -> {
presenter.changeMangaFavorite(manga) presenter.changeMangaFavorite(manga)
@ -508,7 +511,8 @@ open class BrowseSourceController(bundle: Bundle) :
activity.toast(activity.getString(R.string.manga_removed_library)) activity.toast(activity.getString(R.string.manga_removed_library))
} }
} }
}.show() }
.show()
} else { } else {
val categories = presenter.getCategories() val categories = presenter.getCategories()
val defaultCategoryId = preferences.defaultCategory() val defaultCategoryId = preferences.defaultCategory()

View File

@ -6,6 +6,7 @@ import android.text.method.PasswordTransformationMethod
import android.view.View import android.view.View
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType import com.bluelinelabs.conductor.ControllerChangeType
import com.dd.processbutton.iml.ActionProcessButton import com.dd.processbutton.iml.ActionProcessButton
@ -35,16 +36,14 @@ abstract class LoginDialogPreference(
var requestSubscription: Subscription? = null var requestSubscription: Subscription? = null
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
var dialogBuilder = MaterialDialog.Builder(activity!!) var dialog = MaterialDialog(activity!!)
.customView(R.layout.pref_account_login, false) .customView(R.layout.pref_account_login)
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
if (titleRes != null) { 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) onViewCreated(dialog.view)
return dialog return dialog

View File

@ -18,16 +18,14 @@ class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) }) constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) })
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog.Builder(activity!!) return MaterialDialog(activity!!)
.title(activity!!.getString(R.string.logout_title, service.name)) .title(R.string.logout_title, service.name)
.positiveText(R.string.logout) .positiveButton(R.string.logout) {
.onPositive { _, _ ->
service.logout() service.logout()
(targetController as? Listener)?.trackLogoutDialogClosed(service) (targetController as? Listener)?.trackLogoutDialogClosed(service)
activity?.toast(R.string.logout_success) activity?.toast(R.string.logout_success)
} }
.negativeText(android.R.string.cancel) .negativeButton(android.R.string.cancel)
.build()
} }
interface Listener { interface Listener {

View File

@ -58,6 +58,13 @@
<item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item> <item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item> <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
<!-- Material Dialogs -->
<item name="md_background_color">?attr/colorSurface</item>
<item name="md_color_title">?attr/colorOnSurface</item>
<item name="md_color_content">?attr/colorOnSurface</item>
<item name="md_color_button_text">?attr/colorAccent</item>
<item name="md_corner_radius">@dimen/card_radius</item>
<!-- Custom Attributes--> <!-- Custom Attributes-->
<item name="colorLibrarySelection">?attr/colorAccent</item> <item name="colorLibrarySelection">?attr/colorAccent</item>
<item name="colorLibrarySelectionActive">@color/selectorColorLight</item> <item name="colorLibrarySelectionActive">@color/selectorColorLight</item>
@ -132,7 +139,12 @@
<item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item> <item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item> <item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
<!-- Material Dialogs -->
<item name="md_background_color">?attr/colorSurface</item> <item name="md_background_color">?attr/colorSurface</item>
<item name="md_color_title">?attr/colorOnSurface</item>
<item name="md_color_content">?attr/colorOnSurface</item>
<item name="md_color_button_text">?attr/colorAccent</item>
<item name="md_corner_radius">@dimen/card_radius</item>
<!-- Custom Attributes--> <!-- Custom Attributes-->
<item name="colorLibrarySelection">?attr/colorAccent</item> <item name="colorLibrarySelection">?attr/colorAccent</item>
@ -161,9 +173,6 @@
<!-- Some ROMs make black navbars white (e.g. OxygenOS) --> <!-- Some ROMs make black navbars white (e.g. OxygenOS) -->
<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:navigationBarColor">@android:color/transparent</item>
<!-- Themes -->
<item name="md_background_color">@color/colorAmoledPrimary</item>
<!-- Custom Attributes--> <!-- Custom Attributes-->
<item name="colorLibrarySelection">@color/selectorColorDark</item> <item name="colorLibrarySelection">@color/selectorColorDark</item>
<item name="colorLibrarySelectionActive">@color/selectorColorDark</item> <item name="colorLibrarySelectionActive">@color/selectorColorDark</item>