书源登录添加ua

pull/840/head
gedoor 4 years ago
parent b1698efc57
commit 09d50a52d1
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 1
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/login/SourceLogin.kt

@ -15,6 +15,7 @@ import androidx.core.view.size
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import io.legado.app.BuildConfig
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.constant.Status
@ -726,6 +727,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
startActivity<SourceLogin> {
putExtra("sourceUrl", it.bookSourceUrl)
putExtra("loginUrl", it.loginUrl)
putExtra("userAgent", it.getHeaderMap()[AppConst.UA_NAME])
}
}
}

@ -113,6 +113,7 @@ class BookSourceEditActivity :
startActivity<SourceLogin> {
putExtra("sourceUrl", it.bookSourceUrl)
putExtra("loginUrl", it.loginUrl)
putExtra("userAgent", it.getHeaderMap()[AppConst.UA_NAME])
}
}
}

@ -19,6 +19,7 @@ class SourceLogin : BaseActivity<ActivitySourceLoginBinding>() {
var sourceUrl: String? = null
var loginUrl: String? = null
var userAgent: String? = null
var checking = false
override fun getViewBinding(): ActivitySourceLoginBinding {
@ -28,6 +29,7 @@ class SourceLogin : BaseActivity<ActivitySourceLoginBinding>() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
sourceUrl = intent.getStringExtra("sourceUrl")
loginUrl = intent.getStringExtra("loginUrl")
userAgent = intent.getStringExtra("userAgent")
title = getString(R.string.login_source, sourceUrl)
initWebView()
}
@ -38,6 +40,9 @@ class SourceLogin : BaseActivity<ActivitySourceLoginBinding>() {
settings.setSupportZoom(true)
settings.builtInZoomControls = true
settings.javaScriptEnabled = true
userAgent?.let {
settings.userAgentString = it
}
val cookieManager = CookieManager.getInstance()
binding.webView.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {

Loading…
Cancel
Save