new feature: resume last activity after unlocking instead of goind to dashboard everytime
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 5s

This commit is contained in:
2026-05-18 05:09:42 +05:00
parent 8e47101401
commit d59a6fad82
2 changed files with 27 additions and 10 deletions

View File

@@ -39,6 +39,7 @@ class LockActivity : AppCompatActivity() {
companion object {
private const val MAX_ATTEMPTS = 5
private const val LOCKOUT_MS = 30_000L
const val EXTRA_RESUME = "resume"
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -270,8 +271,12 @@ class LockActivity : AppCompatActivity() {
}
private fun proceed() {
startActivity(Intent(this, HomeActivity::class.java))
finish()
if (intent.getBooleanExtra(EXTRA_RESUME, false)) {
finish()
} else {
startActivity(Intent(this, HomeActivity::class.java))
finish()
}
}
// ── Brute-force tracking ──────────────────────────────────────────────────

View File

@@ -64,15 +64,22 @@ class HomeActivity : AppCompatActivity() {
private val warningRunnable = Runnable { showAutolockWarning() }
private var isLocked = false
private val autolockRunnable = Runnable {
countdownTimer?.cancel(); countdownTimer = null
warningDialog?.dismiss(); warningDialog = null
val securitySet = getSharedPreferences("prefs", MODE_PRIVATE)
.getString("security_method", null) != null
if (securitySet) {
startActivity(Intent(this, sh.sar.basedbank.LockActivity::class.java))
finish()
}
if (securitySet) lock()
}
private fun lock() {
isLocked = true
startActivity(
Intent(this, sh.sar.basedbank.LockActivity::class.java)
.putExtra(sh.sar.basedbank.LockActivity.EXTRA_RESUME, true)
)
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -237,6 +244,13 @@ class HomeActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
// Returning from LockActivity — skip the elapsed check and reset state.
if (isLocked) {
isLocked = false
pauseTime = 0L
resetAutolockTimer()
return
}
// If we were away long enough to have hit the autolock timeout (e.g. while
// QrScannerActivity was in the foreground), lock immediately.
if (pauseTime > 0L) {
@@ -244,8 +258,7 @@ class HomeActivity : AppCompatActivity() {
val timeout = getSharedPreferences("prefs", MODE_PRIVATE).getLong("autolock_timeout", 60_000L)
val securitySet = getSharedPreferences("prefs", MODE_PRIVATE).getString("security_method", null) != null
if (timeout > 0L && elapsed >= timeout && securitySet) {
startActivity(Intent(this, sh.sar.basedbank.LockActivity::class.java))
finish()
lock()
return
}
}
@@ -316,8 +329,7 @@ class HomeActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_lock) {
startActivity(Intent(this, sh.sar.basedbank.LockActivity::class.java))
finish()
lock()
return true
}
return super.onOptionsItemSelected(item)