From 701453cc1b86f64057b6b837c74d492c6b8ef812 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Tue, 19 Jul 2022 09:46:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/dao/BookSourceDao.kt | 9 ++++- .../app/ui/book/search/SearchActivity.kt | 40 ++++++++++++------- .../app/ui/book/search/SearchAdapter.kt | 4 +- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index 182023f72..f98063115 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -96,7 +96,14 @@ interface BookSourceDao { @Query("select * from book_sources where bookSourceGroup like '%' || :group || '%'") fun getByGroup(group: String): List - @Query("select * from book_sources where enabled = 1 and bookSourceGroup like '%' || :group || '%'") + @Query( + """select * from book_sources + where enabled = 1 + and (bookSourceGroup = :group + or bookSourceGroup like :group || ',%' + or bookSourceGroup like '%,' || :group + or bookSourceGroup like '%,' || :group || ',%')""" + ) fun getEnabledByGroup(group: String): List @Query("select * from book_sources where enabled = 1 and bookSourceType = :type") diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index d04b0b7d7..bb254de03 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -36,6 +36,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.conflate import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import splitties.init.appCtx class SearchActivity : VMBaseActivity(), BookAdapter.CallBack, @@ -65,21 +66,29 @@ class SearchActivity : VMBaseActivity() - private val searchFinishCallback: (isEmpty: Boolean) -> Unit = { - if (it) { - val searchGroup = AppConfig.searchGroup - if (searchGroup.isNotEmpty()) { - launch { - alert("搜索结果为空") { - setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组") - noButton() - yesButton { - AppConfig.searchGroup = "" - viewModel.searchKey = "" - viewModel.search(searchView.query.toString()) - } + private val searchFinishCallback: (isEmpty: Boolean) -> Unit = searchFinish@{ isEmpty -> + val searchGroup = AppConfig.searchGroup + if (!isEmpty || searchGroup.isEmpty()) return@searchFinish + launch { + alert("搜索结果为空") { + val precisionSearch = appCtx.getPrefBoolean(PreferKey.precisionSearch) + if (precisionSearch) { + setMessage("${searchGroup}分组搜索结果为空,是否关闭精准搜索?") + yesButton { + appCtx.putPrefBoolean(PreferKey.precisionSearch, false) + precisionSearchMenuItem?.isChecked = false + viewModel.searchKey = "" + viewModel.search(searchView.query.toString()) + } + } else { + setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组?") + yesButton { + AppConfig.searchGroup = "" + viewModel.searchKey = "" + viewModel.search(searchView.query.toString()) } } + noButton() } } } @@ -359,10 +368,11 @@ class SearchActivity : VMBaseActivity { putExtra("name", name) putExtra("author", author) + putExtra("bookUrl", bookUrl) } } @@ -370,7 +380,7 @@ class SearchActivity : VMBaseActivity Date: Tue, 19 Jul 2022 09:56:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/rss/read/ReadRssActivity.kt | 8 ++++++++ app/src/main/res/layout/activity_rss_read.xml | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 8cd4fae57..9dec07ee4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -17,6 +17,7 @@ import io.legado.app.constant.AppConst import io.legado.app.databinding.ActivityRssReadBinding import io.legado.app.help.config.AppConfig import io.legado.app.lib.dialogs.SelectItem +import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.primaryTextColor import io.legado.app.model.Download import io.legado.app.ui.association.OnLineImportActivity @@ -118,6 +119,7 @@ class ReadRssActivity : VMBaseActivity @SuppressLint("SetJavaScriptEnabled") private fun initWebView() { + binding.progressBar.fontColor = accentColor binding.webView.webChromeClient = CustomWebChromeClient() binding.webView.webViewClient = CustomWebViewClient() binding.webView.settings.apply { @@ -295,6 +297,12 @@ class ReadRssActivity : VMBaseActivity inner class CustomWebChromeClient : WebChromeClient() { + override fun onProgressChanged(view: WebView?, newProgress: Int) { + super.onProgressChanged(view, newProgress) + binding.progressBar.setDurProgress(newProgress) + binding.progressBar.gone(newProgress == 100) + } + override fun onShowCustomView(view: View?, callback: CustomViewCallback?) { requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR binding.llView.invisible() diff --git a/app/src/main/res/layout/activity_rss_read.xml b/app/src/main/res/layout/activity_rss_read.xml index 6eb28b4f8..a946c6d40 100644 --- a/app/src/main/res/layout/activity_rss_read.xml +++ b/app/src/main/res/layout/activity_rss_read.xml @@ -5,7 +5,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> - + app:fitStatusBar="false" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_height="0dp" + app:layout_constraintTop_toBottomOf="@+id/title_bar" + app:layout_constraintBottom_toBottomOf="parent" /> - + + + Date: Tue, 19 Jul 2022 10:08:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/browser/WebViewActivity.kt | 8 ++++++++ app/src/main/res/layout/activity_web_view.xml | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt index 8f2340d79..ad0265c60 100644 --- a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt +++ b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt @@ -21,6 +21,7 @@ import io.legado.app.help.SourceVerificationHelp import io.legado.app.help.config.AppConfig import io.legado.app.help.http.CookieStore import io.legado.app.lib.dialogs.SelectItem +import io.legado.app.lib.theme.accentColor import io.legado.app.model.Download import io.legado.app.ui.association.OnLineImportActivity import io.legado.app.ui.document.HandleFileContract @@ -81,6 +82,7 @@ class WebViewActivity : VMBaseActivity() { @SuppressLint("JavascriptInterface", "SetJavaScriptEnabled") private fun initWebView(url: String, headerMap: HashMap) { + binding.progressBar.fontColor = accentColor binding.webView.webChromeClient = CustomWebChromeClient() binding.webView.webViewClient = CustomWebViewClient() binding.webView.settings.apply { @@ -191,6 +193,12 @@ class WebViewActivity : VMBaseActivity() { inner class CustomWebChromeClient : WebChromeClient() { + override fun onProgressChanged(view: WebView?, newProgress: Int) { + super.onProgressChanged(view, newProgress) + binding.progressBar.setDurProgress(newProgress) + binding.progressBar.gone(newProgress == 100) + } + override fun onShowCustomView(view: View?, callback: CustomViewCallback?) { requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR binding.llView.invisible() diff --git a/app/src/main/res/layout/activity_web_view.xml b/app/src/main/res/layout/activity_web_view.xml index 6eb28b4f8..a946c6d40 100644 --- a/app/src/main/res/layout/activity_web_view.xml +++ b/app/src/main/res/layout/activity_web_view.xml @@ -5,7 +5,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> - + app:fitStatusBar="false" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_height="0dp" + app:layout_constraintTop_toBottomOf="@+id/title_bar" + app:layout_constraintBottom_toBottomOf="parent" /> - + + + Date: Tue, 19 Jul 2022 10:15:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/login/WebViewLoginFragment.kt | 16 +++++++++------- .../res/layout/fragment_web_view_login.xml | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt index 19871c6b4..9c19605a4 100644 --- a/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt +++ b/app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt @@ -14,6 +14,8 @@ import io.legado.app.constant.AppConst import io.legado.app.data.entities.BaseSource import io.legado.app.databinding.FragmentWebViewLoginBinding import io.legado.app.help.http.CookieStore +import io.legado.app.lib.theme.accentColor +import io.legado.app.utils.gone import io.legado.app.utils.snackbar import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -54,6 +56,7 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) { @SuppressLint("SetJavaScriptEnabled") private fun initWebView(source: BaseSource) { + binding.progressBar.fontColor = accentColor binding.webView.settings.apply { mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW domStorageEnabled = true @@ -86,14 +89,13 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) { } } binding.webView.webChromeClient = object : WebChromeClient() { - override fun onJsAlert( - view: WebView?, - url: String?, - message: String?, - result: JsResult? - ): Boolean { - return super.onJsAlert(view, url, message, result) + + override fun onProgressChanged(view: WebView?, newProgress: Int) { + super.onProgressChanged(view, newProgress) + binding.progressBar.setDurProgress(newProgress) + binding.progressBar.gone(newProgress == 100) } + } source.loginUrl?.let { binding.webView.loadUrl(it, source.getHeaderMap(true)) diff --git a/app/src/main/res/layout/fragment_web_view_login.xml b/app/src/main/res/layout/fragment_web_view_login.xml index 28d14f347..6db638382 100644 --- a/app/src/main/res/layout/fragment_web_view_login.xml +++ b/app/src/main/res/layout/fragment_web_view_login.xml @@ -1,5 +1,5 @@ - + app:title="@string/login" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_height="0dp" + app:layout_constraintTop_toBottomOf="@+id/title_bar" + app:layout_constraintBottom_toBottomOf="parent" /> - \ No newline at end of file + + + \ No newline at end of file