mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-27 07:29:48 +01:00
Catch NPE on webLogin view binding
Resolves: #1958 Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
2fc5545576
commit
ff5f686d7c
@ -30,6 +30,7 @@ import android.os.Bundle
|
|||||||
import android.security.KeyChain
|
import android.security.KeyChain
|
||||||
import android.security.KeyChainException
|
import android.security.KeyChainException
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.webkit.ClientCertRequest
|
import android.webkit.ClientCertRequest
|
||||||
import android.webkit.CookieSyncManager
|
import android.webkit.CookieSyncManager
|
||||||
@ -77,7 +78,6 @@ import java.net.URLDecoder
|
|||||||
import java.security.PrivateKey
|
import java.security.PrivateKey
|
||||||
import java.security.cert.CertificateException
|
import java.security.cert.CertificateException
|
||||||
import java.security.cert.X509Certificate
|
import java.security.cert.X509Certificate
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -183,32 +183,39 @@ class WebViewLoginController(args: Bundle? = null) : NewBaseController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageFinished(view: WebView, url: String) {
|
override fun onPageFinished(view: WebView, url: String) {
|
||||||
loginStep++
|
try {
|
||||||
if (!basePageLoaded) {
|
loginStep++
|
||||||
binding.progressBar.visibility = View.GONE
|
if (!basePageLoaded) {
|
||||||
binding.webview.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.GONE
|
||||||
|
binding.webview.visibility = View.VISIBLE
|
||||||
|
|
||||||
basePageLoaded = true
|
basePageLoaded = true
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(username)) {
|
if (!TextUtils.isEmpty(username)) {
|
||||||
if (loginStep == 1) {
|
if (loginStep == 1) {
|
||||||
binding.webview.loadUrl("javascript: {document.getElementsByClassName('login')[0].click(); };")
|
binding.webview.loadUrl("javascript: {document.getElementsByClassName('login')[0].click(); };")
|
||||||
} else if (!automatedLoginAttempted) {
|
} else if (!automatedLoginAttempted) {
|
||||||
automatedLoginAttempted = true
|
automatedLoginAttempted = true
|
||||||
if (TextUtils.isEmpty(password)) {
|
if (TextUtils.isEmpty(password)) {
|
||||||
binding.webview.loadUrl(
|
binding.webview.loadUrl(
|
||||||
"javascript:var justStore = document.getElementById('user').value = '$username';"
|
"javascript:var justStore = document.getElementById('user').value = '$username';"
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
binding.webview.loadUrl(
|
binding.webview.loadUrl(
|
||||||
"javascript: {" +
|
"javascript: {" +
|
||||||
"document.getElementById('user').value = '" + username + "';" +
|
"document.getElementById('user').value = '" + username + "';" +
|
||||||
"document.getElementById('password').value = '" + password + "';" +
|
"document.getElementById('password').value = '" + password + "';" +
|
||||||
"document.getElementById('submit').click(); };"
|
"document.getElementById('submit').click(); };"
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchronously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onPageFinished(view, url)
|
super.onPageFinished(view, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user