X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FHttpAuthenticationDialog.kt;h=fc506f42fdaf9b71323dd319cc960e64cfc8ceb3;hp=0e8a08db715a5dd60ae8c71593a5527434b4fc57;hb=6ea3e4ebd779594b45ad8f51cc40761bb6d89030;hpb=bda37dc9784e900cb64b87af3e221e11320d9d01 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/HttpAuthenticationDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/HttpAuthenticationDialog.kt index 0e8a08db..fc506f42 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/HttpAuthenticationDialog.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/HttpAuthenticationDialog.kt @@ -120,18 +120,19 @@ class HttpAuthenticationDialog : DialogFragment() { // Set the close button listener. dialogBuilder.setNegativeButton(R.string.close) { _: DialogInterface?, _: Int -> - // Cancel the HTTP authentication request. - httpAuthHandler.cancel() + if (httpAuthHandler != null) { + // Cancel the HTTP authentication request. + httpAuthHandler.cancel() - // Reset the HTTP authentication handler. - nestedScrollWebView.resetHttpAuthHandler() - }// Set the proceed button listener. + // Reset the HTTP authentication handler. + nestedScrollWebView.resetHttpAuthHandler() + } + } + + // Set the proceed button listener. dialogBuilder.setPositiveButton(R.string.proceed) { _: DialogInterface?, _: Int -> // Send the login information - login(httpAuthHandler) - - // Reset the HTTP authentication handler. - nestedScrollWebView.resetHttpAuthHandler() + login(httpAuthHandler, nestedScrollWebView) } // Create an alert dialog from the alert dialog builder. @@ -193,7 +194,7 @@ class HttpAuthenticationDialog : DialogFragment() { // Check the key code and event. if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_DOWN) { // The enter key was pressed. // Send the login information. - login(httpAuthHandler) + login(httpAuthHandler, nestedScrollWebView) // Manually dismiss the alert dialog. alertDialog.dismiss() @@ -210,7 +211,7 @@ class HttpAuthenticationDialog : DialogFragment() { // Check the key code and event. if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_DOWN) { // The enter key was pressed. // Send the login information. - login(httpAuthHandler) + login(httpAuthHandler, nestedScrollWebView) // Manually dismiss the alert dialog. alertDialog.dismiss() @@ -249,8 +250,13 @@ class HttpAuthenticationDialog : DialogFragment() { } } - private fun login(httpAuthHandler: HttpAuthHandler) { - // Send the login information. - httpAuthHandler.proceed(usernameEditText.text.toString(), passwordEditText.text.toString()) + private fun login(httpAuthHandler: HttpAuthHandler?, nestedScrollWebView: NestedScrollWebView) { + if (httpAuthHandler != null) { + // Send the login information. + httpAuthHandler.proceed(usernameEditText.text.toString(), passwordEditText.text.toString()) + + // Reset the HTTP authentication handler. + nestedScrollWebView.resetHttpAuthHandler() + } } } \ No newline at end of file