pull/32/head
kunfei 5 years ago
parent 22db0c851b
commit 9a2f32399c
  1. 5
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 71
      app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt
  3. 7
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  4. 43
      app/src/main/res/layout/dialog_read_padding.xml

@ -23,6 +23,7 @@ import io.legado.app.service.ReadAloudService
import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.ui.readbook.config.MoreConfigDialog
import io.legado.app.ui.readbook.config.PaddingConfigDialog
import io.legado.app.ui.readbook.config.ReadAloudDialog
import io.legado.app.ui.readbook.config.ReadStyleDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity
@ -167,6 +168,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
})
}
fun showPaddingConfig() {
PaddingConfigDialog().show(supportFragmentManager, "paddingConfig")
}
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.read_book, menu)
return super.onCompatCreateOptionsMenu(menu)

@ -5,9 +5,14 @@ import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.SeekBar
import androidx.fragment.app.DialogFragment
import io.legado.app.R
import io.legado.app.constant.Bus
import io.legado.app.help.ReadBookConfig
import io.legado.app.ui.readbook.Help
import io.legado.app.utils.postEvent
import kotlinx.android.synthetic.main.dialog_read_padding.*
class PaddingConfigDialog : DialogFragment() {
@ -40,12 +45,74 @@ class PaddingConfigDialog : DialogFragment() {
initView()
}
private fun initData() {
private fun initData() = with(ReadBookConfig.getConfig()) {
seek_padding_top.progress = paddingTop
seek_padding_bottom.progress = paddingBottom
seek_padding_left.progress = paddingLeft
seek_padding_right.progress = paddingRight
tv_padding_top.text = paddingTop.toString()
tv_padding_bottom.text = paddingBottom.toString()
tv_padding_left.text = paddingLeft.toString()
tv_padding_right.text = paddingRight.toString()
}
private fun initView() = with(ReadBookConfig.getConfig()) {
seek_padding_top.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
paddingTop = progress
tv_padding_top.text = paddingTop.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
seek_padding_bottom.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
paddingBottom = progress
tv_padding_bottom.text = paddingBottom.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
seek_padding_left.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
paddingLeft = progress
tv_padding_left.text = paddingLeft.toString()
}
private fun initView() {
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
seek_padding_right.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
paddingRight = progress
tv_padding_right.text = paddingRight.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
}
}

@ -87,6 +87,13 @@ class ReadStyleDialog : DialogFragment() {
tv_text_bold.isSelected = textBold
postEvent(Bus.UP_CONFIG, false)
}
tv_padding.onClick {
val activity = activity
dismiss()
if (activity is ReadBookActivity) {
activity.showPaddingConfig()
}
}
seek_text_size.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
textSize = progress + 5

@ -1,20 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:padding="8dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_padding_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/tv_text_bold">
<TextView
@ -26,8 +27,8 @@
android:id="@+id/iv_padding_top_remove"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_remove"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_remove"
android:tint="@color/tv_text_default" />
<io.legado.app.lib.theme.view.ATESeekBar
@ -36,14 +37,14 @@
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_weight="4"
android:max="45" />
android:max="100" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_padding_top_add"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_add"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_add"
android:tint="@color/tv_text_default" />
<TextView
@ -52,6 +53,7 @@
android:layout_height="wrap_content"
android:gravity="right"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<LinearLayout
@ -59,10 +61,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/tv_text_bold">
<TextView
@ -74,8 +76,8 @@
android:id="@+id/iv_padding_bottom_remove"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_remove"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_remove"
android:tint="@color/tv_text_default" />
<io.legado.app.lib.theme.view.ATESeekBar
@ -84,14 +86,14 @@
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_weight="4"
android:max="45" />
android:max="100" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_padding_bottom_add"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_add"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_add"
android:tint="@color/tv_text_default" />
<TextView
@ -100,6 +102,7 @@
android:layout_height="wrap_content"
android:gravity="right"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<LinearLayout
@ -107,10 +110,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/tv_text_bold">
<TextView
@ -122,8 +125,8 @@
android:id="@+id/iv_padding_left_remove"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_remove"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_remove"
android:tint="@color/tv_text_default" />
<io.legado.app.lib.theme.view.ATESeekBar
@ -132,14 +135,14 @@
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_weight="4"
android:max="45" />
android:max="100" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_padding_left_add"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_add"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_add"
android:tint="@color/tv_text_default" />
<TextView
@ -148,6 +151,7 @@
android:layout_height="wrap_content"
android:gravity="right"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<LinearLayout
@ -155,10 +159,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/tv_text_bold">
<TextView
@ -170,8 +174,8 @@
android:id="@+id/iv_padding_right_remove"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_remove"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_remove"
android:tint="@color/tv_text_default" />
<io.legado.app.lib.theme.view.ATESeekBar
@ -180,14 +184,14 @@
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_weight="4"
android:max="45" />
android:max="100" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_padding_right_add"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_add"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_add"
android:tint="@color/tv_text_default" />
<TextView
@ -196,6 +200,7 @@
android:layout_height="wrap_content"
android:gravity="right"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout>
Loading…
Cancel
Save