pull/357/head
gedoor 4 years ago
parent 0c126b8dfc
commit 488e61dcaa
  1. 26
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  3. 7
      app/src/main/res/layout/dialog_read_bg_text.xml

@ -23,6 +23,9 @@ import io.legado.app.help.ImageLoader
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat 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.ui.book.read.ReadBookActivityHelp
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_read_bg_text.* import kotlinx.android.synthetic.main.dialog_read_bg_text.*
@ -39,6 +42,8 @@ class BgTextConfigDialog : BaseDialogFragment() {
private val requestCodeBg = 123 private val requestCodeBg = 123
private lateinit var adapter: BgAdapter private lateinit var adapter: BgAdapter
var primaryTextColor = 0
var secondaryTextColor = 0
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -49,7 +54,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
dialog?.window?.let { dialog?.window?.let {
it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
it.setBackgroundDrawableResource(R.color.background) it.setBackgroundDrawableResource(R.color.background)
it.decorView.setPadding(0, 5, 0, 0) it.decorView.setPadding(0, 0, 0, 0)
val attr = it.attributes val attr = it.attributes
attr.dimAmount = 0.0f attr.dimAmount = 0.0f
attr.gravity = Gravity.BOTTOM attr.gravity = Gravity.BOTTOM
@ -67,8 +72,9 @@ class BgTextConfigDialog : BaseDialogFragment() {
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
initData()
initView() initView()
initData()
initEvent()
} }
override fun onDismiss(dialog: DialogInterface) { override fun onDismiss(dialog: DialogInterface) {
@ -76,6 +82,16 @@ class BgTextConfigDialog : BaseDialogFragment() {
ReadBookConfig.save() 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") @SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) { private fun initData() = with(ReadBookConfig.durConfig) {
sw_dark_status_icon.isChecked = statusIconDark() sw_dark_status_icon.isChecked = statusIconDark()
@ -86,6 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
val headerView = LayoutInflater.from(requireContext()) val headerView = LayoutInflater.from(requireContext())
.inflate(R.layout.item_bg_image, recycler_view, false) .inflate(R.layout.item_bg_image, recycler_view, false)
adapter.addHeaderView(headerView) adapter.addHeaderView(headerView)
headerView.tv_name.setTextColor(secondaryTextColor)
headerView.tv_name.text = getString(R.string.select_image) headerView.tv_name.text = getString(R.string.select_image)
headerView.iv_bg.setImageResource(R.drawable.ic_image) headerView.iv_bg.setImageResource(R.drawable.ic_image)
headerView.iv_bg.setColorFilter(getCompatColor(R.color.primaryText)) 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 -> sw_dark_status_icon.onCheckedChange { buttonView, isChecked ->
if (buttonView?.isPressed == true) { if (buttonView?.isPressed == true) {
setStatusIconDark(isChecked) setStatusIconDark(isChecked)
@ -136,7 +153,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
startActivityForResult(intent, requestCodeBg) startActivityForResult(intent, requestCodeBg)
} }
class BgAdapter(context: Context) : inner class BgAdapter(context: Context) :
SimpleRecyclerAdapter<String>(context, R.layout.item_bg_image) { SimpleRecyclerAdapter<String>(context, R.layout.item_bg_image) {
override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
@ -144,6 +161,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
ImageLoader.load(context, context.assets.open("bg/$item").readBytes()) ImageLoader.load(context, context.assets.open("bg/$item").readBytes())
.centerCrop() .centerCrop()
.into(iv_bg) .into(iv_bg)
tv_name.setTextColor(secondaryTextColor)
tv_name.text = item.substringBeforeLast(".") tv_name.text = item.substringBeforeLast(".")
} }
} }

@ -70,10 +70,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
val bg = requireContext().bottomBackground val bg = requireContext().bottomBackground
val isLight = ColorUtils.isColorLight(bg) val isLight = ColorUtils.isColorLight(bg)
val textColor = requireContext().getPrimaryTextColor(isLight) val textColor = requireContext().getPrimaryTextColor(isLight)
root_view.setBackgroundColor(bg)
tv_page_anim.setTextColor(textColor) tv_page_anim.setTextColor(textColor)
tv_bg_ts.setTextColor(textColor) tv_bg_ts.setTextColor(textColor)
tv_share_layout.setTextColor(textColor) tv_share_layout.setTextColor(textColor)
root_view.setBackgroundColor(bg)
dsb_text_size.valueFormat = { dsb_text_size.valueFormat = {
(it + 5).toString() (it + 5).toString()
} }

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_view"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -33,6 +35,7 @@
android:padding="6dp" android:padding="6dp"
android:text="@string/text_color" android:text="@string/text_color"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<io.legado.app.ui.widget.text.StrokeTextView <io.legado.app.ui.widget.text.StrokeTextView
@ -48,6 +51,7 @@
android:padding="6dp" android:padding="6dp"
android:text="@string/bg_color" android:text="@string/bg_color"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<io.legado.app.ui.widget.text.StrokeTextView <io.legado.app.ui.widget.text.StrokeTextView
@ -63,6 +67,7 @@
android:padding="6dp" android:padding="6dp"
android:text="恢复默认" android:text="恢复默认"
android:textSize="14sp" android:textSize="14sp"
app:isBottomBackground="true"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
@ -75,8 +80,10 @@
android:focusable="true"> android:focusable="true">
<TextView <TextView
android:id="@+id/tv_bg_image"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/bg_image" /> android:text="@string/bg_image" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

Loading…
Cancel
Save