pull/32/head
kunfei 5 years ago
parent 79c3168094
commit 44030aedfb
  1. 3
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 55
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt
  4. 0
      app/src/main/res/layout/dialog_read_book_style.xml
  5. 0
      app/src/main/res/layout/popup_keyboard_tool.xml

@ -19,6 +19,7 @@ import io.legado.app.receiver.TimeElectricityReceiver
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.ReadStyleDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.widget.page.ChapterProvider
import io.legado.app.ui.widget.page.PageView
@ -160,7 +161,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
override fun showReadStyle() {
ReadStyleDialog().show(supportFragmentManager, "readStyle")
}
override fun showMoreSetting() {

@ -1,59 +1,62 @@
package io.legado.app.ui.readbook.config
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.PopupWindow
import android.view.View
import android.view.ViewGroup
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.lib.theme.accentColor
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.postEvent
import kotlinx.android.synthetic.main.pop_read_book_style.view.*
import kotlinx.android.synthetic.main.dialog_read_book_style.*
import org.jetbrains.anko.sdk27.listeners.onClick
class ReadStylePopup(context: Context?) : PopupWindow(context) {
class ReadStyleDialog : DialogFragment() {
init {
@SuppressLint("InflateParams")
contentView = LayoutInflater.from(context).inflate(R.layout.pop_read_book_style, null)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.dialog_read_book_style, container)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initOnClick()
}
private fun initData() = with(contentView) {
private fun initData() {
upBg()
}
private fun initOnClick() = with(contentView) {
bg0.onClick {
private fun initOnClick() {
tv_bg0.onClick {
ReadBookConfig.styleSelect = 0
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
}
bg1.onClick {
tv_bg1.onClick {
ReadBookConfig.styleSelect = 1
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
}
bg2.onClick {
tv_bg2.onClick {
ReadBookConfig.styleSelect = 2
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
}
bg3.onClick {
tv_bg3.onClick {
ReadBookConfig.styleSelect = 3
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
}
bg4.onClick {
tv_bg4.onClick {
ReadBookConfig.styleSelect = 4
ReadBookConfig.upBg()
upBg()
@ -61,27 +64,27 @@ class ReadStylePopup(context: Context?) : PopupWindow(context) {
}
}
private fun upBg() = with(contentView) {
bg0.borderColor = context.primaryTextColor
bg1.borderColor = context.primaryTextColor
bg2.borderColor = context.primaryTextColor
bg3.borderColor = context.primaryTextColor
bg4.borderColor = context.primaryTextColor
private fun upBg() {
bg0.borderColor = requireContext().primaryTextColor
bg1.borderColor = requireContext().primaryTextColor
bg2.borderColor = requireContext().primaryTextColor
bg3.borderColor = requireContext().primaryTextColor
bg4.borderColor = requireContext().primaryTextColor
when (ReadBookConfig.styleSelect) {
1 -> {
bg1.borderColor = context.accentColor
bg1.borderColor = requireContext().accentColor
}
2 -> {
bg2.borderColor = context.accentColor
bg2.borderColor = requireContext().accentColor
}
3 -> {
bg3.borderColor = context.accentColor
bg3.borderColor = requireContext().accentColor
}
4 -> {
bg4.borderColor = context.accentColor
bg4.borderColor = requireContext().accentColor
}
else -> {
bg0.borderColor = context.accentColor
bg0.borderColor = requireContext().accentColor
}
}
}

@ -14,7 +14,7 @@ class KeyboardToolPop(context: Context, onClickListener: OnClickListener?) : Pop
init {
@SuppressLint("InflateParams")
val view = LayoutInflater.from(context).inflate(R.layout.pop_keyboard_tool, null)
val view = LayoutInflater.from(context).inflate(R.layout.popup_keyboard_tool, null)
this.contentView = view
isTouchable = true

Loading…
Cancel
Save