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

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 {
BookSource.fromJson(code)?.let { 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(
CodeDialog(
GSON.toJson(source),
disableEdit = false,
requestId = holder.layoutPosition.toString()
)
)

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

@ -193,7 +193,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
requestId?.toInt()?.let {
RssSource.fromJson(code)?.let { 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(
CodeDialog(
GSON.toJson(source),
disableEdit = false,
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.addJsonPattern
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.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -48,12 +49,16 @@ class CodeDialog() : BaseDialogFragment(R.layout.dialog_code_view) {
private fun initMenu() {
binding.toolBar.inflateMenu(R.menu.code_edit)
binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_save -> binding.codeView.text?.toString()?.let { code ->
val requestId = arguments?.getString("requestId")
(parentFragment as? Callback)?.onCodeSave(code, requestId)
?: (activity as? Callback)?.onCodeSave(code, requestId)
R.id.menu_save -> {
binding.codeView.text?.toString()?.let { code ->
val requestId = arguments?.getString("requestId")
(parentFragment as? Callback)?.onCodeSave(code, requestId)
?: (activity as? Callback)?.onCodeSave(code, requestId)
}
dismiss()
}
}
return@setOnMenuItemClickListener true

Loading…
Cancel
Save