pull/967/head
gedoor 4 years ago
parent 5fbf734f89
commit 66b1f5e08a
  1. 25
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  2. 12
      app/src/main/res/layout/dialog_read_bg_text.xml

@ -15,8 +15,10 @@ import io.legado.app.constant.EventBus
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogReadBgTextBinding
import io.legado.app.databinding.ItemBgImageBinding
import io.legado.app.help.DefaultData
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.permission.Permissions
import io.legado.app.lib.permission.PermissionsCompat
import io.legado.app.lib.theme.bottomBackground
@ -107,12 +109,6 @@ class BgTextConfigDialog : BaseDialogFragment() {
binding.ivExport.setColorFilter(primaryTextColor)
binding.ivDelete.setColorFilter(primaryTextColor)
binding.tvBgImage.setTextColor(primaryTextColor)
}
@SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) {
binding.tvName.text = name.ifBlank { "文字" }
binding.swDarkStatusIcon.isChecked = curStatusIconDark()
adapter = BgAdapter(requireContext(), secondaryTextColor)
binding.recyclerView.adapter = adapter
adapter.addHeaderView {
@ -131,6 +127,12 @@ class BgTextConfigDialog : BaseDialogFragment() {
}
}
@SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) {
binding.tvName.text = name.ifBlank { "文字" }
binding.swDarkStatusIcon.isChecked = curStatusIconDark()
}
@SuppressLint("InflateParams")
private fun initEvent() = with(ReadBookConfig.durConfig) {
binding.ivEdit.setOnClickListener {
@ -148,6 +150,17 @@ class BgTextConfigDialog : BaseDialogFragment() {
cancelButton()
}.show()
}
binding.tvRestore.setOnClickListener {
val defaultConfigs = DefaultData.readConfigs
val layoutNames = defaultConfigs.map { it.name }
selector("选择预设布局", layoutNames) { _, i ->
if (i >= 0) {
ReadBookConfig.durConfig = defaultConfigs[i]
initData()
postEvent(EventBus.UP_CONFIG, true)
}
}
}
binding.swDarkStatusIcon.setOnCheckedChangeListener { _, isChecked ->
setCurStatusIconDark(isChecked)
(activity as? ReadBookActivity)?.upSystemUiVisibility()

@ -39,6 +39,18 @@
app:tint="@color/secondaryText"
android:contentDescription="@string/edit" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_restore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/restore"
android:textColor="@color/primaryText" />
</LinearLayout>
<io.legado.app.lib.theme.view.ATESwitch

Loading…
Cancel
Save