From e5b58770ced893cb24733efe42425d4fb7bcdda8 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Thu, 28 Apr 2022 20:38:51 +0200 Subject: [PATCH] improve LoginWebViewActivityUX (#2465) --- .../components/login/LoginWebViewActivity.kt | 18 +++++++++++++++--- app/src/main/res/layout/login_webview.xml | 6 ++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) 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 827b5620..58f745e7 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 @@ -19,8 +19,10 @@ import androidx.activity.result.contract.ActivityResultContract import androidx.core.net.toUri import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.BuildConfig +import com.keylesspalace.tusky.R import com.keylesspalace.tusky.databinding.LoginWebviewBinding import com.keylesspalace.tusky.di.Injectable +import com.keylesspalace.tusky.util.hide import com.keylesspalace.tusky.util.viewBinding import kotlinx.parcelize.Parcelize @@ -87,7 +89,9 @@ class LoginWebViewActivity : BaseActivity(), Injectable { setSupportActionBar(binding.loginToolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) - supportActionBar?.setDisplayShowTitleEnabled(false) + supportActionBar?.setDisplayShowTitleEnabled(true) + + setTitle(R.string.title_login) val webView = binding.loginWebView webView.settings.allowContentAccess = false @@ -103,13 +107,17 @@ class LoginWebViewActivity : BaseActivity(), Injectable { val oauthUrl = data.oauthRedirectUrl webView.webViewClient = object : WebViewClient() { + override fun onPageFinished(view: WebView?, url: String?) { + binding.loginProgress.hide() + } + override fun onReceivedError( view: WebView, request: WebResourceRequest, error: WebResourceError ) { Log.d("LoginWeb", "Failed to load ${data.url}: $error") - finish() + finishWithoutSlideOutAnimation() } override fun shouldOverrideUrlLoading( @@ -165,10 +173,14 @@ class LoginWebViewActivity : BaseActivity(), Injectable { super.onDestroy() } + override fun finish() { + super.finishWithoutSlideOutAnimation() + } + override fun requiresLogin() = false private fun sendResult(result: LoginResult) { setResult(Activity.RESULT_OK, OauthLogin.makeResultIntent(result)) - finish() + finishWithoutSlideOutAnimation() } } diff --git a/app/src/main/res/layout/login_webview.xml b/app/src/main/res/layout/login_webview.xml index 22d7f3bd..67d47d6f 100644 --- a/app/src/main/res/layout/login_webview.xml +++ b/app/src/main/res/layout/login_webview.xml @@ -16,6 +16,12 @@ + + The upload failed. Error sending post. + Login Home Notifications Local