diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index c4dd34127..6232c7b18 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -23,6 +23,9 @@ import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat +import io.legado.app.lib.theme.bottomBackground +import io.legado.app.lib.theme.getPrimaryTextColor +import io.legado.app.lib.theme.getSecondaryTextColor import io.legado.app.ui.book.read.ReadBookActivityHelp import io.legado.app.utils.* import kotlinx.android.synthetic.main.dialog_read_bg_text.* @@ -39,6 +42,8 @@ class BgTextConfigDialog : BaseDialogFragment() { private val requestCodeBg = 123 private lateinit var adapter: BgAdapter + var primaryTextColor = 0 + var secondaryTextColor = 0 override fun onStart() { super.onStart() @@ -49,7 +54,7 @@ class BgTextConfigDialog : BaseDialogFragment() { dialog?.window?.let { it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 5, 0, 0) + it.decorView.setPadding(0, 0, 0, 0) val attr = it.attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM @@ -67,8 +72,9 @@ class BgTextConfigDialog : BaseDialogFragment() { } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - initData() initView() + initData() + initEvent() } override fun onDismiss(dialog: DialogInterface) { @@ -76,6 +82,16 @@ class BgTextConfigDialog : BaseDialogFragment() { ReadBookConfig.save() } + private fun initView() { + val bg = requireContext().bottomBackground + val isLight = ColorUtils.isColorLight(bg) + primaryTextColor = requireContext().getPrimaryTextColor(isLight) + secondaryTextColor = requireContext().getSecondaryTextColor(isLight) + root_view.setBackgroundColor(bg) + sw_dark_status_icon.setTextColor(primaryTextColor) + tv_bg_image.setTextColor(primaryTextColor) + } + @SuppressLint("InflateParams") private fun initData() = with(ReadBookConfig.durConfig) { sw_dark_status_icon.isChecked = statusIconDark() @@ -86,6 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment() { val headerView = LayoutInflater.from(requireContext()) .inflate(R.layout.item_bg_image, recycler_view, false) adapter.addHeaderView(headerView) + headerView.tv_name.setTextColor(secondaryTextColor) headerView.tv_name.text = getString(R.string.select_image) headerView.iv_bg.setImageResource(R.drawable.ic_image) headerView.iv_bg.setColorFilter(getCompatColor(R.color.primaryText)) @@ -95,7 +112,7 @@ class BgTextConfigDialog : BaseDialogFragment() { } } - private fun initView() = with(ReadBookConfig.durConfig) { + private fun initEvent() = with(ReadBookConfig.durConfig) { sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> if (buttonView?.isPressed == true) { setStatusIconDark(isChecked) @@ -136,7 +153,7 @@ class BgTextConfigDialog : BaseDialogFragment() { startActivityForResult(intent, requestCodeBg) } - class BgAdapter(context: Context) : + inner class BgAdapter(context: Context) : SimpleRecyclerAdapter(context, R.layout.item_bg_image) { override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList) { @@ -144,6 +161,7 @@ class BgTextConfigDialog : BaseDialogFragment() { ImageLoader.load(context, context.assets.open("bg/$item").readBytes()) .centerCrop() .into(iv_bg) + tv_name.setTextColor(secondaryTextColor) tv_name.text = item.substringBeforeLast(".") } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 91b424a6a..689752171 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -70,10 +70,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { val bg = requireContext().bottomBackground val isLight = ColorUtils.isColorLight(bg) val textColor = requireContext().getPrimaryTextColor(isLight) + root_view.setBackgroundColor(bg) tv_page_anim.setTextColor(textColor) tv_bg_ts.setTextColor(textColor) tv_share_layout.setTextColor(textColor) - root_view.setBackgroundColor(bg) dsb_text_size.valueFormat = { (it + 5).toString() } diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 6cea816cd..09c428860 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -1,6 +1,8 @@ @@ -75,8 +80,10 @@ android:focusable="true">