pull/1395/head
gedoor 3 years ago
parent 21a02abbbf
commit 24d12119e2
  1. 35
      app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt
  2. 2
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  3. 2
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  5. 2
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  6. 2
      app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt
  9. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  10. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  11. 4
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  12. 4
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  13. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  14. 4
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  15. 2
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  16. 4
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  17. 2
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt
  18. 2
      app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
  19. 8
      app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
  20. 4
      app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt
  21. 4
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  22. 2
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -8,17 +8,11 @@ import android.content.DialogInterface
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
inline fun Fragment.alert(
title: CharSequence? = null,
message: CharSequence? = null,
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
) = requireActivity().alert(title, message, init)
fun Context.alert( fun Context.alert(
title: CharSequence? = null, title: CharSequence? = null,
message: CharSequence? = null, message: CharSequence? = null,
init: (AlertBuilder<DialogInterface>.() -> Unit)? = null init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
): AlertBuilder<AlertDialog> { ): AlertDialog {
return AndroidAlertBuilder(this).apply { return AndroidAlertBuilder(this).apply {
if (title != null) { if (title != null) {
this.setTitle(title) this.setTitle(title)
@ -27,20 +21,20 @@ fun Context.alert(
this.setMessage(message) this.setMessage(message)
} }
if (init != null) init() if (init != null) init()
} }.show()
} }
inline fun Fragment.alert( inline fun Fragment.alert(
titleResource: Int? = null, title: CharSequence? = null,
message: Int? = null, message: CharSequence? = null,
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
) = requireActivity().alert(titleResource, message, init) ) = requireActivity().alert(title, message, init)
fun Context.alert( fun Context.alert(
titleResource: Int? = null, titleResource: Int? = null,
messageResource: Int? = null, messageResource: Int? = null,
init: (AlertBuilder<DialogInterface>.() -> Unit)? = null init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
): AlertBuilder<AlertDialog> { ): AlertDialog {
return AndroidAlertBuilder(this).apply { return AndroidAlertBuilder(this).apply {
if (titleResource != null) { if (titleResource != null) {
this.setTitle(titleResource) this.setTitle(titleResource)
@ -49,18 +43,23 @@ fun Context.alert(
this.setMessage(messageResource) this.setMessage(messageResource)
} }
if (init != null) init() if (init != null) init()
}.apply { }.show()
show()
}
} }
inline fun Fragment.alert(
titleResource: Int? = null,
message: Int? = null,
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
) = requireActivity().alert(titleResource, message, init)
fun Context.alert(init: AlertBuilder<AlertDialog>.() -> Unit): AlertDialog =
AndroidAlertBuilder(this).apply {
init()
}.show()
inline fun Fragment.alert(noinline init: AlertBuilder<DialogInterface>.() -> Unit) = inline fun Fragment.alert(noinline init: AlertBuilder<DialogInterface>.() -> Unit) =
requireContext().alert(init) requireContext().alert(init)
fun Context.alert(init: AlertBuilder<AlertDialog>.() -> Unit): AlertBuilder<AlertDialog> =
AndroidAlertBuilder(this).apply { init() }
inline fun Fragment.progressDialog( inline fun Fragment.progressDialog(
title: Int? = null, title: Int? = null,
message: Int? = null, message: Int? = null,

@ -105,7 +105,7 @@ class AboutFragment : PreferenceFragmentCompat() {
} }
} }
} }
}.show() }
} }
private fun joinQQGroup(key: String): Boolean { private fun joinQQGroup(key: String): Boolean {

@ -195,7 +195,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickLi
} }
} }
noButton() noButton()
}.show() }
} }
inner class SourcesAdapter(context: Context) : inner class SourcesAdapter(context: Context) :

@ -171,7 +171,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickL
} }
} }
noButton() noButton()
}.show() }
} }
private fun upSelectText() { private fun upSelectText() {

@ -194,7 +194,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickLis
} }
} }
noButton() noButton()
}.show() }
} }
inner class SourcesAdapter(context: Context) : inner class SourcesAdapter(context: Context) :

@ -90,7 +90,7 @@ class OnLineImportActivity :
onDismiss { onDismiss {
finish() finish()
} }
}.show() }
} }
} }

@ -203,7 +203,7 @@ class AudioPlayActivity :
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
} }
noButton { viewModel.removeFromBookshelf { super.finish() } } noButton { viewModel.removeFromBookshelf { super.finish() } }
}.show() }
} else { } else {
super.finish() super.finish()
} }

@ -107,7 +107,7 @@ class GroupEditDialog() : BaseDialogFragment() {
ok.invoke() ok.invoke()
} }
noButton() noButton()
}.show() }
} }
} }

@ -384,7 +384,7 @@ class BookInfoActivity :
} }
} }
negativeButton(R.string.no) negativeButton(R.string.no)
}.show() }
} else { } else {
viewModel.delBook { viewModel.delBook {
upTvBookshelf() upTvBookshelf()

@ -934,7 +934,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
} }
noButton { viewModel.removeFromBookshelf { super.finish() } } noButton { viewModel.removeFromBookshelf { super.finish() } }
}.show() }
} else { } else {
super.finish() super.finish()
} }

@ -150,7 +150,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
} }
} }
cancelButton() cancelButton()
}.show() }
} }
binding.tvRestore.setOnClickListener { binding.tvRestore.setOnClickListener {
val defaultConfigs = DefaultData.readConfigs val defaultConfigs = DefaultData.readConfigs
@ -297,7 +297,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
} }
} }
noButton() noButton()
}.show() }
} }
private fun importNetConfig(url: String) { private fun importNetConfig(url: String) {

@ -64,7 +64,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
okButton { okButton {
requireContext().sendToClip(uri.toString()) requireContext().sendToClip(uri.toString())
} }
}.show() }
} }
override fun onStart() { override fun onStart() {
@ -181,7 +181,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
viewModel.importOnLine(url) viewModel.importOnLine(url)
} }
} }
}.show() }
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")

@ -98,7 +98,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@ -113,7 +113,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
viewModel.upGroup(group, alertBinding.editView.text?.toString()) viewModel.upGroup(group, alertBinding.editView.text?.toString())
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
private inner class GroupAdapter(context: Context) : private inner class GroupAdapter(context: Context) :

@ -221,7 +221,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
onDismiss { onDismiss {
Restore.saveIgnoreConfig() Restore.saveIgnoreConfig()
} }
}.show() }
} }
@ -278,7 +278,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
restoreFromLocal() restoreFromLocal()
} }
cancelButton() cancelButton()
}.show() }
} }
} }

@ -159,7 +159,7 @@ class OtherConfigFragment : BasePreferenceFragment(),
} }
} }
noButton() noButton()
}.show() }
} }
private fun clearCache() { private fun clearCache() {

@ -183,7 +183,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
} }
} }
noButton() noButton()
}.show() }
} }
private fun selectBgAction(isNight: Boolean) { private fun selectBgAction(isNight: Boolean) {
@ -241,7 +241,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
} }
} }
noButton() noButton()
}.show() }
} }
private fun upTheme(isNightTheme: Boolean) { private fun upTheme(isNightTheme: Boolean) {

@ -85,7 +85,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
initData() initData()
} }
noButton() noButton()
}.show() }
} }
fun share(index: Int) { fun share(index: Int) {

@ -116,7 +116,7 @@ class HandleFileActivity :
onCancelled { onCancelled {
finish() finish()
} }
}.show() }
} }
private fun getFileData(): Triple<String, ByteArray, String>? { private fun getFileData(): Triple<String, ByteArray, String>? {

@ -51,7 +51,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
okButton { okButton {
requireContext().sendToClip(uri.toString()) requireContext().sendToClip(uri.toString())
} }
}.show() }
} }
} }
abstract val groupId: Long abstract val groupId: Long
@ -106,7 +106,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
} }
} }
noButton() noButton()
}.show() }
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@ -148,7 +148,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
} }
} }
noButton() noButton()
}.show() }
} }
@ -170,7 +170,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
allowExtensions = arrayOf("txt", "json") allowExtensions = arrayOf("txt", "json")
} }
} }
}.show() }
} }
} }

@ -100,7 +100,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@ -115,7 +115,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
viewModel.upGroup(group, alertBinding.editView.text?.toString()) viewModel.upGroup(group, alertBinding.editView.text?.toString())
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
private inner class GroupAdapter(context: Context) : private inner class GroupAdapter(context: Context) :

@ -100,7 +100,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@ -115,7 +115,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
viewModel.upGroup(group, alertBinding.editView.text?.toString()) viewModel.upGroup(group, alertBinding.editView.text?.toString())
} }
noButton() noButton()
}.show().requestInputMethod() }.requestInputMethod()
} }
private inner class GroupAdapter(context: Context) : private inner class GroupAdapter(context: Context) :

@ -115,7 +115,7 @@ class FontSelectDialog : BaseDialogFragment(),
onDefaultFontChange() onDefaultFontChange()
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }
}.show() }
} }
R.id.menu_other -> { R.id.menu_other -> {
openFolder() openFolder()

Loading…
Cancel
Save