pull/32/head
kunfei 5 years ago
parent 44030aedfb
commit 1d3232a3ac
  1. 10
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 1
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  3. 18
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  5. 40
      app/src/main/res/layout/dialog_read_book_style.xml

@ -37,8 +37,8 @@ object ReadBookConfig {
set(value) = App.INSTANCE.putPrefInt("readStyleSelect", value) set(value) = App.INSTANCE.putPrefInt("readStyleSelect", value)
var bg: Drawable? = null var bg: Drawable? = null
fun getConfig(): Config { fun getConfig(index: Int = styleSelect): Config {
return configList[styleSelect] return configList[index]
} }
fun upBg() { fun upBg() {
@ -109,5 +109,9 @@ object ReadBookConfig {
var paddingTop: Int = 0, var paddingTop: Int = 0,
var textColor: String = "#3E3D3B", var textColor: String = "#3E3D3B",
var textSize: Int = 15 var textSize: Int = 15
) ) {
fun textColor(): Int {
return Color.parseColor(textColor)
}
}
} }

@ -161,6 +161,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
} }
override fun showReadStyle() { override fun showReadStyle() {
runMenuOut()
ReadStyleDialog().show(supportFragmentManager, "readStyle") ReadStyleDialog().show(supportFragmentManager, "readStyle")
} }

@ -1,6 +1,7 @@
package io.legado.app.ui.readbook.config package io.legado.app.ui.readbook.config
import android.os.Bundle import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -26,7 +27,15 @@ class ReadStyleDialog : DialogFragment() {
initOnClick() 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() { private fun initData() {
setBg()
upBg() 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() { private fun upBg() {
bg0.borderColor = requireContext().primaryTextColor bg0.borderColor = requireContext().primaryTextColor
bg1.borderColor = requireContext().primaryTextColor bg1.borderColor = requireContext().primaryTextColor

@ -41,8 +41,8 @@ class ContentView : FrameLayout {
fun setBg(bg: Drawable?) { fun setBg(bg: Drawable?) {
if (bg is ColorDrawable) { if (bg is ColorDrawable) {
bgImage.setImageDrawable(null)
bgImage.background = bg bgImage.background = bg
bgImage
} else { } else {
ImageLoader.load(context, bg) ImageLoader.load(context, bg)
.centerCrop() .centerCrop()

@ -7,8 +7,8 @@
<io.legado.app.ui.widget.image.CircleImageView <io.legado.app.ui.widget.image.CircleImageView
android:id="@+id/bg0" android:id="@+id/bg0"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
app:civ_border_color="@color/tv_text_default" app:civ_border_color="@color/tv_text_default"
app:civ_border_width="1dp" app:civ_border_width="1dp"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
@ -17,8 +17,8 @@
<TextView <TextView
android:id="@+id/tv_bg0" android:id="@+id/tv_bg0"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
android:gravity="center" android:gravity="center"
android:text="@string/text" android:text="@string/text"
app:layout_constraintTop_toTopOf="@+id/bg0" app:layout_constraintTop_toTopOf="@+id/bg0"
@ -26,8 +26,8 @@
<io.legado.app.ui.widget.image.CircleImageView <io.legado.app.ui.widget.image.CircleImageView
android:id="@+id/bg1" android:id="@+id/bg1"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
app:civ_border_color="@color/tv_text_default" app:civ_border_color="@color/tv_text_default"
app:civ_border_width="1dp" app:civ_border_width="1dp"
app:layout_constraintLeft_toRightOf="@+id/bg0" app:layout_constraintLeft_toRightOf="@+id/bg0"
@ -36,8 +36,8 @@
<TextView <TextView
android:id="@+id/tv_bg1" android:id="@+id/tv_bg1"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
android:gravity="center" android:gravity="center"
android:text="@string/text" android:text="@string/text"
app:layout_constraintTop_toTopOf="@+id/bg1" app:layout_constraintTop_toTopOf="@+id/bg1"
@ -45,8 +45,8 @@
<io.legado.app.ui.widget.image.CircleImageView <io.legado.app.ui.widget.image.CircleImageView
android:id="@+id/bg2" android:id="@+id/bg2"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
app:civ_border_color="@color/tv_text_default" app:civ_border_color="@color/tv_text_default"
app:civ_border_width="1dp" app:civ_border_width="1dp"
app:layout_constraintLeft_toRightOf="@+id/bg1" app:layout_constraintLeft_toRightOf="@+id/bg1"
@ -55,8 +55,8 @@
<TextView <TextView
android:id="@+id/tv_bg2" android:id="@+id/tv_bg2"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
android:gravity="center" android:gravity="center"
android:text="@string/text" android:text="@string/text"
app:layout_constraintTop_toTopOf="@+id/bg2" app:layout_constraintTop_toTopOf="@+id/bg2"
@ -64,8 +64,8 @@
<io.legado.app.ui.widget.image.CircleImageView <io.legado.app.ui.widget.image.CircleImageView
android:id="@+id/bg3" android:id="@+id/bg3"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
app:civ_border_color="@color/tv_text_default" app:civ_border_color="@color/tv_text_default"
app:civ_border_width="1dp" app:civ_border_width="1dp"
app:layout_constraintLeft_toRightOf="@+id/bg2" app:layout_constraintLeft_toRightOf="@+id/bg2"
@ -74,8 +74,8 @@
<TextView <TextView
android:id="@+id/tv_bg3" android:id="@+id/tv_bg3"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
android:gravity="center" android:gravity="center"
android:text="@string/text" android:text="@string/text"
app:layout_constraintTop_toTopOf="@+id/bg3" app:layout_constraintTop_toTopOf="@+id/bg3"
@ -83,8 +83,8 @@
<io.legado.app.ui.widget.image.CircleImageView <io.legado.app.ui.widget.image.CircleImageView
android:id="@+id/bg4" android:id="@+id/bg4"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
app:civ_border_color="@color/tv_text_default" app:civ_border_color="@color/tv_text_default"
app:civ_border_width="1dp" app:civ_border_width="1dp"
app:layout_constraintLeft_toRightOf="@+id/bg3" app:layout_constraintLeft_toRightOf="@+id/bg3"
@ -93,8 +93,8 @@
<TextView <TextView
android:id="@+id/tv_bg4" android:id="@+id/tv_bg4"
android:layout_width="40dp" android:layout_width="48dp"
android:layout_height="40dp" android:layout_height="48dp"
android:gravity="center" android:gravity="center"
android:text="@string/text" android:text="@string/text"
app:layout_constraintTop_toTopOf="@+id/bg4" app:layout_constraintTop_toTopOf="@+id/bg4"

Loading…
Cancel
Save