pull/1603/head
kunfei 3 years ago
parent 4a73754942
commit 309f0c53d2
  1. 5
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  3. 10
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  4. 6
      app/src/main/res/menu/txt_toc_regex.xml

@ -105,8 +105,8 @@ class BookInfoActivity :
binding.flAction.setBackgroundColor(bottomBackground) binding.flAction.setBackgroundColor(bottomBackground)
binding.tvShelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground))) binding.tvShelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground)))
binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading)) binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading))
viewModel.bookData.observe(this, { showBook(it) }) viewModel.bookData.observe(this) { showBook(it) }
viewModel.chapterListData.observe(this, { upLoading(false, it) }) viewModel.chapterListData.observe(this) { upLoading(false, it) }
viewModel.initData(intent) viewModel.initData(intent)
initOnClick() initOnClick()
} }
@ -197,6 +197,7 @@ class BookInfoActivity :
it.setLimitContentLength(!item.isChecked) it.setLimitContentLength(!item.isChecked)
viewModel.loadBookInfo(it, false) viewModel.loadBookInfo(it, false)
} }
item.isChecked = !item.isChecked
if (item.isChecked) longToastOnUi(R.string.need_more_time_load_content) if (item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
} }
} }

@ -28,7 +28,7 @@ class BookInfoEditActivity :
override val viewModel by viewModels<BookInfoEditViewModel>() override val viewModel by viewModels<BookInfoEditViewModel>()
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.bookData.observe(this, { upView(it) }) viewModel.bookData.observe(this) { upView(it) }
if (viewModel.bookData.value == null) { if (viewModel.bookData.value == null) {
intent.getStringExtra("bookUrl")?.let { intent.getStringExtra("bookUrl")?.let {
viewModel.loadBook(it) viewModel.loadBook(it)

@ -24,14 +24,13 @@ import io.legado.app.databinding.ItemTocRegexBinding
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.ReadBook
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.util.*
class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex), class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
Toolbar.OnMenuItemClickListener { Toolbar.OnMenuItemClickListener {
@ -60,6 +59,8 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
binding.toolBar.setTitle(R.string.txt_toc_regex) binding.toolBar.setTitle(R.string.txt_toc_regex)
binding.toolBar.inflateMenu(R.menu.txt_toc_regex) binding.toolBar.inflateMenu(R.menu.txt_toc_regex)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.menu.findItem(R.id.menu_limit_content_length)
?.isChecked = ReadBook.book?.getLimitContentLength() == true
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
initView() initView()
initData() initData()
@ -114,6 +115,11 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
R.id.menu_add -> editRule() R.id.menu_add -> editRule()
R.id.menu_default -> viewModel.importDefault() R.id.menu_default -> viewModel.importDefault()
R.id.menu_import -> showImportDialog() R.id.menu_import -> showImportDialog()
R.id.menu_limit_content_length -> {
ReadBook.book?.setLimitContentLength(!item.isChecked)
item.isChecked = !item.isChecked
if (item.isChecked) context?.longToastOnUi(R.string.need_more_time_load_content)
}
} }
return false return false
} }

@ -20,4 +20,10 @@
android:title="@string/import_replace_rule_on_line" android:title="@string/import_replace_rule_on_line"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_limit_content_length"
android:title="@string/limit_content_length"
android:checkable="true"
app:showAsAction="never" />
</menu> </menu>
Loading…
Cancel
Save