GitHub授权按钮在WebView中不起作用

时间:2019-05-18 23:22:14

标签: android kotlin android-webview

我想在应用程序内部提供自定义浏览器,以便用户可以在 GitHub.com 上通过授权。但是在WebView中禁用了授权按钮。
Screenshot

我在 stackoverflow 上设置了其他问题的推荐标志,但这没有帮助。我的ViewModel在下面,您可以看到我为WebView设置的标志和客户端:

class LoginViewModel : ViewModel() {

    var url: ObservableField<String> = ObservableField()

    var isLoading: ObservableBoolean = ObservableBoolean()

    val webViewClient: WebViewClient = object : WebViewClient() {

        override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
            view?.loadUrl(url)
            return true
        }

        override fun onReceivedError(
            view: WebView, request: WebResourceRequest,
            error: WebResourceError
        ) {
            super.onReceivedError(view, request, error)
            isLoading.set(false)
        }

        override fun onPageFinished(view: WebView, url: String) {
            super.onPageFinished(view, url)
            isLoading.set(false)
        }
    }

    val webChromeClient: WebChromeClient = WebChromeClient()

    val webViewConfig: IWebViewConfig = object : IWebViewConfig {

        override fun onConfig(webView: WebView) {
            webView.settings.domStorageEnabled = true
            webView.settings.databaseEnabled = true
            webView.settings.javaScriptEnabled = true
            webView.settings.loadWithOverviewMode = true
            webView.settings.useWideViewPort = true
            webView.settings.allowContentAccess = true
            webView.settings.allowFileAccess = true
            webView.settings.allowFileAccessFromFileURLs = true
            webView.settings.allowUniversalAccessFromFileURLs = true
            webView.settings.userAgentString = "Android"
        }

    }

    fun onRefresh() {
        isLoading.set(true)
        url.notifyChange()
    }
}

问题出在哪里?

0 个答案:

没有答案