From b4551ece5746414c4f630862bf6f5cbdebeb67ad Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 8 Sep 2021 23:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B7=BB=E5=8A=A0=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/login/WebViewLoginFragment.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 843046c54..ffc3e3a45 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 @@ -13,7 +13,7 @@ import androidx.fragment.app.activityViewModels import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.constant.AppConst -import io.legado.app.data.entities.BookSource +import io.legado.app.data.entities.BaseSource import io.legado.app.databinding.FragmentWebViewLoginBinding import io.legado.app.help.http.CookieStore import io.legado.app.utils.snackbar @@ -28,7 +28,7 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.source?.let { - binding.titleBar.title = getString(R.string.login_source, it.bookSourceName) + binding.titleBar.title = getString(R.string.login_source, it.getName()) initWebView(it) } } @@ -52,32 +52,32 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) { } @SuppressLint("SetJavaScriptEnabled") - private fun initWebView(bookSource: BookSource) { + private fun initWebView(source: BaseSource) { val settings = binding.webView.settings settings.setSupportZoom(true) settings.builtInZoomControls = true settings.javaScriptEnabled = true - bookSource.getHeaderMap()[AppConst.UA_NAME]?.let { + source.getHeaderMap()[AppConst.UA_NAME]?.let { settings.userAgentString = it } val cookieManager = CookieManager.getInstance() binding.webView.webViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { val cookie = cookieManager.getCookie(url) - CookieStore.setCookie(bookSource.bookSourceUrl, cookie) + CookieStore.setCookie(source.getStoreUrl(), cookie) super.onPageStarted(view, url, favicon) } override fun onPageFinished(view: WebView?, url: String?) { val cookie = cookieManager.getCookie(url) - CookieStore.setCookie(bookSource.bookSourceUrl, cookie) + CookieStore.setCookie(source.getStoreUrl(), cookie) if (checking) { activity?.finish() } super.onPageFinished(view, url) } } - bookSource.loginUrl?.let { + source.loginUrl?.let { binding.webView.loadUrl(it) } }