improve LoginWebViewActivityUX (#2465)
This commit is contained in:
parent
28ac190212
commit
e5b58770ce
3 changed files with 22 additions and 3 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue