From f3d79238034586d2fb81cff21d8ecdeb3a15ad54 Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Tue, 3 May 2022 19:14:55 +0200 Subject: [PATCH] Improve UX when Login WebView fails to load the page (#2492) Previously we simply closed the screen with the login WebView which could cause confusion. Now we specify that page could not be loaded. As a side effect it will also show the error message which the server returns (if any). --- .../com/keylesspalace/tusky/components/login/LoginActivity.kt | 4 +++- .../tusky/components/login/LoginWebViewActivity.kt | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt index 4df7abc1..bcbb4abf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt @@ -68,7 +68,9 @@ class LoginActivity : BaseActivity(), Injectable { // Authorization failed. Put the error response where the user can read it and they // can try again. setLoading(false) - binding.domainTextInputLayout.error = getString(R.string.error_authorization_denied) + // Use error returned by the server or fall back to the generic message + binding.domainTextInputLayout.error = + result.errorMessage.ifBlank { getString(R.string.error_authorization_denied) } Log.e( TAG, "%s %s".format( diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt index 58f745e7..a32a164c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt @@ -117,7 +117,7 @@ class LoginWebViewActivity : BaseActivity(), Injectable { error: WebResourceError ) { Log.d("LoginWeb", "Failed to load ${data.url}: $error") - finishWithoutSlideOutAnimation() + sendResult(LoginResult.Err(getString(R.string.error_could_not_load_login_page))) } override fun shouldOverrideUrlLoading( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2a209d9a..fc1ed743 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,6 +9,7 @@ An unidentified authorization error occurred. Authorization was denied. Failed getting a login token. + Could not load the login page. The post is too long! The file must be less than 8MB. Video files must be less than 40MB.