添加进度条
This commit is contained in:
@@ -14,6 +14,8 @@ import io.legado.app.constant.AppConst
|
|||||||
import io.legado.app.data.entities.BaseSource
|
import io.legado.app.data.entities.BaseSource
|
||||||
import io.legado.app.databinding.FragmentWebViewLoginBinding
|
import io.legado.app.databinding.FragmentWebViewLoginBinding
|
||||||
import io.legado.app.help.http.CookieStore
|
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.snackbar
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) {
|
|||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
private fun initWebView(source: BaseSource) {
|
private fun initWebView(source: BaseSource) {
|
||||||
|
binding.progressBar.fontColor = accentColor
|
||||||
binding.webView.settings.apply {
|
binding.webView.settings.apply {
|
||||||
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
||||||
domStorageEnabled = true
|
domStorageEnabled = true
|
||||||
@@ -86,14 +89,13 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.webView.webChromeClient = object : WebChromeClient() {
|
binding.webView.webChromeClient = object : WebChromeClient() {
|
||||||
override fun onJsAlert(
|
|
||||||
view: WebView?,
|
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||||
url: String?,
|
super.onProgressChanged(view, newProgress)
|
||||||
message: String?,
|
binding.progressBar.setDurProgress(newProgress)
|
||||||
result: JsResult?
|
binding.progressBar.gone(newProgress == 100)
|
||||||
): Boolean {
|
|
||||||
return super.onJsAlert(view, url, message, result)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
source.loginUrl?.let {
|
source.loginUrl?.let {
|
||||||
binding.webView.loadUrl(it, source.getHeaderMap(true))
|
binding.webView.loadUrl(it, source.getHeaderMap(true))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
@@ -10,11 +10,21 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:attachToActivity="false"
|
app:attachToActivity="false"
|
||||||
app:title="@string/login" />
|
app:title="@string/login"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/web_view"
|
android:id="@+id/web_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title_bar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
</LinearLayout>
|
<io.legado.app.ui.widget.anima.RefreshProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
app:max_progress="100"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/web_view" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user