导入源和规则时可以先编辑再导入

pull/1415/head
gedoor 3 years ago
parent cbcbcc7d35
commit d7b73b801b
  1. 3
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 6
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  3. 3
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  4. 13
      app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt

@ -194,7 +194,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
requestId?.toInt()?.let { requestId?.toInt()?.let {
BookSource.fromJson(code)?.let { source -> BookSource.fromJson(code)?.let { source ->
viewModel.allSources[it] = source viewModel.allSources[it] = source
adapter.notifyItemChanged(it) adapter.setItem(it, source)
} }
} }
} }
@ -242,6 +242,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
showDialogFragment( showDialogFragment(
CodeDialog( CodeDialog(
GSON.toJson(source), GSON.toJson(source),
disableEdit = false,
requestId = holder.layoutPosition.toString() requestId = holder.layoutPosition.toString()
) )
) )

@ -186,7 +186,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
requestId?.toInt()?.let { requestId?.toInt()?.let {
GSON.fromJsonObject<ReplaceRule>(code)?.let { rule -> GSON.fromJsonObject<ReplaceRule>(code)?.let { rule ->
viewModel.allRules[it] = rule viewModel.allRules[it] = rule
adapter.notifyItemChanged(it) adapter.setItem(it, rule)
} }
} }
} }
@ -198,6 +198,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
return ItemSourceImportBinding.inflate(inflater, parent, false) return ItemSourceImportBinding.inflate(inflater, parent, false)
} }
@SuppressLint("SetTextI18n")
override fun convert( override fun convert(
holder: ItemViewHolder, holder: ItemViewHolder,
binding: ItemSourceImportBinding, binding: ItemSourceImportBinding,
@ -206,7 +207,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
) { ) {
binding.run { binding.run {
cbSourceName.isChecked = viewModel.selectStatus[holder.layoutPosition] cbSourceName.isChecked = viewModel.selectStatus[holder.layoutPosition]
cbSourceName.text = item.name cbSourceName.text = "${item.name}(${item.group})"
val localRule = viewModel.checkRules[holder.layoutPosition] val localRule = viewModel.checkRules[holder.layoutPosition]
tvSourceState.text = when { tvSourceState.text = when {
localRule == null -> "新增" localRule == null -> "新增"
@ -237,6 +238,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
showDialogFragment( showDialogFragment(
CodeDialog( CodeDialog(
GSON.toJson(source), GSON.toJson(source),
disableEdit = false,
requestId = holder.layoutPosition.toString() requestId = holder.layoutPosition.toString()
) )
) )

@ -193,7 +193,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
requestId?.toInt()?.let { requestId?.toInt()?.let {
RssSource.fromJson(code)?.let { source -> RssSource.fromJson(code)?.let { source ->
viewModel.allSources[it] = source viewModel.allSources[it] = source
adapter.notifyItemChanged(it) adapter.setItem(it, source)
} }
} }
} }
@ -240,6 +240,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
showDialogFragment( showDialogFragment(
CodeDialog( CodeDialog(
GSON.toJson(source), GSON.toJson(source),
disableEdit = false,
requestId = holder.layoutPosition.toString() requestId = holder.layoutPosition.toString()
) )
) )

@ -9,6 +9,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.code.addJsPattern import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern import io.legado.app.ui.widget.code.addLegadoPattern
import io.legado.app.utils.applyTint
import io.legado.app.utils.disableEdit import io.legado.app.utils.disableEdit
import io.legado.app.utils.setLayout import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -48,12 +49,16 @@ class CodeDialog() : BaseDialogFragment(R.layout.dialog_code_view) {
private fun initMenu() { private fun initMenu() {
binding.toolBar.inflateMenu(R.menu.code_edit) binding.toolBar.inflateMenu(R.menu.code_edit)
binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener { binding.toolBar.setOnMenuItemClickListener {
when (it.itemId) { when (it.itemId) {
R.id.menu_save -> binding.codeView.text?.toString()?.let { code -> R.id.menu_save -> {
val requestId = arguments?.getString("requestId") binding.codeView.text?.toString()?.let { code ->
(parentFragment as? Callback)?.onCodeSave(code, requestId) val requestId = arguments?.getString("requestId")
?: (activity as? Callback)?.onCodeSave(code, requestId) (parentFragment as? Callback)?.onCodeSave(code, requestId)
?: (activity as? Callback)?.onCodeSave(code, requestId)
}
dismiss()
} }
} }
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true

Loading…
Cancel
Save