编辑源菜单添加清除cookie

pull/1881/head
kunfei 3 years ago
parent 17fd77a53e
commit 62fe4e8597
  1. 8
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  3. 7
      app/src/main/res/layout/activity_rss_source_edit.xml

@ -47,7 +47,7 @@ class BookSourceEditActivity :
private val qrCodeResult = registerForActivityResult(QrCodeResult()) { private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
it ?: return@registerForActivityResult it ?: return@registerForActivityResult
viewModel.importSource(it) { source -> viewModel.importSource(it) { source ->
upRecyclerView(source) upSourceView(source)
} }
} }
private val selectDoc = registerForActivityResult(HandleFileContract()) { private val selectDoc = registerForActivityResult(HandleFileContract()) {
@ -68,7 +68,7 @@ class BookSourceEditActivity :
softKeyboardTool.attachToWindow(window) softKeyboardTool.attachToWindow(window)
initView() initView()
viewModel.initData(intent) { viewModel.initData(intent) {
upRecyclerView() upSourceView()
} }
} }
@ -112,7 +112,7 @@ class BookSourceEditActivity :
R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl) R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl)
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete
R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource())) R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource()))
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_paste_source -> viewModel.pasteSource { upSourceView(it) }
R.id.menu_qr_code_camera -> qrCodeResult.launch() R.id.menu_qr_code_camera -> qrCodeResult.launch()
R.id.menu_share_str -> share(GSON.toJson(getSource())) R.id.menu_share_str -> share(GSON.toJson(getSource()))
R.id.menu_share_qr -> shareWithQr( R.id.menu_share_qr -> shareWithQr(
@ -187,7 +187,7 @@ class BookSourceEditActivity :
binding.recyclerView.scrollToPosition(0) binding.recyclerView.scrollToPosition(0)
} }
private fun upRecyclerView(source: BookSource? = viewModel.bookSource) { private fun upSourceView(source: BookSource? = viewModel.bookSource) {
source?.let { source?.let {
binding.cbIsEnable.isChecked = it.enabled binding.cbIsEnable.isChecked = it.enabled
binding.cbIsEnableFind.isChecked = it.enabledExplore binding.cbIsEnableFind.isChecked = it.enabledExplore

@ -48,7 +48,7 @@ class RssSourceEditActivity :
private val qrCodeResult = registerForActivityResult(QrCodeResult()) { private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
it?.let { it?.let {
viewModel.importSource(it) { source: RssSource -> viewModel.importSource(it) { source: RssSource ->
upRecyclerView(source) upSourceView(source)
} }
} }
} }
@ -57,7 +57,7 @@ class RssSourceEditActivity :
softKeyboardTool.attachToWindow(window) softKeyboardTool.attachToWindow(window)
initView() initView()
viewModel.initData(intent) { viewModel.initData(intent) {
upRecyclerView() upSourceView()
} }
} }
@ -134,7 +134,7 @@ class RssSourceEditActivity :
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete
R.id.menu_copy_source -> sendToClip(GSON.toJson(getRssSource())) R.id.menu_copy_source -> sendToClip(GSON.toJson(getRssSource()))
R.id.menu_qr_code_camera -> qrCodeResult.launch() R.id.menu_qr_code_camera -> qrCodeResult.launch()
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_paste_source -> viewModel.pasteSource { upSourceView(it) }
R.id.menu_share_str -> share(GSON.toJson(getRssSource())) R.id.menu_share_str -> share(GSON.toJson(getRssSource()))
R.id.menu_share_qr -> shareWithQr( R.id.menu_share_qr -> shareWithQr(
GSON.toJson(getRssSource()), GSON.toJson(getRssSource()),
@ -151,10 +151,11 @@ class RssSourceEditActivity :
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
} }
private fun upRecyclerView(source: RssSource? = viewModel.rssSource) { private fun upSourceView(source: RssSource? = viewModel.rssSource) {
source?.let { source?.let {
binding.cbIsEnable.isChecked = source.enabled binding.cbIsEnable.isChecked = source.enabled
binding.cbSingleUrl.isChecked = source.singleUrl binding.cbSingleUrl.isChecked = source.singleUrl
binding.cbIsEnableCookie.isChecked = source.enabledCookieJar == true
binding.cbEnableJs.isChecked = source.enableJs binding.cbEnableJs.isChecked = source.enableJs
binding.cbEnableBaseUrl.isChecked = source.loadWithBaseUrl binding.cbEnableBaseUrl.isChecked = source.loadWithBaseUrl
} }
@ -192,6 +193,7 @@ class RssSourceEditActivity :
val source = viewModel.rssSource val source = viewModel.rssSource
source.enabled = binding.cbIsEnable.isChecked source.enabled = binding.cbIsEnable.isChecked
source.singleUrl = binding.cbSingleUrl.isChecked source.singleUrl = binding.cbSingleUrl.isChecked
source.enabledCookieJar = binding.cbIsEnableCookie.isChecked
source.enableJs = binding.cbEnableJs.isChecked source.enableJs = binding.cbEnableJs.isChecked
source.loadWithBaseUrl = binding.cbEnableBaseUrl.isChecked source.loadWithBaseUrl = binding.cbEnableBaseUrl.isChecked
sourceEntities.forEach { sourceEntities.forEach {

@ -45,6 +45,13 @@
android:text="@string/single_url" android:text="@string/single_url"
tools:ignore="TouchTargetSizeCheck" /> tools:ignore="TouchTargetSizeCheck" />
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_is_enable_cookie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/auto_save_cookie" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

Loading…
Cancel
Save