Релиз 1.4.7: фиксы lockscreen, звонков и стабильности

This commit is contained in:
2026-04-05 13:06:29 +05:00
parent 9e14724ae2
commit 9d04ec07e8
13 changed files with 406 additions and 131 deletions

View File

@@ -21,6 +21,7 @@ class AccountManager(private val context: Context) {
private val IS_LOGGED_IN = booleanPreferencesKey("is_logged_in")
private const val PREFS_NAME = "rosetta_account_prefs"
private const val KEY_LAST_LOGGED = "last_logged_public_key"
private const val KEY_LAST_LOGGED_PRIVATE_HASH = "last_logged_private_hash"
}
// Use SharedPreferences for last logged account - more reliable for immediate reads
@@ -43,13 +44,19 @@ class AccountManager(private val context: Context) {
val publicKey = sharedPrefs.getString(KEY_LAST_LOGGED, null)
return publicKey
}
fun getLastLoggedPrivateKeyHash(): String? {
return sharedPrefs.getString(KEY_LAST_LOGGED_PRIVATE_HASH, null)
}
// Synchronous write to SharedPreferences
fun setLastLoggedPublicKey(publicKey: String) {
val success = sharedPrefs.edit().putString(KEY_LAST_LOGGED, publicKey).commit() // commit() is synchronous
// Verify immediately
val saved = sharedPrefs.getString(KEY_LAST_LOGGED, null)
sharedPrefs.edit().putString(KEY_LAST_LOGGED, publicKey).commit() // commit() is synchronous
}
fun setLastLoggedPrivateKeyHash(privateKeyHash: String) {
if (privateKeyHash.isBlank()) return
sharedPrefs.edit().putString(KEY_LAST_LOGGED_PRIVATE_HASH, privateKeyHash).apply()
}
suspend fun saveAccount(account: EncryptedAccount) {
@@ -98,6 +105,7 @@ class AccountManager(private val context: Context) {
context.accountDataStore.edit { preferences ->
preferences[IS_LOGGED_IN] = false
}
sharedPrefs.edit().remove(KEY_LAST_LOGGED_PRIVATE_HASH).apply()
}
/**
@@ -140,12 +148,21 @@ class AccountManager(private val context: Context) {
// Clear SharedPreferences if this was the last logged account
val lastLogged = sharedPrefs.getString(KEY_LAST_LOGGED, null)
if (lastLogged == publicKey) {
sharedPrefs.edit().remove(KEY_LAST_LOGGED).commit()
sharedPrefs
.edit()
.remove(KEY_LAST_LOGGED)
.remove(KEY_LAST_LOGGED_PRIVATE_HASH)
.commit()
}
}
suspend fun clearAll() {
context.accountDataStore.edit { it.clear() }
sharedPrefs
.edit()
.remove(KEY_LAST_LOGGED)
.remove(KEY_LAST_LOGGED_PRIVATE_HASH)
.apply()
}
private fun serializeAccounts(accounts: List<EncryptedAccount>): String {