diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 0d62c791c..021338077 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -214,6 +214,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo R.id.menu_book_info -> ReadBook.book?.let { startActivity(Pair("bookUrl", it.bookUrl)) } + R.id.menu_toc_regex -> TocRegexDialog.show( + supportFragmentManager, + ReadBook.book?.tocUrl + ) } return super.onCompatOptionsItemSelected(item) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt new file mode 100644 index 000000000..971cf998d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -0,0 +1,44 @@ +package io.legado.app.ui.book.read.config + +import android.os.Bundle +import android.util.DisplayMetrics +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 + + +class TocRegexDialog : BaseDialogFragment() { + + companion object { + fun show(fragmentManager: FragmentManager, tocRegex: String? = null) { + val dialog = TocRegexDialog() + val bundle = Bundle() + bundle.putString("tocRegex", tocRegex) + dialog.arguments = bundle + dialog.show(fragmentManager, "tocRegexDialog") + } + } + + override fun onStart() { + super.onStart() + val dm = DisplayMetrics() + activity?.windowManager?.defaultDisplay?.getMetrics(dm) + dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.8).toInt()) + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.dialog_toc_regex, container) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index c25fd0664..233922f21 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -130,6 +130,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at pageOffset = 0f } + val cHeight = if (textPage.height > 0) textPage.height else height } diff --git a/app/src/main/res/layout/dialog_toc_regex.xml b/app/src/main/res/layout/dialog_toc_regex.xml new file mode 100644 index 000000000..43d0c5d3b --- /dev/null +++ b/app/src/main/res/layout/dialog_toc_regex.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file