pull/32/head
kunfei 5 years ago
parent a8cfc17caa
commit b9b52ae32b
  1. 22
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  2. 13
      app/src/main/res/layout/dialog_read_book_style.xml

@ -71,14 +71,16 @@ class ReadStyleDialog : DialogFragment() {
ReadBookConfig.getConfig().let { ReadBookConfig.getConfig().let {
tv_text_bold.isSelected = it.textBold tv_text_bold.isSelected = it.textBold
seek_text_size.progress = it.textSize - 5 seek_text_size.progress = it.textSize - 5
tv_text_size.text = it.textSize.toString()
seek_text_letter_spacing.progress = (it.letterSpacing * 10).toInt() + 5 seek_text_letter_spacing.progress = (it.letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = it.letterSpacing.toString()
seek_line_size.progress = it.lineSpacingExtra.toInt() seek_line_size.progress = it.lineSpacingExtra.toInt()
tv_line_size.text = it.lineSpacingExtra.toString()
} }
setBg() setBg()
upBg() upBg()
} }
private fun initOnClick() = with(ReadBookConfig.getConfig()) { private fun initOnClick() = with(ReadBookConfig.getConfig()) {
tv_text_bold.onClick { tv_text_bold.onClick {
textBold = !textBold textBold = !textBold
@ -87,11 +89,11 @@ class ReadStyleDialog : DialogFragment() {
} }
seek_text_size.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { seek_text_size.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
textSize = progress + 5
tv_text_size.text = textSize.toString()
} }
override fun onStartTrackingTouch(seekBar: SeekBar?) {} override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) { override fun onStopTrackingTouch(seekBar: SeekBar?) {
textSize = seek_text_size.progress + 5
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
}) })
@ -99,54 +101,60 @@ class ReadStyleDialog : DialogFragment() {
textSize++ textSize++
if (textSize > 50) textSize = 50 if (textSize > 50) textSize = 50
seek_text_size.progress = textSize - 5 seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
iv_line_size_remove.onClick { iv_line_size_remove.onClick {
textSize-- textSize--
if (textSize < 5) textSize = 5 if (textSize < 5) textSize = 5
seek_text_size.progress = textSize - 5 seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
seek_text_letter_spacing.setOnSeekBarChangeListener(object : seek_text_letter_spacing.setOnSeekBarChangeListener(object :
SeekBar.OnSeekBarChangeListener { SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
letterSpacing = (seek_text_letter_spacing.progress - 5) / 10f
tv_text_letter_spacing.text = letterSpacing.toString()
} }
override fun onStartTrackingTouch(seekBar: SeekBar?) {} override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) { override fun onStopTrackingTouch(seekBar: SeekBar?) {
letterSpacing = (seek_text_letter_spacing.progress - 5) / 10f
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
}) })
iv_text_letter_spacing_add.onClick { iv_text_letter_spacing_add.onClick {
letterSpacing += 0.1f letterSpacing += 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5 seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
iv_text_letter_spacing_remove.onClick { iv_text_letter_spacing_remove.onClick {
letterSpacing -= 0.1f letterSpacing -= 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5 seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
seek_line_size.setOnSeekBarChangeListener(object : seek_line_size.setOnSeekBarChangeListener(object :
SeekBar.OnSeekBarChangeListener { SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
lineSpacingExtra = seek_line_size.progress.toFloat()
tv_line_size.text = lineSpacingExtra.toString()
} }
override fun onStartTrackingTouch(seekBar: SeekBar?) {} override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) { override fun onStopTrackingTouch(seekBar: SeekBar?) {
lineSpacingExtra = seek_line_size.progress.toFloat()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
}) })
iv_line_size_add.onClick { iv_line_size_add.onClick {
lineSpacingExtra++ lineSpacingExtra++
tv_line_size.text = lineSpacingExtra.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
iv_line_size_remove.onClick { iv_line_size_remove.onClick {
lineSpacingExtra-- lineSpacingExtra--
tv_line_size.text = lineSpacingExtra.toString()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, true)
} }
rg_page_anim.onCheckedChange { _, checkedId -> rg_page_anim.onCheckedChange { _, checkedId ->

@ -107,6 +107,10 @@
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="@color/tv_text_default" /> android:tint="@color/tv_text_default" />
<TextView
android:id="@+id/tv_text_size"
android:layout_width="40dp"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -148,6 +152,11 @@
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="@color/tv_text_default" /> android:tint="@color/tv_text_default" />
<TextView
android:id="@+id/tv_text_letter_spacing"
android:layout_width="40dp"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -189,6 +198,10 @@
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="@color/tv_text_default" /> android:tint="@color/tv_text_default" />
<TextView
android:id="@+id/tv_line_size"
android:layout_width="40dp"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<View <View

Loading…
Cancel
Save