feat(core/message_logger): deleted message color

Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
rhunk 2025-01-10 16:27:06 +01:00
parent 2c435a3760
commit 1e290149ec
5 changed files with 17 additions and 6 deletions

View File

@ -473,9 +473,12 @@ class AlertDialogs(
ColorPickerDialog( ColorPickerDialog(
initialColor = currentColor, initialColor = currentColor,
setProperty = { setProperty = setProperty@{
currentColor = it currentColor = it
property.value.setAny(it?.toArgb()) property.value.setAny(it?.toArgb())
if (it == null) {
property.value.setAny(property.value.defaultValues?.firstOrNull() ?: return@setProperty)
}
}, },
dismiss = dismiss dismiss = dismiss
) )

View File

@ -713,6 +713,10 @@
"message_filter": { "message_filter": {
"name": "Message Filter", "name": "Message Filter",
"description": "Select which messages should get logged (empty for all messages)" "description": "Select which messages should get logged (empty for all messages)"
},
"deleted_message_color": {
"name": "Deleted Message Color",
"description": "Sets the color of deleted messages"
} }
} }
}, },

View File

@ -72,7 +72,7 @@ open class ConfigContainer(
key: String, key: String,
defaultValue: Int? = null, defaultValue: Int? = null,
params: ConfigParamsBuilder = {} params: ConfigParamsBuilder = {}
) = registerProperty(key, DataProcessors.INT_COLOR, PropertyValue(defaultValue), params) ) = registerProperty(key, DataProcessors.INT_COLOR, PropertyValue(defaultValue, defaultValues = defaultValue?.let { listOf(it) }), params)
fun toJson(exportSensitiveData: Boolean = true): JsonObject { fun toJson(exportSensitiveData: Boolean = true): JsonObject {
val json = JsonObject() val json = JsonObject()

View File

@ -9,6 +9,10 @@ import me.rhunk.snapenhance.common.util.PURGE_TRANSLATION_KEY
import me.rhunk.snapenhance.common.util.PURGE_VALUES import me.rhunk.snapenhance.common.util.PURGE_VALUES
class MessagingTweaks : ConfigContainer() { class MessagingTweaks : ConfigContainer() {
companion object {
const val DELETED_MESSAGE_COLOR = 0x6Eb71c1c;
}
inner class HalfSwipeNotifierConfig : ConfigContainer(hasGlobalState = true) { inner class HalfSwipeNotifierConfig : ConfigContainer(hasGlobalState = true) {
val minDuration: PropertyValue<Int> = integer("min_duration", defaultValue = 0) { val minDuration: PropertyValue<Int> = integer("min_duration", defaultValue = 0) {
inputCheck = { it.toIntOrNull()?.coerceAtLeast(0) != null && maxDuration.get() >= it.toInt() } inputCheck = { it.toIntOrNull()?.coerceAtLeast(0) != null && maxDuration.get() >= it.toInt() }
@ -24,7 +28,6 @@ class MessagingTweaks : ConfigContainer() {
customOptionTranslationPath = PURGE_TRANSLATION_KEY customOptionTranslationPath = PURGE_TRANSLATION_KEY
disabledKey = PURGE_DISABLED_KEY disabledKey = PURGE_DISABLED_KEY
}.apply { set("3_days") } }.apply { set("3_days") }
val messageFilter = multiple("message_filter", "CHAT", val messageFilter = multiple("message_filter", "CHAT",
"SNAP", "SNAP",
"NOTE", "NOTE",
@ -33,6 +36,7 @@ class MessagingTweaks : ConfigContainer() {
) { ) {
customOptionTranslationPath = "content_type" customOptionTranslationPath = "content_type"
} }
val deletedMessageColor = color("deleted_message_color", DELETED_MESSAGE_COLOR)
} }
class BetterNotifications: ConfigContainer() { class BetterNotifications: ConfigContainer() {
@ -89,7 +93,7 @@ class MessagingTweaks : ConfigContainer() {
val notificationBlacklist = multiple("notification_blacklist", *NotificationType.getIncomingValues().map { it.key }.toTypedArray()) { val notificationBlacklist = multiple("notification_blacklist", *NotificationType.getIncomingValues().map { it.key }.toTypedArray()) {
customOptionTranslationPath = "features.options.notifications" customOptionTranslationPath = "features.options.notifications"
} }
val messageLogger = container("message_logger", MessageLoggerConfig()) { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val messageLogger = container("message_logger", MessageLoggerConfig()) { requireRestart() }
val galleryMediaSendOverride = unique("gallery_media_send_override", "always_ask", "SNAP", "NOTE", "SAVEABLE_SNAP") { requireRestart(); nativeHooks() } val galleryMediaSendOverride = unique("gallery_media_send_override", "always_ask", "SNAP", "NOTE", "SAVEABLE_SNAP") { requireRestart(); nativeHooks() }
val stripMediaMetadata = multiple("strip_media_metadata", "hide_caption_text", "hide_snap_filters", "hide_extras", "remove_audio_note_duration", "remove_audio_note_transcript_capability") { requireRestart() } val stripMediaMetadata = multiple("strip_media_metadata", "hide_caption_text", "hide_snap_filters", "hide_extras", "remove_audio_note_duration", "remove_audio_note_transcript_capability") { requireRestart() }
val bypassMessageRetentionPolicy = boolean("bypass_message_retention_policy") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val bypassMessageRetentionPolicy = boolean("bypass_message_retention_policy") { addNotices(FeatureNotice.UNSTABLE); requireRestart() }

View File

@ -9,6 +9,7 @@ import com.google.gson.JsonObject
import com.google.gson.JsonParser import com.google.gson.JsonParser
import me.rhunk.snapenhance.bridge.logger.BridgeLoggedMessage import me.rhunk.snapenhance.bridge.logger.BridgeLoggedMessage
import me.rhunk.snapenhance.bridge.logger.LoggedChatEdit import me.rhunk.snapenhance.bridge.logger.LoggedChatEdit
import me.rhunk.snapenhance.common.config.impl.MessagingTweaks
import me.rhunk.snapenhance.common.data.ContentType import me.rhunk.snapenhance.common.data.ContentType
import me.rhunk.snapenhance.common.data.MessageState import me.rhunk.snapenhance.common.data.MessageState
import me.rhunk.snapenhance.common.data.QuotedMessageContentStatus import me.rhunk.snapenhance.common.data.QuotedMessageContentStatus
@ -28,7 +29,6 @@ class MessageLogger : Feature("MessageLogger") {
companion object { companion object {
const val PREFETCH_MESSAGE_COUNT = 20 const val PREFETCH_MESSAGE_COUNT = 20
const val PREFETCH_FEED_COUNT = 20 const val PREFETCH_FEED_COUNT = 20
const val DELETED_MESSAGE_COLOR = 0x6Eb71c1c
} }
private val loggerInterface by lazyBridge { context.bridgeClient.getMessageLogger() } private val loggerInterface by lazyBridge { context.bridgeClient.getMessageLogger() }
@ -186,7 +186,7 @@ class MessageLogger : Feature("MessageLogger") {
event.view.addForegroundDrawable("deletedMessage", ShapeDrawable(object: Shape() { event.view.addForegroundDrawable("deletedMessage", ShapeDrawable(object: Shape() {
override fun draw(canvas: Canvas, paint: Paint) { override fun draw(canvas: Canvas, paint: Paint) {
canvas.drawRect(0f, 0f, canvas.width.toFloat(), canvas.height.toFloat(), Paint().apply { canvas.drawRect(0f, 0f, canvas.width.toFloat(), canvas.height.toFloat(), Paint().apply {
color = DELETED_MESSAGE_COLOR color = context.config.messaging.messageLogger.deletedMessageColor.getNullable() ?: MessagingTweaks.DELETED_MESSAGE_COLOR
}) })
} }
})) }))