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:
@@ -3,6 +3,70 @@ package com.rosetta.messenger.database
|
||||
import androidx.room.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
// 📌 PINNED MESSAGES
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
|
||||
/** Entity для закреплённых сообщений в чате (Telegram-style pinned messages) */
|
||||
@Entity(
|
||||
tableName = "pinned_messages",
|
||||
indices =
|
||||
[
|
||||
Index(
|
||||
value = ["account", "dialog_key", "message_id"],
|
||||
unique = true
|
||||
),
|
||||
Index(value = ["account", "dialog_key", "pinned_at"])]
|
||||
)
|
||||
data class PinnedMessageEntity(
|
||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||
@ColumnInfo(name = "account") val account: String,
|
||||
@ColumnInfo(name = "dialog_key") val dialogKey: String,
|
||||
@ColumnInfo(name = "message_id") val messageId: String,
|
||||
@ColumnInfo(name = "pinned_at") val pinnedAt: Long = System.currentTimeMillis()
|
||||
)
|
||||
|
||||
/** DAO для работы с закреплёнными сообщениями */
|
||||
@Dao
|
||||
interface PinnedMessageDao {
|
||||
|
||||
/** Закрепить сообщение (IGNORE если уже закреплено) */
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insertPin(pin: PinnedMessageEntity): Long
|
||||
|
||||
/** Открепить конкретное сообщение */
|
||||
@Query(
|
||||
"DELETE FROM pinned_messages WHERE account = :account AND dialog_key = :dialogKey AND message_id = :messageId"
|
||||
)
|
||||
suspend fun removePin(account: String, dialogKey: String, messageId: String)
|
||||
|
||||
/** Получить все закреплённые сообщения диалога (Flow для реактивных обновлений) */
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM pinned_messages
|
||||
WHERE account = :account AND dialog_key = :dialogKey
|
||||
ORDER BY pinned_at DESC
|
||||
"""
|
||||
)
|
||||
fun getPinnedMessages(account: String, dialogKey: String): Flow<List<PinnedMessageEntity>>
|
||||
|
||||
/** Проверить, закреплено ли сообщение */
|
||||
@Query(
|
||||
"SELECT EXISTS(SELECT 1 FROM pinned_messages WHERE account = :account AND dialog_key = :dialogKey AND message_id = :messageId)"
|
||||
)
|
||||
suspend fun isPinned(account: String, dialogKey: String, messageId: String): Boolean
|
||||
|
||||
/** Открепить все сообщения диалога */
|
||||
@Query("DELETE FROM pinned_messages WHERE account = :account AND dialog_key = :dialogKey")
|
||||
suspend fun unpinAll(account: String, dialogKey: String): Int
|
||||
|
||||
/** Количество закреплённых сообщений в диалоге */
|
||||
@Query(
|
||||
"SELECT COUNT(*) FROM pinned_messages WHERE account = :account AND dialog_key = :dialogKey"
|
||||
)
|
||||
suspend fun getPinnedCount(account: String, dialogKey: String): Int
|
||||
}
|
||||
|
||||
/** 🔥 Data class для статуса последнего сообщения */
|
||||
data class LastMessageStatus(
|
||||
@ColumnInfo(name = "from_me") val fromMe: Int,
|
||||
|
||||
Reference in New Issue
Block a user