diff options
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt new file mode 100644 index 00000000..8f607ee0 --- /dev/null +++ b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt @@ -0,0 +1,49 @@ +package com.zeapo.pwdstore + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.preference.PreferenceManager +import com.zeapo.pwdstore.crypto.PgpActivity +import com.zeapo.pwdstore.utils.auth.AuthenticationResult +import com.zeapo.pwdstore.utils.auth.Authenticator + +class LaunchActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val prefs = PreferenceManager.getDefaultSharedPreferences(this) + if (prefs.getBoolean("biometric_auth", false)) { + Authenticator(this) { + when (it) { + is AuthenticationResult.Success -> { + startTargetActivity() + } + is AuthenticationResult.UnrecoverableError -> { + finish() + } + else -> { + } + } + }.authenticate() + } else { + startTargetActivity() + } + } + + private fun startTargetActivity() { + if (intent?.getStringExtra("OPERATION") == "DECRYPT") { + val decryptIntent = Intent(this, PgpActivity::class.java) + decryptIntent.putExtra("NAME", intent.getStringExtra("NAME")) + decryptIntent.putExtra("FILE_PATH", intent.getStringExtra("FILE_PATH")) + decryptIntent.putExtra("REPO_PATH", intent.getStringExtra("REPO_PATH")) + decryptIntent.putExtra("LAST_CHANGED_TIMESTAMP", intent.getLongExtra("LAST_CHANGED_TIMESTAMP", 0L)) + decryptIntent.putExtra("OPERATION", "DECRYPT") + startActivity(decryptIntent) + }else { + startActivity(Intent(this, PasswordStore::class.java)) + } + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) + finish() + } +} |
