diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index cd6a77adf..588889e40 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -37,8 +37,8 @@ object ReadBookConfig { set(value) = App.INSTANCE.putPrefInt("readStyleSelect", value) var bg: Drawable? = null - fun getConfig(): Config { - return configList[styleSelect] + fun getConfig(index: Int = styleSelect): Config { + return configList[index] } fun upBg() { @@ -109,5 +109,9 @@ object ReadBookConfig { var paddingTop: Int = 0, var textColor: String = "#3E3D3B", var textSize: Int = 15 - ) + ) { + fun textColor(): Int { + return Color.parseColor(textColor) + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 07b5b3002..319755c21 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -161,6 +161,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } override fun showReadStyle() { + runMenuOut() ReadStyleDialog().show(supportFragmentManager, "readStyle") } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index 3c3b40633..efa6d7c14 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.readbook.config import android.os.Bundle +import android.util.DisplayMetrics import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -26,7 +27,15 @@ class ReadStyleDialog : DialogFragment() { initOnClick() } + override fun onStart() { + super.onStart() + val dm = DisplayMetrics() + activity?.windowManager?.defaultDisplay?.getMetrics(dm) + dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) + } + private fun initData() { + setBg() upBg() } @@ -64,6 +73,15 @@ class ReadStyleDialog : DialogFragment() { } } + private fun setBg() { + tv_bg0.setTextColor(ReadBookConfig.getConfig(0).textColor()) + tv_bg1.setTextColor(ReadBookConfig.getConfig(1).textColor()) + tv_bg2.setTextColor(ReadBookConfig.getConfig(2).textColor()) + tv_bg3.setTextColor(ReadBookConfig.getConfig(3).textColor()) + tv_bg4.setTextColor(ReadBookConfig.getConfig(4).textColor()) + + } + private fun upBg() { bg0.borderColor = requireContext().primaryTextColor bg1.borderColor = requireContext().primaryTextColor diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt index 38833feaf..208a1de3f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt @@ -41,8 +41,8 @@ class ContentView : FrameLayout { fun setBg(bg: Drawable?) { if (bg is ColorDrawable) { + bgImage.setImageDrawable(null) bgImage.background = bg - bgImage } else { ImageLoader.load(context, bg) .centerCrop() diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 5fdd25a09..99e9e6946 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -7,8 +7,8 @@