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() { @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/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/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" /> - + + + - + app:fitStatusBar="false" + app:layout_constraintTop_toTopOf="parent" /> + android:layout_height="0dp" + app:layout_constraintTop_toBottomOf="@+id/title_bar" + app:layout_constraintBottom_toBottomOf="parent" /> - + + + - + 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