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() {
val log = String(requireContext().assets.open("updateLog.md").readBytes())
TextDialog.show(childFragmentManager, log, TextDialog.MD)
showDialogFragment(TextDialog(log, TextDialog.Mode.MD))
}
private fun checkUpdate() {
@ -133,7 +133,7 @@ class AboutFragment : PreferenceFragmentCompat() {
}
context?.selector(R.string.crash_log, crashLogNames) { _, select ->
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.ui.widget.dialog.TextDialog
import io.legado.app.utils.LogUtils
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize
import splitties.views.onClick
@ -76,7 +77,7 @@ class AppLogDialog : BaseDialogFragment() {
binding.root.onClick {
getItem(holder.layoutPosition)?.let { item ->
item.third?.let {
TextDialog.show(childFragmentManager, it.stackTraceToString())
showDialogFragment(TextDialog(it.stackTraceToString()))
}
}
}

@ -252,8 +252,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
showDialogFragment(BookmarkDialog(bookmark))
}
}
R.id.menu_copy_text ->
TextDialog.show(supportFragmentManager, BookRead.curTextChapter?.getContent())
R.id.menu_copy_text -> showDialogFragment(
TextDialog(BookRead.curTextChapter?.getContent())
)
R.id.menu_update_toc -> BookRead.book?.let {
loadChapterList(it)
}
@ -653,7 +654,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
override fun showReadMenuHelp() {
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(
requireContext().assets.open("help/httpTTSHelp.md").readBytes()
)
TextDialog.show(childFragmentManager, helpStr, TextDialog.MD)
showDialogFragment(TextDialog(helpStr, TextDialog.Mode.MD))
}
}.show()
}

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

@ -272,7 +272,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun showHelp() {
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) {

@ -146,7 +146,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
private fun showHelp() {
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() {

@ -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.widget.dialog.TextDialog
import io.legado.app.utils.observeEvent
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -119,10 +120,10 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
LocalConfig.versionCode = appInfo.versionCode
if (LocalConfig.isFirstOpenApp) {
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) {
val log = String(assets.open("updateLog.md").readBytes())
TextDialog.show(supportFragmentManager, log, TextDialog.MD)
showDialogFragment(TextDialog(log, TextDialog.Mode.MD))
}
viewModel.upVersion()
}

@ -51,7 +51,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
when (item.itemId) {
R.id.menu_help -> {
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() {
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 {

@ -19,6 +19,7 @@ import io.legado.app.databinding.ActivityReplaceEditBinding
import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.widget.KeyboardToolPop
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.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize
@ -146,7 +147,7 @@ class ReplaceEditActivity :
private fun showRegexHelp() {
val mdText = String(assets.open("help/regexHelp.md").readBytes())
TextDialog.show(supportFragmentManager, mdText, TextDialog.MD)
showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
}
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.ui.widget.dialog.TextDialog
import io.legado.app.utils.gone
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.launch
@ -47,10 +48,8 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_list_src ->
TextDialog.show(supportFragmentManager, viewModel.listSrc)
R.id.menu_content_src ->
TextDialog.show(supportFragmentManager, viewModel.contentSrc)
R.id.menu_list_src -> showDialogFragment(TextDialog(viewModel.listSrc))
R.id.menu_content_src -> showDialogFragment(TextDialog(viewModel.contentSrc))
}
return super.onCompatOptionsItemSelected(item)
}

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

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

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

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

Loading…
Cancel
Save