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