背景配置自由添加

pull/371/head
gedoor 4 years ago
parent 21f941c64b
commit 808fbd83e1
  1. 13
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 13
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  3. 29
      app/src/main/res/layout/dialog_read_bg_text.xml

@ -118,13 +118,16 @@ object ReadBookConfig {
} }
} }
fun resetDur() { fun deleteDur(): Boolean {
defaultConfigs[styleSelect].let { if (configList.size > 5) {
durConfig.setBg(it.bgType(), it.bgStr()) configList.removeAt(styleSelect)
durConfig.setTextColor(it.textColor()) if (styleSelect > 0) {
styleSelect -= 1
}
upBg() upBg()
save() return true
} }
return false
} }
private fun resetAll() { private fun resetAll() {

@ -102,6 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
sw_dark_status_icon.setTextColor(primaryTextColor) sw_dark_status_icon.setTextColor(primaryTextColor)
iv_import.setColorFilter(primaryTextColor) iv_import.setColorFilter(primaryTextColor)
iv_export.setColorFilter(primaryTextColor) iv_export.setColorFilter(primaryTextColor)
iv_delete.setColorFilter(primaryTextColor)
tv_bg_image.setTextColor(primaryTextColor) tv_bg_image.setTextColor(primaryTextColor)
} }
@ -149,10 +150,6 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
.setDialogId(BG_COLOR) .setDialogId(BG_COLOR)
.show(requireActivity()) .show(requireActivity())
} }
tv_default.onClick {
ReadBookConfig.resetDur()
postEvent(EventBus.UP_CONFIG, false)
}
iv_import.onClick { iv_import.onClick {
val importFormNet = "网络导入" val importFormNet = "网络导入"
val otherActions = arrayListOf(importFormNet) val otherActions = arrayListOf(importFormNet)
@ -175,6 +172,14 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
title = getString(R.string.export_str) title = getString(R.string.export_str)
) )
} }
iv_delete.onClick {
if (ReadBookConfig.deleteDur()) {
postEvent(EventBus.UP_CONFIG, true)
dismiss()
} else {
toast("数量以是最少,不能删除.")
}
}
} }
private fun selectImage() { private fun selectImage() {

@ -57,23 +57,6 @@
app:isBottomBackground="true" app:isBottomBackground="true"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<io.legado.app.ui.widget.text.StrokeTextView
android:id="@+id/tv_default"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_weight="3"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="6dp"
android:singleLine="true"
android:text="@string/btn_default_s"
android:textSize="14sp"
app:isBottomBackground="true"
tools:ignore="HardcodedText" />
<ImageView <ImageView
android:id="@+id/iv_import" android:id="@+id/iv_import"
android:layout_width="36dp" android:layout_width="36dp"
@ -98,6 +81,18 @@
android:tooltipText="@string/export_str" android:tooltipText="@string/export_str"
tools:ignore="UnusedAttribute" /> tools:ignore="UnusedAttribute" />
<ImageView
android:id="@+id/iv_delete"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/delete"
android:src="@drawable/ic_clear_all"
android:tooltipText="@string/delete"
tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
<TextView <TextView

Loading…
Cancel
Save