forked from thijooree/android
50 lines
2.0 KiB
Kotlin
50 lines
2.0 KiB
Kotlin
package sh.sar.basedbank
|
|
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import sh.sar.basedbank.ui.home.HomeActivity
|
|
import sh.sar.basedbank.ui.login.LoginActivity
|
|
import sh.sar.basedbank.ui.onboarding.OnboardingActivity
|
|
import sh.sar.basedbank.util.CredentialStore
|
|
import sh.sar.basedbank.BasedBankApp
|
|
import sh.sar.basedbank.R
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
|
|
val prefs = getSharedPreferences("prefs", MODE_PRIVATE)
|
|
val onboardingDone = prefs.getBoolean("onboarding_done", false)
|
|
val securitySet = prefs.getString("security_method", null) != null
|
|
val store = CredentialStore(this)
|
|
val hasCredentials = store.hasMibCredentials() || store.hasBmlCredentials() || store.hasFahipayCredentials()
|
|
|
|
val navDestination = when (intent?.action) {
|
|
"sh.sar.basedbank.OPEN_TRANSFER" -> R.id.nav_transfer
|
|
"sh.sar.basedbank.OPEN_SCAN_QR" -> R.id.nav_transfer
|
|
"sh.sar.basedbank.OPEN_PAY_WITH_CARD" -> R.id.nav_pay_with_card
|
|
else -> -1
|
|
}
|
|
val autoScan = intent?.action == "sh.sar.basedbank.OPEN_SCAN_QR"
|
|
|
|
val target = when {
|
|
!onboardingDone -> OnboardingActivity::class.java
|
|
!hasCredentials -> LoginActivity::class.java
|
|
securitySet -> LockActivity::class.java // proceed() → HomeActivity
|
|
else -> HomeActivity::class.java
|
|
}
|
|
// No lock screen configured — mark as unlocked so HomeActivity's guard passes
|
|
if (target == HomeActivity::class.java) {
|
|
(application as BasedBankApp).isUnlocked = true
|
|
}
|
|
|
|
startActivity(Intent(this, target).apply {
|
|
if (navDestination != -1) putExtra("nav_destination", navDestination)
|
|
if (autoScan) putExtra("auto_scan", true)
|
|
})
|
|
finish()
|
|
}
|
|
}
|