LaunchActivity: Optionally delay finish call to allow transition… (#583)

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
Harsh Shandilya 2019-11-29 14:47:23 +05:30 committed by GitHub
parent 241986e4fa
commit fdbbb467b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ package com.zeapo.pwdstore
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.zeapo.pwdstore.crypto.PgpActivity import com.zeapo.pwdstore.crypto.PgpActivity
@ -21,7 +22,7 @@ class LaunchActivity : AppCompatActivity() {
Authenticator(this) { Authenticator(this) {
when (it) { when (it) {
is AuthenticationResult.Success -> { is AuthenticationResult.Success -> {
startTargetActivity() startTargetActivity(false)
} }
is AuthenticationResult.UnrecoverableError -> { is AuthenticationResult.UnrecoverableError -> {
finish() finish()
@ -31,11 +32,11 @@ class LaunchActivity : AppCompatActivity() {
} }
}.authenticate() }.authenticate()
} else { } else {
startTargetActivity() startTargetActivity(true)
} }
} }
private fun startTargetActivity() { private fun startTargetActivity(noAuth: Boolean) {
if (intent?.getStringExtra("OPERATION") == "DECRYPT") { if (intent?.getStringExtra("OPERATION") == "DECRYPT") {
val decryptIntent = Intent(this, PgpActivity::class.java) val decryptIntent = Intent(this, PgpActivity::class.java)
decryptIntent.putExtra("NAME", intent.getStringExtra("NAME")) decryptIntent.putExtra("NAME", intent.getStringExtra("NAME"))
@ -48,6 +49,6 @@ class LaunchActivity : AppCompatActivity() {
startActivity(Intent(this, PasswordStore::class.java)) startActivity(Intent(this, PasswordStore::class.java))
} }
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
finish() Handler().postDelayed({ finish() }, if (noAuth) 0L else 500L)
} }
} }