Merge pull request #2181 from 52fisher/master

阅读界面的TXT目录正则 弹框中也支持正则标题示例
pull/2189/head
kunfei 2 years ago committed by GitHub
commit d1acdb3f28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  2. 81
      app/src/main/res/layout/item_toc_regex.xml

@ -169,12 +169,14 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
alertBinding.apply { alertBinding.apply {
tvRuleName.setText(tocRule.name) tvRuleName.setText(tocRule.name)
tvRuleRegex.setText(tocRule.rule) tvRuleRegex.setText(tocRule.rule)
tvRuleExample.setText(tocRule.example)
} }
customView { alertBinding.root } customView { alertBinding.root }
okButton { okButton {
alertBinding.apply { alertBinding.apply {
tocRule.name = tvRuleName.text.toString() tocRule.name = tvRuleName.text.toString()
tocRule.rule = tvRuleRegex.text.toString() tocRule.rule = tvRuleRegex.text.toString()
tocRule.example = tvRuleExample.text.toString()
viewModel.saveRule(tocRule) viewModel.saveRule(tocRule)
} }
} }
@ -200,6 +202,7 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
rbRegexName.text = item.name rbRegexName.text = item.name
titleExample.text = item.example
rbRegexName.isChecked = item.name == selectedName rbRegexName.isChecked = item.name == selectedName
swtEnabled.isChecked = item.enable swtEnabled.isChecked = item.enable
} else { } else {

@ -3,45 +3,56 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="16dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="vertical">
<io.legado.app.lib.theme.view.ThemeRadioButton <LinearLayout
android:id="@+id/rb_regex_name" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="match_parent"
android:layout_height="wrap_content" android:gravity="center_vertical">
android:layout_weight="1" <io.legado.app.lib.theme.view.ThemeRadioButton
android:maxLines="1" /> android:id="@+id/rb_regex_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1" />
<io.legado.app.lib.theme.view.ThemeSwitch
android:id="@+id/swt_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<io.legado.app.lib.theme.view.ThemeSwitch <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/swt_enabled" android:id="@+id/iv_edit"
android:layout_width="wrap_content" android:layout_width="36dp"
android:layout_height="wrap_content" /> android:layout_height="36dp"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/edit"
android:padding="6dp"
android:tooltipText="@string/edit"
android:src="@drawable/ic_edit"
android:tint="@color/primaryText"
tools:ignore="UnusedAttribute" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_edit" android:id="@+id/iv_delete"
android:layout_width="36dp" android:layout_width="36dp"
android:layout_height="36dp" android:layout_height="36dp"
android:layout_gravity="center" android:background="?attr/selectableItemBackgroundBorderless"
android:background="?android:attr/selectableItemBackgroundBorderless" android:contentDescription="@string/more_menu"
android:contentDescription="@string/edit" android:tooltipText="@string/more_menu"
android:padding="6dp" android:padding="6dp"
android:tooltipText="@string/edit" android:src="@drawable/ic_clear_all"
android:src="@drawable/ic_edit" android:tint="@color/primaryText"
android:tint="@color/primaryText" tools:ignore="UnusedAttribute" />
tools:ignore="UnusedAttribute" /> </LinearLayout>
<androidx.appcompat.widget.AppCompatImageView <TextView
android:id="@+id/iv_delete" android:id="@+id/title_example"
android:layout_width="36dp" android:layout_width="match_parent"
android:layout_height="36dp" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless" android:textSize="12sp" />
android:contentDescription="@string/more_menu"
android:tooltipText="@string/more_menu"
android:padding="6dp"
android:src="@drawable/ic_clear_all"
android:tint="@color/primaryText"
tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
Loading…
Cancel
Save