commit 1e290149ec3fe7721d5ed4d839156a7a0d796898 parent 2c435a3760502adead950b342ed654f672f8df85 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:27:06 +0100 feat(core/message_logger): deleted message color Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com> Diffstat:
5 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/util/AlertDialogs.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/util/AlertDialogs.kt @@ -473,9 +473,12 @@ class AlertDialogs( ColorPickerDialog( initialColor = currentColor, - setProperty = { + setProperty = setProperty@{ currentColor = it property.value.setAny(it?.toArgb()) + if (it == null) { + property.value.setAny(property.value.defaultValues?.firstOrNull() ?: return@setProperty) + } }, dismiss = dismiss ) diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -713,6 +713,10 @@ "message_filter": { "name": "Message Filter", "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" } } }, diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/ConfigContainer.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/ConfigContainer.kt @@ -72,7 +72,7 @@ open class ConfigContainer( key: String, defaultValue: Int? = null, 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 { val json = JsonObject() diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt @@ -9,6 +9,10 @@ import me.rhunk.snapenhance.common.util.PURGE_TRANSLATION_KEY import me.rhunk.snapenhance.common.util.PURGE_VALUES class MessagingTweaks : ConfigContainer() { + companion object { + const val DELETED_MESSAGE_COLOR = 0x6Eb71c1c; + } + inner class HalfSwipeNotifierConfig : ConfigContainer(hasGlobalState = true) { val minDuration: PropertyValue<Int> = integer("min_duration", defaultValue = 0) { inputCheck = { it.toIntOrNull()?.coerceAtLeast(0) != null && maxDuration.get() >= it.toInt() } @@ -24,7 +28,6 @@ class MessagingTweaks : ConfigContainer() { customOptionTranslationPath = PURGE_TRANSLATION_KEY disabledKey = PURGE_DISABLED_KEY }.apply { set("3_days") } - val messageFilter = multiple("message_filter", "CHAT", "SNAP", "NOTE", @@ -33,6 +36,7 @@ class MessagingTweaks : ConfigContainer() { ) { customOptionTranslationPath = "content_type" } + val deletedMessageColor = color("deleted_message_color", DELETED_MESSAGE_COLOR) } class BetterNotifications: ConfigContainer() { @@ -89,7 +93,7 @@ class MessagingTweaks : ConfigContainer() { val notificationBlacklist = multiple("notification_blacklist", *NotificationType.getIncomingValues().map { it.key }.toTypedArray()) { 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 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() } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/spying/MessageLogger.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/spying/MessageLogger.kt @@ -9,6 +9,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonParser import me.rhunk.snapenhance.bridge.logger.BridgeLoggedMessage 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.MessageState import me.rhunk.snapenhance.common.data.QuotedMessageContentStatus @@ -28,7 +29,6 @@ class MessageLogger : Feature("MessageLogger") { companion object { const val PREFETCH_MESSAGE_COUNT = 20 const val PREFETCH_FEED_COUNT = 20 - const val DELETED_MESSAGE_COLOR = 0x6Eb71c1c } private val loggerInterface by lazyBridge { context.bridgeClient.getMessageLogger() } @@ -186,7 +186,7 @@ class MessageLogger : Feature("MessageLogger") { event.view.addForegroundDrawable("deletedMessage", ShapeDrawable(object: Shape() { override fun draw(canvas: Canvas, paint: Paint) { 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 }) } }))