pull/1352/head
gedoor 3 years ago
parent b81ae218a4
commit 2a6177e51d
  1. 4
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  2. 3
      app/src/main/java/io/legado/app/ui/about/AppLogDialog.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  5. 15
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  8. 2
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  9. 5
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  10. 2
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  11. 2
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  12. 3
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt
  13. 7
      app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt
  14. 4
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  15. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  16. 41
      app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt
  17. 15
      app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt

@ -81,7 +81,7 @@ class AboutFragment : PreferenceFragmentCompat() {
private fun showUpdateLog() { private fun showUpdateLog() {
val log = String(requireContext().assets.open("updateLog.md").readBytes()) val log = String(requireContext().assets.open("updateLog.md").readBytes())
TextDialog.show(childFragmentManager, log, TextDialog.MD) showDialogFragment(TextDialog(log, TextDialog.Mode.MD))
} }
private fun checkUpdate() { private fun checkUpdate() {
@ -133,7 +133,7 @@ class AboutFragment : PreferenceFragmentCompat() {
} }
context?.selector(R.string.crash_log, crashLogNames) { _, select -> context?.selector(R.string.crash_log, crashLogNames) { _, select ->
crashLogs?.getOrNull(select)?.let { logFile -> crashLogs?.getOrNull(select)?.let { logFile ->
TextDialog.show(childFragmentManager, logFile.readText()) showDialogFragment(TextDialog(logFile.readText()))
} }
} }
} }

@ -16,6 +16,7 @@ import io.legado.app.databinding.ItemAppLogBinding
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.LogUtils import io.legado.app.utils.LogUtils
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize import io.legado.app.utils.windowSize
import splitties.views.onClick import splitties.views.onClick
@ -76,7 +77,7 @@ class AppLogDialog : BaseDialogFragment() {
binding.root.onClick { binding.root.onClick {
getItem(holder.layoutPosition)?.let { item -> getItem(holder.layoutPosition)?.let { item ->
item.third?.let { item.third?.let {
TextDialog.show(childFragmentManager, it.stackTraceToString()) showDialogFragment(TextDialog(it.stackTraceToString()))
} }
} }
} }

@ -252,8 +252,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
showDialogFragment(BookmarkDialog(bookmark)) showDialogFragment(BookmarkDialog(bookmark))
} }
} }
R.id.menu_copy_text -> R.id.menu_copy_text -> showDialogFragment(
TextDialog.show(supportFragmentManager, BookRead.curTextChapter?.getContent()) TextDialog(BookRead.curTextChapter?.getContent())
)
R.id.menu_update_toc -> BookRead.book?.let { R.id.menu_update_toc -> BookRead.book?.let {
loadChapterList(it) loadChapterList(it)
} }
@ -653,7 +654,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
override fun showReadMenuHelp() { override fun showReadMenuHelp() {
val text = String(assets.open("help/readMenuHelp.md").readBytes()) val text = String(assets.open("help/readMenuHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
/** /**

@ -205,7 +205,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
val helpStr = String( val helpStr = String(
requireContext().assets.open("help/httpTTSHelp.md").readBytes() requireContext().assets.open("help/httpTTSHelp.md").readBytes()
) )
TextDialog.show(childFragmentManager, helpStr, TextDialog.MD) showDialogFragment(TextDialog(helpStr, TextDialog.Mode.MD))
} }
}.show() }.show()
} }

@ -14,6 +14,7 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.qrcode.QrCodeResult import io.legado.app.ui.qrcode.QrCodeResult
import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -129,14 +130,10 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_scan -> qrCodeResult.launch(null) R.id.menu_scan -> qrCodeResult.launch(null)
R.id.menu_search_src -> R.id.menu_search_src -> showDialogFragment(TextDialog(viewModel.searchSrc))
TextDialog.show(supportFragmentManager, viewModel.searchSrc) R.id.menu_book_src -> showDialogFragment(TextDialog(viewModel.bookSrc))
R.id.menu_book_src -> R.id.menu_toc_src -> showDialogFragment(TextDialog(viewModel.tocSrc))
TextDialog.show(supportFragmentManager, viewModel.bookSrc) R.id.menu_content_src -> showDialogFragment(TextDialog(viewModel.contentSrc))
R.id.menu_toc_src ->
TextDialog.show(supportFragmentManager, viewModel.tocSrc)
R.id.menu_content_src ->
TextDialog.show(supportFragmentManager, viewModel.contentSrc)
R.id.menu_help -> showHelp() R.id.menu_help -> showHelp()
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
@ -144,7 +141,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
private fun showHelp() { private fun showHelp() {
val text = String(assets.open("help/debugHelp.md").readBytes()) val text = String(assets.open("help/debugHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
} }

@ -426,12 +426,12 @@ class BookSourceEditActivity :
private fun showRuleHelp() { private fun showRuleHelp() {
val mdText = String(assets.open("help/ruleHelp.md").readBytes()) val mdText = String(assets.open("help/ruleHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
} }
private fun showRegexHelp() { private fun showRegexHelp() {
val mdText = String(assets.open("help/regexHelp.md").readBytes()) val mdText = String(assets.open("help/regexHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
} }
private fun showKeyboardTopPopupWindow() { private fun showKeyboardTopPopupWindow() {

@ -272,7 +272,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun showHelp() { private fun showHelp() {
val text = String(assets.open("help/SourceMBookHelp.md").readBytes()) val text = String(assets.open("help/SourceMBookHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
private fun sortCheck(sort: Sort) { private fun sortCheck(sort: Sort) {

@ -146,7 +146,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
private fun showHelp() { private fun showHelp() {
val text = String(requireContext().assets.open("help/webDavHelp.md").readBytes()) val text = String(requireContext().assets.open("help/webDavHelp.md").readBytes())
TextDialog.show(childFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
override fun onDestroy() { override fun onDestroy() {

@ -34,6 +34,7 @@ import io.legado.app.ui.main.my.MyFragment
import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.main.rss.RssFragment
import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.observeEvent import io.legado.app.utils.observeEvent
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -119,10 +120,10 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
LocalConfig.versionCode = appInfo.versionCode LocalConfig.versionCode = appInfo.versionCode
if (LocalConfig.isFirstOpenApp) { if (LocalConfig.isFirstOpenApp) {
val text = String(assets.open("help/appHelp.md").readBytes()) val text = String(assets.open("help/appHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} else if (!BuildConfig.DEBUG) { } else if (!BuildConfig.DEBUG) {
val log = String(assets.open("updateLog.md").readBytes()) val log = String(assets.open("updateLog.md").readBytes())
TextDialog.show(supportFragmentManager, log, TextDialog.MD) showDialogFragment(TextDialog(log, TextDialog.Mode.MD))
} }
viewModel.upVersion() viewModel.upVersion()
} }

@ -51,7 +51,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
when (item.itemId) { when (item.itemId) {
R.id.menu_help -> { R.id.menu_help -> {
val text = String(requireContext().assets.open("help/appHelp.md").readBytes()) val text = String(requireContext().assets.open("help/appHelp.md").readBytes())
TextDialog.show(childFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
} }
} }

@ -294,7 +294,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
private fun showHelp() { private fun showHelp() {
val text = String(assets.open("help/replaceRuleHelp.md").readBytes()) val text = String(assets.open("help/replaceRuleHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
override fun onQueryTextChange(newText: String?): Boolean { override fun onQueryTextChange(newText: String?): Boolean {

@ -19,6 +19,7 @@ import io.legado.app.databinding.ActivityReplaceEditBinding
import io.legado.app.lib.dialogs.selector import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.ui.widget.KeyboardToolPop
import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize import io.legado.app.utils.windowSize
@ -146,7 +147,7 @@ class ReplaceEditActivity :
private fun showRegexHelp() { private fun showRegexHelp() {
val mdText = String(assets.open("help/regexHelp.md").readBytes()) val mdText = String(assets.open("help/regexHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
} }
private fun showKeyboardTopPopupWindow() { private fun showKeyboardTopPopupWindow() {

@ -12,6 +12,7 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.gone import io.legado.app.utils.gone
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -47,10 +48,8 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_list_src -> R.id.menu_list_src -> showDialogFragment(TextDialog(viewModel.listSrc))
TextDialog.show(supportFragmentManager, viewModel.listSrc) R.id.menu_content_src -> showDialogFragment(TextDialog(viewModel.contentSrc))
R.id.menu_content_src ->
TextDialog.show(supportFragmentManager, viewModel.contentSrc)
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }

@ -237,12 +237,12 @@ class RssSourceEditActivity :
private fun showRuleHelp() { private fun showRuleHelp() {
val mdText = String(assets.open("help/ruleHelp.md").readBytes()) val mdText = String(assets.open("help/ruleHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
} }
private fun showRegexHelp() { private fun showRegexHelp() {
val mdText = String(assets.open("help/regexHelp.md").readBytes()) val mdText = String(assets.open("help/regexHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
} }
private fun showKeyboardTopPopupWindow() { private fun showKeyboardTopPopupWindow() {

@ -256,7 +256,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
private fun showHelp() { private fun showHelp() {
val text = String(assets.open("help/SourceMRssHelp.md").readBytes()) val text = String(assets.open("help/SourceMRssHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD) showDialogFragment(TextDialog(text, TextDialog.Mode.MD))
} }
override fun upCountView() { override fun upCountView() {

@ -1,10 +1,11 @@
package io.legado.app.ui.widget.dialog package io.legado.app.ui.widget.dialog
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Html
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogTextViewBinding import io.legado.app.databinding.DialogTextViewBinding
@ -18,29 +19,25 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class TextDialog : BaseDialogFragment() { class TextDialog() : BaseDialogFragment() {
companion object { enum class Mode {
const val MD = 1 MD, HTML, TEXT
}
fun show( constructor(
fragmentManager: FragmentManager,
content: String?, content: String?,
mode: Int = 0, mode: Mode = Mode.TEXT,
time: Long = 0, time: Long = 0,
autoClose: Boolean = false autoClose: Boolean = false
) { ) : this() {
TextDialog().apply { arguments = Bundle().apply {
val bundle = Bundle() putString("content", content)
bundle.putString("content", content) putString("mode", mode.name)
bundle.putInt("mode", mode) putLong("time", time)
bundle.putLong("time", time) }
arguments = bundle
isCancelable = false isCancelable = false
this.autoClose = autoClose this.autoClose = autoClose
}.show(fragmentManager, "textDialog")
}
} }
private val binding by viewBinding(DialogTextViewBinding::bind) private val binding by viewBinding(DialogTextViewBinding::bind)
@ -64,8 +61,8 @@ class TextDialog : BaseDialogFragment() {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
arguments?.let { arguments?.let {
val content = it.getString("content") ?: "" val content = it.getString("content") ?: ""
when (it.getInt("mode")) { when (it.getString("mode")) {
MD -> binding.textView.post { Mode.MD.name -> binding.textView.post {
Markwon.builder(requireContext()) Markwon.builder(requireContext())
.usePlugin(GlideImagesPlugin.create(requireContext())) .usePlugin(GlideImagesPlugin.create(requireContext()))
.usePlugin(HtmlPlugin.create()) .usePlugin(HtmlPlugin.create())
@ -73,6 +70,12 @@ class TextDialog : BaseDialogFragment() {
.build() .build()
.setMarkdown(binding.textView, content) .setMarkdown(binding.textView, content)
} }
Mode.HTML.name -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
binding.textView.text = Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY)
} else {
@Suppress("DEPRECATION")
binding.textView.text = Html.fromHtml(content)
}
else -> binding.textView.text = content else -> binding.textView.text = content
} }
time = it.getLong("time", 0L) time = it.getLong("time", 0L)

@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
@ -16,16 +15,12 @@ import io.legado.app.databinding.ItemLogBinding
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize import io.legado.app.utils.windowSize
class TextListDialog : BaseDialogFragment() { class TextListDialog() : BaseDialogFragment() {
companion object { constructor(title: String, values: ArrayList<String>) : this() {
fun show(fragmentManager: FragmentManager, title: String, values: ArrayList<String>) { arguments = Bundle().apply {
TextListDialog().apply { putString("title", title)
val bundle = Bundle() putStringArrayList("values", values)
bundle.putString("title", title)
bundle.putStringArrayList("values", values)
arguments = bundle
}.show(fragmentManager, "textListDialog")
} }
} }

Loading…
Cancel
Save