From d7a5979b4a13ad298b41a85339efef55085d852b Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 1 Nov 2022 21:58:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 +- .../app/ui/association/ImportHttpTtsDialog.kt | 12 +++++++++++- .../app/ui/book/read/config/HttpTtsEditDialog.kt | 2 ++ .../java/io/legado/app/ui/book/toc/TocActivity.kt | 14 +++++--------- app/src/main/res/layout/dialog_http_tts_edit.xml | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index ec5933448..8c74b095e 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -289,7 +289,7 @@ class AnalyzeUrl( private fun fetchStart(): ConcurrentRecord? { source ?: return null val concurrentRate = source.concurrentRate - if (concurrentRate.isNullOrEmpty()) { + if (concurrentRate.isNullOrEmpty() || concurrentRate == "0") { return null } val rateIndex = concurrentRate.indexOf("/") diff --git a/app/src/main/java/io/legado/app/ui/association/ImportHttpTtsDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportHttpTtsDialog.kt index 1952008a1..46ded7973 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportHttpTtsDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportHttpTtsDialog.kt @@ -25,7 +25,8 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.visible import splitties.views.onClick -class ImportHttpTtsDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) { +class ImportHttpTtsDialog() : BaseDialogFragment(R.layout.dialog_recycler_view), + CodeDialog.Callback { constructor(source: String, finishOnDismiss: Boolean = false) : this() { arguments = Bundle().apply { @@ -176,4 +177,13 @@ class ImportHttpTtsDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) } } + + override fun onCodeSave(code: String, requestId: String?) { + requestId?.toInt()?.let { + HttpTTS.fromJson(code).getOrNull()?.let { source -> + viewModel.allSources[it] = source + adapter.setItem(it, source) + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt index eed08b409..57bad73d0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt @@ -73,6 +73,7 @@ class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit, tr binding.tvName.setText(httpTTS.name) binding.tvUrl.setText(httpTTS.url) binding.tvContentType.setText(httpTTS.contentType) + binding.tvConcurrentRate.setText(httpTTS.concurrentRate) binding.tvLoginUrl.setText(httpTTS.loginUrl) binding.tvLoginUi.setText(httpTTS.loginUi) binding.tvLoginCheckJs.setText(httpTTS.loginCheckJs) @@ -121,6 +122,7 @@ class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit, tr name = binding.tvName.text.toString(), url = binding.tvUrl.text.toString(), contentType = binding.tvContentType.text?.toString(), + concurrentRate = binding.tvConcurrentRate.text?.toString(), loginUrl = binding.tvLoginUrl.text?.toString(), loginUi = binding.tvLoginUi.text?.toString(), loginCheckJs = binding.tvLoginCheckJs.text?.toString(), diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt index ed6c5e1b4..da4ae0f4d 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt @@ -85,6 +85,11 @@ class TocActivity : VMBaseActivity() { return false } }) + setOnQueryTextFocusChangeListener { v, hasFocus -> + if (!hasFocus) { + searchView?.isIconified = true + } + } } return super.onCompatCreateOptionsMenu(menu) } @@ -116,15 +121,6 @@ class TocActivity : VMBaseActivity() { return super.onCompatOptionsItemSelected(item) } - override fun finish() { - if (tabLayout.isGone) { - searchView?.onActionViewCollapsed() - tabLayout.visible() - } else { - super.finish() - } - } - @Suppress("DEPRECATION") private inner class TabFragmentPageAdapter : FragmentPagerAdapter(supportFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { diff --git a/app/src/main/res/layout/dialog_http_tts_edit.xml b/app/src/main/res/layout/dialog_http_tts_edit.xml index dc5f489c0..77429784b 100644 --- a/app/src/main/res/layout/dialog_http_tts_edit.xml +++ b/app/src/main/res/layout/dialog_http_tts_edit.xml @@ -75,6 +75,20 @@ + + + + + +