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

@@ -230,16 +230,16 @@ class MessageRepository private constructor(private val context: Context) {
_newMessageEvents.tryEmit(dialogKey)
}
/** Send a system message from "Rosetta Updates" account */
suspend fun addUpdateSystemMessage(messageText: String) {
val account = currentAccount ?: return
val privateKey = currentPrivateKey ?: return
/** Send a system message from "Rosetta Updates" account. Returns messageId or null. */
suspend fun addUpdateSystemMessage(messageText: String): String? {
val account = currentAccount ?: return null
val privateKey = currentPrivateKey ?: return null
val encryptedPlainMessage =
try {
CryptoManager.encryptWithPassword(messageText, privateKey)
} catch (_: Exception) {
return
return null
}
val messageId = UUID.randomUUID().toString().replace("-", "").take(32)
@@ -265,7 +265,7 @@ class MessageRepository private constructor(private val context: Context) {
)
)
if (inserted == -1L) return
if (inserted == -1L) return null
val existing = dialogDao.getDialog(account, SYSTEM_UPDATES_PUBLIC_KEY)
dialogDao.insertDialog(
@@ -286,6 +286,7 @@ class MessageRepository private constructor(private val context: Context) {
dialogDao.updateDialogFromMessages(account, SYSTEM_UPDATES_PUBLIC_KEY)
_newMessageEvents.tryEmit(dialogKey)
return messageId
}
/**
@@ -295,12 +296,23 @@ class MessageRepository private constructor(private val context: Context) {
suspend fun checkAndSendVersionUpdateMessage() {
val account = currentAccount ?: return
val prefs = context.getSharedPreferences("rosetta_system_${account}", Context.MODE_PRIVATE)
val lastNoticeVersion = prefs.getString("lastNoticeVersion", "") ?: ""
val lastNoticeKey = prefs.getString("lastNoticeKey", "") ?: ""
val currentVersion = com.rosetta.messenger.BuildConfig.VERSION_NAME
val currentKey = "${currentVersion}_${ReleaseNotes.noticeHash}"
if (lastNoticeVersion != currentVersion) {
addUpdateSystemMessage(ReleaseNotes.getNotice(currentVersion))
prefs.edit().putString("lastNoticeVersion", currentVersion).apply()
if (lastNoticeKey != currentKey) {
// Delete the previous message for this version (if any)
val prevMessageId = prefs.getString("lastNoticeMessageId_$currentVersion", null)
if (prevMessageId != null) {
messageDao.deleteMessage(account, prevMessageId)
dialogDao.updateDialogFromMessages(account, SYSTEM_UPDATES_PUBLIC_KEY)
}
val messageId = addUpdateSystemMessage(ReleaseNotes.getNotice(currentVersion))
prefs.edit()
.putString("lastNoticeKey", currentKey)
.putString("lastNoticeMessageId_$currentVersion", messageId)
.apply()
}
}

View File

@@ -28,4 +28,8 @@ object ReleaseNotes {
fun getNotice(version: String): String =
RELEASE_NOTICE.replace(VERSION_PLACEHOLDER, version)
/** Hash of current notice text — used to re-send if text changed within the same version */
val noticeHash: String
get() = RELEASE_NOTICE.hashCode().toString(16)
}