Refactor image blurring to use RenderScript for improved performance and quality

- Replaced custom fast blur implementation with RenderScript-based Gaussian blur in BlurredAvatarBackground and AppearanceScreen.
- Updated image processing logic to scale down bitmaps before applying blur for efficiency.
- Simplified blur logic by removing unnecessary pixel manipulation methods.
- Enhanced media preview handling in OtherProfileScreen to utilize new Gaussian blur function.
- Improved code readability and maintainability by consolidating blur functionality.
This commit is contained in:
2026-02-22 12:32:19 +05:00
parent 5b9b3f83f7
commit ba7182abe6
13 changed files with 1378 additions and 697 deletions

View File

@@ -28,6 +28,7 @@ import com.rosetta.messenger.data.AccountManager
import com.rosetta.messenger.data.DecryptedAccount
import com.rosetta.messenger.data.EncryptedAccount
import com.rosetta.messenger.data.PreferencesManager
import com.rosetta.messenger.crypto.CryptoManager
import com.rosetta.messenger.data.RecentSearchesManager
import com.rosetta.messenger.data.resolveAccountDisplayName
import com.rosetta.messenger.database.RosettaDatabase
@@ -1097,6 +1098,7 @@ fun MainScreen(
val biometricPrefs = remember {
com.rosetta.messenger.biometric.BiometricPreferences(context)
}
val biometricAccountManager = remember { AccountManager(context) }
val activity = context as? FragmentActivity
BiometricEnableScreen(
@@ -1108,24 +1110,40 @@ fun MainScreen(
return@BiometricEnableScreen
}
biometricManager.encryptPassword(
activity = activity,
password = password,
onSuccess = { encryptedPassword ->
mainScreenScope.launch {
biometricPrefs.saveEncryptedPassword(
accountPublicKey,
encryptedPassword
)
biometricPrefs.enableBiometric()
onSuccess()
// Verify password against the real account before saving
mainScreenScope.launch {
val account = biometricAccountManager.getAccount(accountPublicKey)
if (account == null) {
onError("Account not found")
return@launch
}
val decryptedKey = try {
CryptoManager.decryptWithPassword(account.encryptedPrivateKey, password)
} catch (_: Exception) { null }
if (decryptedKey == null) {
onError("Incorrect password")
return@launch
}
biometricManager.encryptPassword(
activity = activity,
password = password,
onSuccess = { encryptedPassword ->
mainScreenScope.launch {
biometricPrefs.saveEncryptedPassword(
accountPublicKey,
encryptedPassword
)
biometricPrefs.enableBiometric()
onSuccess()
}
},
onError = { error -> onError(error) },
onCancel = {
navStack = navStack.filterNot { it is Screen.Biometric }
}
},
onError = { error -> onError(error) },
onCancel = {
navStack = navStack.filterNot { it is Screen.Biometric }
}
)
)
}
}
)
}