|
|
|
@ -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 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |