improve LoginWebViewActivityUX (#2465)

This commit is contained in:
Konrad Pozniak 2022-04-28 20:38:51 +02:00 committed by GitHub
parent 28ac190212
commit e5b58770ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View file

@ -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()
}
}

View file

@ -16,6 +16,12 @@
</com.google.android.material.appbar.AppBarLayout>
<ProgressBar
android:id="@+id/loginProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<WebView
android:id="@+id/loginWebView"
android:layout_width="match_parent"

View file

@ -21,6 +21,7 @@
<string name="error_media_upload_sending">The upload failed.</string>
<string name="error_sender_account_gone">Error sending post.</string>
<string name="title_login">Login</string>
<string name="title_home">Home</string>
<string name="title_notifications">Notifications</string>
<string name="title_public_local">Local</string>