From acd6cbf7510293fe49c35ed344390e9cb352f9ce Mon Sep 17 00:00:00 2001 From: Hy4ri Date: Sun, 21 Jun 2026 11:31:09 +0300 Subject: [PATCH] refactor(#78): extract notification strings to resources --- .../notification/ChatNotificationService.kt | 22 +++++++++---------- app/src/main/res/values/strings.xml | 12 ++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt b/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt index c4a0d8f8..24fa848f 100644 --- a/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt +++ b/app/src/main/java/com/m57/hermescontrol/notification/ChatNotificationService.kt @@ -70,7 +70,7 @@ class ChatNotificationService : Service() { override fun onCreate() { super.onCreate() createNotificationChannels() - startForeground(NOTIFICATION_ID, buildForegroundNotification("Waiting for Hermes replies")) + startForeground(NOTIFICATION_ID, buildForegroundNotification(getString(R.string.notif_waiting_replies))) startEventCollection() } @@ -85,12 +85,12 @@ class ChatNotificationService : Service() { event.text .take(100) .replace("\n", " ") - .ifBlank { "New message" } + .ifBlank { getString(R.string.notif_new_message) } showReplyNotification(preview, event.sessionId) } is WsEvent.ClarifyRequest -> { - showReplyNotification("Hermes needs a clarification", null) + showReplyNotification(getString(R.string.notif_clarification_needed), null) } else -> {} @@ -108,7 +108,7 @@ class ChatNotificationService : Service() { NotificationCompat .Builder(this, CHAT_CHANNEL_ID) .setSmallIcon(R.drawable.ic_notification) - .setContentTitle("Hermes") + .setContentTitle(getString(R.string.notif_title)) .setContentText(text) .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPriority(NotificationCompat.PRIORITY_HIGH) @@ -116,7 +116,7 @@ class ChatNotificationService : Service() { .setContentIntent(buildContentIntent(sessionId)) if (!sessionId.isNullOrBlank()) { - val replyLabel = "Type your reply..." + val replyLabel = getString(R.string.notif_reply_placeholder) val remoteInput = RemoteInput .Builder(NotificationReplyReceiver.KEY_TEXT_REPLY) @@ -140,7 +140,7 @@ class ChatNotificationService : Service() { NotificationCompat.Action .Builder( R.drawable.ic_notification, - "Reply", + getString(R.string.action_reply), replyPendingIntent, ).addRemoteInput(remoteInput) .build() @@ -169,7 +169,7 @@ class ChatNotificationService : Service() { NotificationCompat .Builder(this, SERVICE_CHANNEL_ID) .setSmallIcon(R.drawable.ic_notification) - .setContentTitle("Hermes") + .setContentTitle(getString(R.string.notif_title)) .setContentText(text) .setPriority(NotificationCompat.PRIORITY_MIN) .setOngoing(true) @@ -180,19 +180,19 @@ class ChatNotificationService : Service() { val serviceChannel = NotificationChannel( SERVICE_CHANNEL_ID, - "Hermes Background Service", + getString(R.string.notif_channel_service_name), NotificationManager.IMPORTANCE_MIN, ).apply { - description = "Keeps connection alive in the background" + description = getString(R.string.notif_channel_service_desc) } val chatChannel = NotificationChannel( CHAT_CHANNEL_ID, - "Hermes Chat Replies", + getString(R.string.notif_channel_chat_name), NotificationManager.IMPORTANCE_HIGH, ).apply { - description = "Alerts for new replies from Hermes" + description = getString(R.string.notif_channel_chat_desc) } val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5ecd8f52..3f375975 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,4 +58,16 @@ Kanban Achievements History + + + Hermes + Waiting for Hermes replies + New message + Hermes needs a clarification + Type your reply\u2026 + Hermes Background Service + Keeps connection alive in the background + Hermes Chat Replies + Alerts for new replies from Hermes + Reply \ No newline at end of file