feat: tipConfig

pull/193/head
kunfei 5 years ago
parent 29a58bd112
commit 2b833aad49
  1. 59
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  3. 52
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  4. 18
      app/src/main/res/layout/dialog_read_book_style.xml
  5. 1
      app/src/main/res/layout/dialog_tip_config.xml
  6. 6
      app/src/main/res/values/arrays.xml
  7. 1
      app/src/main/res/values/strings.xml

@ -0,0 +1,59 @@
package io.legado.app.help
import io.legado.app.App
import io.legado.app.R
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.putPrefInt
object ReadTipConfig {
val tipArray = App.INSTANCE.resources.getStringArray(R.array.read_tip)
const val none = 0
const val chapterTitle = 1
const val time = 2
const val battery = 3
const val page = 4
const val totalProgress = 5
val tipHeaderLeftStr: String = tipArray[tipHeaderLeft]
val tipHeaderMiddleStr: String = tipArray[tipHeaderMiddle]
val tipHeaderRightStr: String = tipArray[tipHeaderRight]
val tipFooterLeftStr: String = tipArray[tipFooterLeft]
val tipFooterMiddleStr: String = tipArray[tipFooterMiddle]
val tipFooterRightStr: String = tipArray[tipFooterRight]
var tipHeaderLeft: Int
get() = App.INSTANCE.getPrefInt("tipHeaderLeft", time)
set(value) {
App.INSTANCE.putPrefInt("tipHeaderLeft", value)
}
var tipHeaderMiddle: Int
get() = App.INSTANCE.getPrefInt("tipHeaderMiddle", none)
set(value) {
App.INSTANCE.putPrefInt("tipHeaderMiddle", value)
}
var tipHeaderRight: Int
get() = App.INSTANCE.getPrefInt("tipHeaderRight", battery)
set(value) {
App.INSTANCE.putPrefInt("tipHeaderRight", value)
}
var tipFooterLeft: Int
get() = App.INSTANCE.getPrefInt("tipFooterLeft", chapterTitle)
set(value) {
App.INSTANCE.putPrefInt("tipFooterLeft", value)
}
var tipFooterMiddle: Int
get() = App.INSTANCE.getPrefInt("tipFooterMiddle", none)
set(value) {
App.INSTANCE.putPrefInt("tipFooterMiddle", value)
}
var tipFooterRight: Int
get() = App.INSTANCE.getPrefInt("tipFooterRight", page)
set(value) {
App.INSTANCE.putPrefInt("tipFooterRight", value)
}
}

@ -123,6 +123,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack {
tv_padding.onClick {
dismiss()
callBack?.showPaddingConfig()
}
tv_tip.onClick {
}
rg_page_anim.onCheckedChange { _, checkedId ->
ReadBookConfig.pageAnim = rg_page_anim.getIndexById(checkedId)

@ -7,7 +7,11 @@ import android.view.View
import android.view.ViewGroup
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.help.ReadTipConfig
import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.book.read.Help
import kotlinx.android.synthetic.main.dialog_tip_config.*
import org.jetbrains.anko.sdk27.listeners.onClick
class TipConfigDialog : BaseDialogFragment() {
@ -35,8 +39,56 @@ class TipConfigDialog : BaseDialogFragment() {
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
initView()
initEvent()
}
private fun initView() {
tv_header_left.text = ReadTipConfig.tipHeaderLeftStr
tv_header_middle.text = ReadTipConfig.tipHeaderMiddleStr
tv_header_right.text = ReadTipConfig.tipHeaderRightStr
tv_footer_left.text = ReadTipConfig.tipFooterLeftStr
tv_footer_middle.text = ReadTipConfig.tipFooterMiddleStr
tv_footer_right.text = ReadTipConfig.tipFooterRightStr
}
private fun initEvent() {
tv_header_left.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderLeft = i
tv_header_left.text = ReadTipConfig.tipArray[i]
}
}
tv_header_middle.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderMiddle = i
tv_header_middle.text = ReadTipConfig.tipArray[i]
}
}
tv_header_right.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderRight = i
tv_header_right.text = ReadTipConfig.tipArray[i]
}
}
tv_footer_left.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterLeft = i
tv_footer_left.text = ReadTipConfig.tipArray[i]
}
}
tv_footer_middle.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterMiddle = i
tv_footer_middle.text = ReadTipConfig.tipArray[i]
}
}
tv_footer_right.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterRight = i
tv_footer_right.text = ReadTipConfig.tipArray[i]
}
}
}
}

@ -121,6 +121,24 @@
android:textSize="14sp"
app:radius="3dp" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/tv_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:text="@string/information"
android:gravity="center"
android:textSize="14sp"
app:radius="3dp" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"

@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<io.legado.app.ui.widget.text.AccentTextView

@ -96,4 +96,10 @@
<item>系统等宽字体</item>
</string-array>
<string-array name="read_tip">
<item></item>
<item>标题</item>
<item></item>
</string-array>
</resources>

@ -652,4 +652,5 @@
<string name="media_button_on_exit_title">全程响应耳机按键</string>
<string name="media_button_on_exit_summary">即使退出软件也响应耳机按键</string>
<string name="middle"></string>
<string name="information">信息</string>
</resources>

Loading…
Cancel
Save