mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:55:09 +01:00
Using new material dialog libraty
Co-Authored-By: Carlos <carlosesco@users.noreply.github.com>
This commit is contained in:
parent
c8656526df
commit
c143490f5a
@ -6,10 +6,8 @@ object BackupConst {
|
||||
|
||||
const val INTENT_FILTER = "SettingsBackupFragment"
|
||||
const val ACTION_BACKUP_COMPLETED_DIALOG = "$ID.$INTENT_FILTER.ACTION_BACKUP_COMPLETED_DIALOG"
|
||||
const val ACTION_SET_PROGRESS_DIALOG = "$ID.$INTENT_FILTER.ACTION_SET_PROGRESS_DIALOG"
|
||||
const val ACTION_ERROR_BACKUP_DIALOG = "$ID.$INTENT_FILTER.ACTION_ERROR_BACKUP_DIALOG"
|
||||
const val ACTION_ERROR_RESTORE_DIALOG = "$ID.$INTENT_FILTER.ACTION_ERROR_RESTORE_DIALOG"
|
||||
const val ACTION_RESTORE_COMPLETED_DIALOG = "$ID.$INTENT_FILTER.ACTION_RESTORE_COMPLETED_DIALOG"
|
||||
const val ACTION = "$ID.$INTENT_FILTER.ACTION"
|
||||
const val EXTRA_PROGRESS = "$ID.$INTENT_FILTER.EXTRA_PROGRESS"
|
||||
const val EXTRA_AMOUNT = "$ID.$INTENT_FILTER.EXTRA_AMOUNT"
|
||||
|
@ -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
|
||||
@ -13,11 +14,6 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
class CategoryCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
where T : Controller, T : CategoryCreateDialog.Listener {
|
||||
|
||||
/**
|
||||
* Name of the new category. Value updated with each input from the user.
|
||||
*/
|
||||
private var currentName = ""
|
||||
|
||||
constructor(target: T) : this() {
|
||||
targetController = target
|
||||
}
|
||||
@ -29,15 +25,13 @@ 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 ->
|
||||
currentName = input.toString()
|
||||
.positiveButton(android.R.string.ok)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.input(hintRes = R.string.name) { _, input ->
|
||||
(targetController as? Listener)?.createCategory(input.toString())
|
||||
}
|
||||
.onPositive { _, _ -> (targetController as? Listener)?.createCategory(currentName) }
|
||||
.build()
|
||||
}
|
||||
|
||||
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,13 @@ 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(hintRes = R.string.name, prefill = currentName) { _, input ->
|
||||
currentName = input.toString()
|
||||
}
|
||||
.onPositive { _, _ -> onPositive() }
|
||||
.build()
|
||||
.positiveButton(android.R.string.ok)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
@ -28,17 +29,18 @@ class ChangeMangaCategoriesDialog<T>(bundle: Bundle? = null) :
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.action_move_category)
|
||||
.items(categories.map { it.name })
|
||||
.itemsCallbackMultiChoice(preselected) { dialog, _, _ ->
|
||||
val newCategories = dialog.selectedIndices?.map { categories[it] }.orEmpty()
|
||||
(targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories)
|
||||
true
|
||||
}
|
||||
.positiveText(android.R.string.ok)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.action_move_category)
|
||||
.listItemsMultiChoice(
|
||||
items = categories.map { it.name },
|
||||
initialSelection = preselected.toIntArray(),
|
||||
allowEmptySelection = true
|
||||
) { _, selections, _ ->
|
||||
val newCategories = selections.map { categories[it] }
|
||||
(targetController as? Listener)?.updateCategoriesForMangas(mangas, newCategories)
|
||||
}
|
||||
.positiveButton(android.R.string.ok)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
||||
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) "Notices" else "Changelog")
|
||||
.customView(view, false)
|
||||
.positiveText(android.R.string.yes)
|
||||
.build()
|
||||
return MaterialDialog(activity)
|
||||
.title(text = if (BuildConfig.DEBUG) "Notices" else "Changelog")
|
||||
.customView(view = view, scrollable = false)
|
||||
.positiveButton(android.R.string.yes)
|
||||
}
|
||||
|
||||
class WhatsNewRecyclerView(context: Context) : ChangeLogRecyclerView(context) {
|
||||
|
@ -491,13 +491,10 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
fun deleteChapters(chapters: List<ChapterItem>) {
|
||||
destroyActionModeIfNeeded()
|
||||
if (chapters.isEmpty()) return
|
||||
|
||||
DeletingChaptersDialog().showDialog(router)
|
||||
presenter.deleteChapters(chapters)
|
||||
}
|
||||
|
||||
fun onChaptersDeleted(chapters: List<ChapterItem>) {
|
||||
dismissDeletingDialog()
|
||||
//this is needed so the downloaded text gets removed from the item
|
||||
chapters.forEach {
|
||||
adapter?.updateItem(it)
|
||||
@ -506,14 +503,9 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
fun onChaptersDeletedError(error: Throwable) {
|
||||
dismissDeletingDialog()
|
||||
Timber.e(error)
|
||||
}
|
||||
|
||||
private fun dismissDeletingDialog() {
|
||||
router.popControllerWithTag(DeletingChaptersDialog.TAG)
|
||||
}
|
||||
|
||||
// OVERFLOW MENU DIALOGS
|
||||
|
||||
private fun showDisplayModeDialog() {
|
||||
|
@ -15,14 +15,13 @@ 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.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
(targetController as? Listener)?.deleteChapters()
|
||||
}
|
||||
.show()
|
||||
return MaterialDialog(activity!!).show {
|
||||
message(R.string.confirm_delete_chapters)
|
||||
positiveButton(android.R.string.yes) {
|
||||
(targetController as? Listener)?.deleteChapters()
|
||||
}
|
||||
negativeButton(android.R.string.no)
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
|
@ -1,27 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
|
||||
class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "deleting_dialog"
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.progress(true, 0)
|
||||
.content(R.string.deleting)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun showDialog(router: Router) {
|
||||
showDialog(router, TAG)
|
||||
}
|
||||
|
||||
}
|
@ -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.list.listItems
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
@ -26,14 +27,13 @@ class DownloadChaptersDialog<T>(bundle: Bundle? = null) : DialogController(bundl
|
||||
R.string.download_all
|
||||
).map { activity.getString(it) }
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.manga_download)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.items(choices)
|
||||
.itemsCallback { _, _, position, _ ->
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.listItems(items = choices){dialog, position, _ ->
|
||||
(targetController as? Listener)?.downloadChapters(position)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -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.list.listItemsSingleChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -25,15 +26,12 @@ class SetDisplayModeDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
val choices = intArrayOf(R.string.show_title, R.string.show_chapter_number)
|
||||
.map { activity.getString(it) }
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.action_display_mode)
|
||||
.items(choices)
|
||||
.itemsIds(ids)
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, itemView, _, _ ->
|
||||
(targetController as? Listener)?.setDisplayMode(itemView.id)
|
||||
true
|
||||
.listItemsSingleChoice(items = choices, initialSelection = selectedIndex)
|
||||
{_, position, _ ->
|
||||
(targetController as? Listener)?.setDisplayMode(ids[position])
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
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.list.listItemsSingleChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -25,15 +26,12 @@ class SetSortingDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
val choices = intArrayOf(R.string.sort_by_source, R.string.sort_by_number)
|
||||
.map { activity.getString(it) }
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.sorting_mode)
|
||||
.items(choices)
|
||||
.itemsIds(ids)
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, itemView, _, _ ->
|
||||
(targetController as? Listener)?.setSorting(itemView.id)
|
||||
true
|
||||
.listItemsSingleChoice(items = choices, initialSelection = selectedIndex){
|
||||
_, position, _ ->
|
||||
(targetController as? Listener)?.setSorting(ids[position])
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
|
@ -21,11 +21,9 @@ import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.bumptech.glide.signature.ObjectKey
|
||||
@ -62,7 +60,6 @@ import eu.kanade.tachiyomi.util.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.updatePaddingRelative
|
||||
import jp.wasabeef.glide.transformations.CropSquareTransformation
|
||||
import jp.wasabeef.glide.transformations.MaskTransformation
|
||||
import kotlinx.android.synthetic.main.catalogue_list_item.*
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.*
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
@ -554,14 +551,14 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
R.string.square_icon,
|
||||
R.string.star_icon)
|
||||
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.icon_shape)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.items(modes.map { activity?.getString(it) })
|
||||
.itemsCallback { _, _, i, _ ->
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.listItemsSingleChoice (
|
||||
items = modes.map { activity?.getString(it) as CharSequence })
|
||||
{ _, i, _ ->
|
||||
(targetController as? MangaInfoController)?.createShortcutForShape(i)
|
||||
}
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,31 +36,25 @@ class SetTrackChaptersDialog<T> : DialogController
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val item = item
|
||||
|
||||
val dialog = MaterialDialog.Builder(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()
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
.title(R.string.chapters)
|
||||
.customView(viewRes = R.layout.track_chapters_dialog, scrollable = false)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.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()
|
||||
val view = dialog.getCustomView()
|
||||
val np: NumberPicker = view.findViewById(R.id.chapters_picker)
|
||||
// Set initial value
|
||||
np.value = item.track?.last_chapter_read ?: 0
|
||||
// Don't allow to go from 0 to 9999
|
||||
np.wrapSelectorWheel = false
|
||||
|
||||
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
|
||||
// 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,32 @@ class SetTrackScoreDialog<T> : DialogController
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val item = item
|
||||
|
||||
val dialog = MaterialDialog.Builder(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()
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
.title(R.string.score)
|
||||
.customView(R.layout.track_score_dialog, scrollable = false)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.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)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
(targetController as? Listener)?.setScore(item, np.value)
|
||||
|
||||
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
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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,14 @@ class SetTrackStatusDialog<T> : DialogController
|
||||
val statusString = statusList.mapNotNull { item.service.getStatus(it) }
|
||||
val selectedIndex = statusList.indexOf(item.track?.status)
|
||||
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.status)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.items(statusString)
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, _, i, _ ->
|
||||
(targetController as? Listener)?.setStatus(item, i)
|
||||
true
|
||||
}
|
||||
.build()
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.status)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.listItemsSingleChoice(items = statusString, initialSelection = selectedIndex)
|
||||
{ dialog, position, _ ->
|
||||
(targetController as? Listener)?.setStatus(item, position)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
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 com.jakewharton.rxbinding.widget.itemClicks
|
||||
import com.jakewharton.rxbinding.widget.textChanges
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -51,12 +52,10 @@ 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)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive { _, _ -> onPositiveButtonClick() }
|
||||
.build()
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
.customView(viewRes = R.layout.track_search_dialog, scrollable = false)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.positiveButton(android.R.string.ok) { onPositiveButtonClick() }
|
||||
|
||||
if (subscriptions.isUnsubscribed) {
|
||||
subscriptions = CompositeSubscription()
|
||||
|
@ -105,16 +105,6 @@ class MigrationController : NucleusController<MigrationPresenter>(),
|
||||
}
|
||||
}
|
||||
|
||||
fun renderIsReplacingManga(state: ViewState) {
|
||||
if (state.isReplacingManga) {
|
||||
if (router.getControllerWithTag(LOADING_DIALOG_TAG) == null) {
|
||||
LoadingController().showDialog(router, LOADING_DIALOG_TAG)
|
||||
}
|
||||
} else {
|
||||
router.popControllerWithTag(LOADING_DIALOG_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(view: View?, position: Int): Boolean {
|
||||
val item = adapter?.getItem(position) ?: return false
|
||||
|
||||
@ -157,22 +147,6 @@ class MigrationController : NucleusController<MigrationPresenter>(),
|
||||
presenter.migrateManga(prevManga, manga, replace)
|
||||
return null
|
||||
}
|
||||
|
||||
class LoadingController : DialogController() {
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.progress(true, 0)
|
||||
.content(R.string.migrating)
|
||||
.cancelable(false)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LOADING_DIALOG_TAG = "LoadingDialog"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface MigrationInterface {
|
||||
|
@ -27,15 +27,13 @@ class MigrationMangaDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
if (mangaSkipped > 0)
|
||||
" " + applicationContext?.getString(R.string.skipping_x, mangaSkipped) ?: ""
|
||||
else "")) ?: ""
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.content(confirmString)
|
||||
.positiveText(android.R.string.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
if (copy)
|
||||
(targetController as? MigrationListController)?.copyMangas()
|
||||
else
|
||||
(targetController as? MigrationListController)?.migrateMangas()
|
||||
}.show()
|
||||
return MaterialDialog(activity!!).show {
|
||||
message(text = confirmString)
|
||||
positiveButton(android.R.string.yes) {
|
||||
if (copy) (targetController as? MigrationListController)?.copyMangas()
|
||||
else (targetController as? MigrationListController)?.migrateMangas()
|
||||
}
|
||||
negativeButton(android.R.string.no)
|
||||
}
|
||||
}
|
||||
}
|
@ -56,8 +56,8 @@ class MigrationPresenter(
|
||||
.distinctUntilChanged { t1, t2 -> t1.isReplacingManga != t2.isReplacingManga }
|
||||
.subscribeLatestCache(MigrationController::render)
|
||||
|
||||
stateRelay.distinctUntilChanged { state -> state.isReplacingManga }
|
||||
.subscribeLatestCache(MigrationController::renderIsReplacingManga)
|
||||
/* stateRelay.distinctUntilChanged { state -> state.isReplacingManga }
|
||||
.subscribeLatestCache(MigrationController::renderIsReplacingManga)*/
|
||||
}
|
||||
|
||||
fun setSelectedSource(source: Source) {
|
||||
|
@ -7,6 +7,7 @@ import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
||||
import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -137,27 +138,20 @@ 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, _ ->
|
||||
// Save current settings for the next time
|
||||
val newValue = MigrationFlags.getFlagsFromPositions(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, _ ->
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -113,16 +113,6 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
}
|
||||
}
|
||||
|
||||
fun migrationFailure() {
|
||||
activity?.let {
|
||||
MaterialDialog.Builder(it)
|
||||
.title("Migration failure")
|
||||
.content("An unknown error occured while migrating this manga!")
|
||||
.positiveText("Ok")
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun runMigrations(mangas: List<MigratingManga>) {
|
||||
val useSourceWithMost = preferences.useSourceWithMost().getOrDefault()
|
||||
|
||||
@ -381,14 +371,14 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
|
||||
override fun handleBack(): Boolean {
|
||||
activity?.let {
|
||||
MaterialDialog.Builder(it).title(R.string.stop_migration)
|
||||
.positiveText(R.string.yes)
|
||||
.negativeText(R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
MaterialDialog(it).show {
|
||||
title(R.string.stop_migration)
|
||||
positiveButton (R.string.yes) {
|
||||
router.popCurrentController()
|
||||
migrationsJob?.cancel()
|
||||
}
|
||||
.show()
|
||||
negativeButton(R.string.no)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -44,14 +44,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.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
MaterialDialog(activity)
|
||||
.title(R.string.confirm_set_image_as_cover)
|
||||
.positiveButton(android.R.string.yes) {
|
||||
activity.setAsCover(page)
|
||||
dismiss()
|
||||
}
|
||||
.negativeButton(android.R.string.no)
|
||||
.show()
|
||||
}
|
||||
|
||||
|
@ -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.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
return MaterialDialog(activity!!)
|
||||
.message(R.string.confirm_delete_chapters)
|
||||
.positiveButton(android.R.string.yes) {
|
||||
(targetController as? Listener)?.deleteChapters(chaptersToDelete)
|
||||
}
|
||||
.build()
|
||||
.negativeButton(android.R.string.no)
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
|
@ -1,27 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.recent_updates
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
|
||||
class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "deleting_dialog"
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.progress(true, 0)
|
||||
.content(R.string.deleting)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun showDialog(router: Router) {
|
||||
showDialog(router, TAG)
|
||||
}
|
||||
|
||||
}
|
@ -216,14 +216,13 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
|
||||
override fun deleteChapters(chaptersToDelete: List<RecentChapterItem>) {
|
||||
destroyActionModeIfNeeded()
|
||||
DeletingChaptersDialog().showDialog(router)
|
||||
presenter.deleteChapters(chaptersToDelete)
|
||||
}
|
||||
|
||||
/**
|
||||
* Destory [ActionMode] if it's shown
|
||||
*/
|
||||
fun destroyActionModeIfNeeded() {
|
||||
private fun destroyActionModeIfNeeded() {
|
||||
actionMode?.finish()
|
||||
}
|
||||
|
||||
@ -248,7 +247,6 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
* @param chapter selected chapter with manga
|
||||
*/
|
||||
fun deleteChapter(chapter: RecentChapterItem) {
|
||||
DeletingChaptersDialog().showDialog(router)
|
||||
presenter.deleteChapters(listOf(chapter))
|
||||
}
|
||||
|
||||
@ -266,7 +264,6 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
* Called when chapters are deleted
|
||||
*/
|
||||
fun onChaptersDeleted() {
|
||||
dismissDeletingDialog()
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@ -275,17 +272,9 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
|
||||
* @param error error message
|
||||
*/
|
||||
fun onChaptersDeletedError(error: Throwable) {
|
||||
dismissDeletingDialog()
|
||||
Timber.e(error)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to dismiss deleting dialog
|
||||
*/
|
||||
fun dismissDeletingDialog() {
|
||||
router.popControllerWithTag(DeletingChaptersDialog.TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when ActionMode created.
|
||||
* @param mode the ActionMode object
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.recently_read
|
||||
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,12 @@ 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, scrollable = true)
|
||||
.positiveButton(R.string.action_remove) { onPositive(dialogCheckboxView.isChecked
|
||||
()) }
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
||||
private fun onPositive(checked: Boolean) {
|
||||
|
@ -128,12 +128,10 @@ class SettingsAboutController : SettingsController() {
|
||||
})
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.update_check_title)
|
||||
.content(args.getString(BODY_KEY) ?: "")
|
||||
.positiveText(R.string.update_check_confirm)
|
||||
.negativeText(R.string.update_check_ignore)
|
||||
.onPositive { _, _ ->
|
||||
.message(text = args.getString(BODY_KEY) ?: "")
|
||||
.positiveButton(R.string.update_check_confirm) {
|
||||
val appContext = applicationContext
|
||||
if (appContext != null) {
|
||||
// Start download
|
||||
@ -141,7 +139,7 @@ class SettingsAboutController : SettingsController() {
|
||||
UpdaterService.downloadUpdate(appContext, url)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
.negativeButton(R.string.update_check_ignore)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
@ -84,10 +84,6 @@ class SettingsAdvancedController : SettingsController() {
|
||||
|
||||
var deletedFiles = 0
|
||||
|
||||
val ctrl = DeletingFilesDialogController()
|
||||
ctrl.total = files.size
|
||||
ctrl.showDialog(router)
|
||||
|
||||
Observable.defer { Observable.from(files) }
|
||||
.doOnNext { file ->
|
||||
if (chapterCache.removeFileFromCache(file.name)) {
|
||||
@ -97,61 +93,23 @@ class SettingsAdvancedController : SettingsController() {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
ctrl.setProgress(deletedFiles)
|
||||
}, {
|
||||
activity?.toast(R.string.cache_delete_error)
|
||||
}, {
|
||||
ctrl.finish()
|
||||
activity?.toast(resources?.getString(R.string.cache_deleted, deletedFiles))
|
||||
findPreference(CLEAR_CACHE_KEY)?.summary =
|
||||
resources?.getString(R.string.used_cache, chapterCache.readableSize)
|
||||
})
|
||||
}
|
||||
|
||||
class DeletingFilesDialogController : DialogController() {
|
||||
|
||||
var total = 0
|
||||
|
||||
private var materialDialog: MaterialDialog? = null
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.deleting)
|
||||
.progress(false, total, true)
|
||||
.cancelable(false)
|
||||
.build()
|
||||
.also { materialDialog = it }
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
materialDialog = null
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
finish()
|
||||
}
|
||||
|
||||
fun setProgress(deletedFiles: Int) {
|
||||
materialDialog?.setProgress(deletedFiles)
|
||||
}
|
||||
|
||||
fun finish() {
|
||||
router.popController(this)
|
||||
}
|
||||
}
|
||||
|
||||
class ClearDatabaseDialogController : DialogController() {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.content(R.string.clear_database_confirmation)
|
||||
.positiveText(android.R.string.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
return MaterialDialog(activity!!)
|
||||
.message(R.string.clear_database_confirmation)
|
||||
.positiveButton(android.R.string.yes) {
|
||||
(targetController as? SettingsAdvancedController)?.clearDatabase()
|
||||
}
|
||||
.build()
|
||||
.negativeButton(android.R.string.no)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,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
|
||||
@ -168,7 +169,6 @@ class SettingsBackupController : SettingsController() {
|
||||
|
||||
val file = UniFile.fromUri(activity, uri)
|
||||
|
||||
CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG)
|
||||
BackupCreateService.makeBackup(activity, file.uri, backupFlags)
|
||||
}
|
||||
CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) {
|
||||
@ -207,12 +207,12 @@ 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))
|
||||
{ _, positions, _ ->
|
||||
var flags = 0
|
||||
for (i in 1 until positions.size) {
|
||||
when (positions[i]) {
|
||||
@ -224,27 +224,9 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
|
||||
(targetController as? SettingsBackupController)?.createBackup(flags)
|
||||
true
|
||||
}
|
||||
.positiveText(R.string.action_create)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
class CreatingBackupDialog : DialogController() {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.backup)
|
||||
.content(R.string.creating_backup)
|
||||
.progress(true, 0)
|
||||
.cancelable(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
router.popController(this)
|
||||
.positiveButton(R.string.action_create)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,18 +238,16 @@ class SettingsBackupController : SettingsController() {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val unifile = UniFile.fromUri(activity, args.getParcelable(KEY_URI))
|
||||
return MaterialDialog.Builder(activity)
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.backup_created)
|
||||
.content(activity.getString(R.string.file_saved, unifile.filePath))
|
||||
.positiveText(R.string.action_close)
|
||||
.negativeText(R.string.action_export)
|
||||
.onNegative { _, _ ->
|
||||
.message(R.string.file_saved, unifile.filePath)
|
||||
.positiveButton(R.string.action_close)
|
||||
.negativeButton(R.string.action_export) {
|
||||
val sendIntent = Intent(Intent.ACTION_SEND)
|
||||
sendIntent.type = "application/json"
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, unifile.uri)
|
||||
startActivity(Intent.createChooser(sendIntent, ""))
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@ -281,18 +261,16 @@ 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) {
|
||||
activity?.toast(R.string.restoring_backup)
|
||||
BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@ -300,102 +278,6 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
class RestoringBackupDialog : DialogController() {
|
||||
private var materialDialog: MaterialDialog? = null
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.backup)
|
||||
.content(R.string.restoring_backup)
|
||||
.progress(false, 100, true)
|
||||
.cancelable(false)
|
||||
.negativeText(R.string.action_stop)
|
||||
.onNegative { _, _ ->
|
||||
applicationContext?.let { BackupRestoreService.stop(it) }
|
||||
}
|
||||
.build()
|
||||
.also { materialDialog = it }
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
materialDialog = null
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
router.popController(this)
|
||||
}
|
||||
|
||||
fun updateProgress(content: String?, progress: Int, amount: Int) {
|
||||
val dialog = materialDialog ?: return
|
||||
dialog.setContent(content)
|
||||
dialog.setProgress(progress)
|
||||
dialog.maxProgress = amount
|
||||
}
|
||||
}
|
||||
|
||||
class RestoredBackupDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
constructor(time: Long, errorCount: Int, path: String, file: String, errors: String) : this
|
||||
(Bundle().apply {
|
||||
putLong(KEY_TIME, time)
|
||||
putInt(KEY_ERROR_COUNT, errorCount)
|
||||
putString(KEY_PATH, path)
|
||||
putString(KEY_FILE, file)
|
||||
putString(KEY_MINI_ERRORS, errors)
|
||||
})
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val time = args.getLong(KEY_TIME)
|
||||
val errors = args.getInt(KEY_ERROR_COUNT)
|
||||
val path = args.getString(KEY_PATH)
|
||||
val file = args.getString(KEY_FILE)
|
||||
val miniErrors = args.getString(KEY_MINI_ERRORS)
|
||||
val timeString = String.format("%02d min, %02d sec",
|
||||
TimeUnit.MILLISECONDS.toMinutes(time),
|
||||
TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(
|
||||
TimeUnit.MILLISECONDS.toMinutes(time))
|
||||
)
|
||||
|
||||
var errorString = activity.getString(R.string.restore_completed_content, timeString,
|
||||
if (errors > 0) "$errors" else activity.getString(android.R.string
|
||||
.no))
|
||||
if (errors > 0)
|
||||
errorString = errorString.trimEnd('.') + ":"
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
.title(R.string.restore_completed)
|
||||
.content("$errorString\n$miniErrors")
|
||||
.positiveText(R.string.action_close)
|
||||
.negativeText(R.string.action_open_log)
|
||||
.onNegative { _, _ ->
|
||||
val context = applicationContext ?: return@onNegative
|
||||
if (!path.isNullOrEmpty()) {
|
||||
val destFile = File(path, file)
|
||||
val uri = destFile.getUriCompat(context)
|
||||
val sendIntent = Intent(Intent.ACTION_VIEW).apply {
|
||||
setDataAndType(uri, "text/plain")
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
startActivity(sendIntent)
|
||||
} else {
|
||||
context.toast(context.getString(R.string.error_opening_log))
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val KEY_TIME = "RestoredBackupDialog.time"
|
||||
const val KEY_ERROR_COUNT = "RestoredBackupDialog.errors"
|
||||
const val KEY_PATH = "RestoredBackupDialog.path"
|
||||
const val KEY_FILE = "RestoredBackupDialog.file"
|
||||
const val KEY_MINI_ERRORS = "RestoredBackupDialog.miniErrors"
|
||||
}
|
||||
}
|
||||
|
||||
inner class BackupBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.getStringExtra(BackupConst.ACTION)) {
|
||||
@ -404,24 +286,6 @@ class SettingsBackupController : SettingsController() {
|
||||
val uri = Uri.parse(intent.getStringExtra(BackupConst.EXTRA_URI))
|
||||
CreatedBackupDialog(uri).showDialog(router)
|
||||
}
|
||||
BackupConst.ACTION_SET_PROGRESS_DIALOG -> {
|
||||
val progress = intent.getIntExtra(BackupConst.EXTRA_PROGRESS, 0)
|
||||
val amount = intent.getIntExtra(BackupConst.EXTRA_AMOUNT, 0)
|
||||
val content = intent.getStringExtra(BackupConst.EXTRA_CONTENT)
|
||||
(router.getControllerWithTag(TAG_RESTORING_BACKUP_DIALOG)
|
||||
as? RestoringBackupDialog)?.updateProgress(content, progress, amount)
|
||||
}
|
||||
BackupConst.ACTION_RESTORE_COMPLETED_DIALOG -> {
|
||||
router.popControllerWithTag(TAG_RESTORING_BACKUP_DIALOG)
|
||||
val time = intent.getLongExtra(BackupConst.EXTRA_TIME, 0)
|
||||
val errors = intent.getIntExtra(BackupConst.EXTRA_ERRORS, 0)
|
||||
val path = intent.getStringExtra(BackupConst.EXTRA_ERROR_FILE_PATH)
|
||||
val file = intent.getStringExtra(BackupConst.EXTRA_ERROR_FILE)
|
||||
val miniErrors = intent.getStringExtra(BackupConst.EXTRA_MINI_ERROR)
|
||||
if (errors > 0) {
|
||||
RestoredBackupDialog(time, errors, path, file, miniErrors).showDialog(router)
|
||||
}
|
||||
}
|
||||
BackupConst.ACTION_ERROR_BACKUP_DIALOG -> {
|
||||
router.popControllerWithTag(TAG_CREATING_BACKUP_DIALOG)
|
||||
context.toast(intent.getStringExtra(BackupConst.EXTRA_ERROR_MESSAGE))
|
||||
|
@ -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
|
||||
@ -147,18 +148,16 @@ class SettingsDownloadController : SettingsController() {
|
||||
val externalDirs = getExternalDirs() + File(activity.getString(R.string.custom_dir))
|
||||
val selectedIndex = externalDirs.map(File::toString).indexOfFirst { it in currentDir }
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
.items(externalDirs)
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, _, which, text ->
|
||||
val target = targetController as? SettingsDownloadController
|
||||
if (which == externalDirs.lastIndex) {
|
||||
target?.customDirectorySelected(currentDir)
|
||||
} else {
|
||||
target?.predefinedDirectorySelected(text.toString())
|
||||
}
|
||||
true
|
||||
return MaterialDialog(activity)
|
||||
.listItemsSingleChoice(items = externalDirs.map { it.path }, initialSelection = selectedIndex)
|
||||
{ _, position, text ->
|
||||
val target = targetController as? SettingsDownloadController
|
||||
if (position == externalDirs.lastIndex) {
|
||||
target?.customDirectorySelected(currentDir)
|
||||
} else {
|
||||
target?.predefinedDirectorySelected(text.toString())
|
||||
}
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getExternalDirs(): List<File> {
|
||||
|
@ -7,6 +7,7 @@ import android.view.View
|
||||
import androidx.biometric.BiometricManager
|
||||
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
|
||||
@ -186,16 +187,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(viewRes = R.layout.pref_library_columns, scrollable = false)
|
||||
.positiveButton(android.R.string.ok) {
|
||||
preferences.portraitColumns().set(portrait)
|
||||
preferences.landscapeColumns().set(landscape)
|
||||
}
|
||||
.build()
|
||||
.negativeButton(android.R.string.cancel)
|
||||
|
||||
onViewCreated(dialog.view)
|
||||
return dialog
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.View
|
||||
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
|
||||
@ -26,10 +27,9 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(
|
||||
var requestSubscription: Subscription? = null
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val dialog = MaterialDialog.Builder(activity!!)
|
||||
.customView(R.layout.pref_account_login, false)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
.customView(R.layout.pref_account_login, scrollable = false)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
|
||||
onViewCreated(dialog.view)
|
||||
|
||||
|
@ -242,7 +242,7 @@
|
||||
<string name="restoring_backup">S\'està restaurant la còpia de seguretat</string>
|
||||
<string name="creating_backup">S\'està creant la còpia de seguretat</string>
|
||||
<string name="pref_clear_chapter_cache">Buida la memòria cau de capítols</string>
|
||||
<string name="used_cache">Ús: $1$s</string>
|
||||
<string name="used_cache">Ús: %1$s</string>
|
||||
<string name="cache_deleted">S\'ha buidat la memòria cau. S\'han suprimit %1$d fitxers</string>
|
||||
<string name="cache_delete_error">S\'ha produït un error en buidar la memòria cau</string>
|
||||
<string name="pref_clear_cookies">Esborra les galetes</string>
|
||||
|
@ -20,7 +20,6 @@
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="md_background_color">@color/dialogDark</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
|
||||
@ -35,6 +34,14 @@
|
||||
<item name="snackbar_background">@color/snackbarBackground</item>
|
||||
<item name="snackbar_text">@color/textColorPrimaryLight</item>
|
||||
<item name="android:navigationBarColor">@color/oldNavBarBackground</item>
|
||||
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_color_title">@color/textColorPrimaryDark</item>
|
||||
<item name="md_color_content">@color/textColorSecondaryDark</item>
|
||||
<item name="md_color_button_text">@color/colorAccentDark</item>
|
||||
<item name="md_background_color">@color/dialogDark</item>
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Base.Reader" parent="Theme.Base">
|
||||
@ -64,5 +71,13 @@
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_amoled</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_amoled</item>
|
||||
<item name="background_card">@color/dialog_amoled</item>
|
||||
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_color_title">@color/textColorPrimaryDark</item>
|
||||
<item name="md_color_content">@color/textColorSecondaryDark</item>
|
||||
<item name="md_color_button_text">@color/colorAccentDark</item>
|
||||
<item name="md_background_color">@color/dialog_amoled</item>
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
</style>
|
||||
</resources>
|
@ -28,7 +28,6 @@
|
||||
<item name="actionBarTheme">@style/Theme.ActionBar.Light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Light</item>
|
||||
<item name="md_background_color">@color/dialogLight</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
@ -43,6 +42,13 @@
|
||||
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">#B3000000</item>
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_color_title">@color/textColorPrimaryLight</item>
|
||||
<item name="md_color_content">@color/textColorSecondaryLight</item>
|
||||
<item name="md_color_button_text">@color/colorAccent</item>
|
||||
<item name="md_background_color">@color/dialogLight</item>
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base"/>
|
||||
|
Loading…
Reference in New Issue
Block a user