refactor(#78): extract notification strings to resources
This commit is contained in:
1 parent
7ca3399a01
commit
acd6cbf751
2 files changed
+23
-11
No files matched your search
@@ -70,7 +70,7 @@ class ChatNotificationService : Service() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
createNotificationChannels()
|
createNotificationChannels()
|
||||||
startForeground(NOTIFICATION_ID, buildForegroundNotification("Waiting for Hermes replies"))
|
startForeground(NOTIFICATION_ID, buildForegroundNotification(getString(R.string.notif_waiting_replies)))
|
||||||
startEventCollection()
|
startEventCollection()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +85,12 @@ class ChatNotificationService : Service() {
|
|||||||
event.text
|
event.text
|
||||||
.take(100)
|
.take(100)
|
||||||
.replace("\n", " ")
|
.replace("\n", " ")
|
||||||
.ifBlank { "New message" }
|
.ifBlank { getString(R.string.notif_new_message) }
|
||||||
showReplyNotification(preview, event.sessionId)
|
showReplyNotification(preview, event.sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
is WsEvent.ClarifyRequest -> {
|
is WsEvent.ClarifyRequest -> {
|
||||||
showReplyNotification("Hermes needs a clarification", null)
|
showReplyNotification(getString(R.string.notif_clarification_needed), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
@@ -108,7 +108,7 @@ class ChatNotificationService : Service() {
|
|||||||
NotificationCompat
|
NotificationCompat
|
||||||
.Builder(this, CHAT_CHANNEL_ID)
|
.Builder(this, CHAT_CHANNEL_ID)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setContentTitle("Hermes")
|
.setContentTitle(getString(R.string.notif_title))
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
|
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
@@ -116,7 +116,7 @@ class ChatNotificationService : Service() {
|
|||||||
.setContentIntent(buildContentIntent(sessionId))
|
.setContentIntent(buildContentIntent(sessionId))
|
||||||
|
|
||||||
if (!sessionId.isNullOrBlank()) {
|
if (!sessionId.isNullOrBlank()) {
|
||||||
val replyLabel = "Type your reply..."
|
val replyLabel = getString(R.string.notif_reply_placeholder)
|
||||||
val remoteInput =
|
val remoteInput =
|
||||||
RemoteInput
|
RemoteInput
|
||||||
.Builder(NotificationReplyReceiver.KEY_TEXT_REPLY)
|
.Builder(NotificationReplyReceiver.KEY_TEXT_REPLY)
|
||||||
@@ -140,7 +140,7 @@ class ChatNotificationService : Service() {
|
|||||||
NotificationCompat.Action
|
NotificationCompat.Action
|
||||||
.Builder(
|
.Builder(
|
||||||
R.drawable.ic_notification,
|
R.drawable.ic_notification,
|
||||||
"Reply",
|
getString(R.string.action_reply),
|
||||||
replyPendingIntent,
|
replyPendingIntent,
|
||||||
).addRemoteInput(remoteInput)
|
).addRemoteInput(remoteInput)
|
||||||
.build()
|
.build()
|
||||||
@@ -169,7 +169,7 @@ class ChatNotificationService : Service() {
|
|||||||
NotificationCompat
|
NotificationCompat
|
||||||
.Builder(this, SERVICE_CHANNEL_ID)
|
.Builder(this, SERVICE_CHANNEL_ID)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setContentTitle("Hermes")
|
.setContentTitle(getString(R.string.notif_title))
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
@@ -180,19 +180,19 @@ class ChatNotificationService : Service() {
|
|||||||
val serviceChannel =
|
val serviceChannel =
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
SERVICE_CHANNEL_ID,
|
SERVICE_CHANNEL_ID,
|
||||||
"Hermes Background Service",
|
getString(R.string.notif_channel_service_name),
|
||||||
NotificationManager.IMPORTANCE_MIN,
|
NotificationManager.IMPORTANCE_MIN,
|
||||||
).apply {
|
).apply {
|
||||||
description = "Keeps connection alive in the background"
|
description = getString(R.string.notif_channel_service_desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
val chatChannel =
|
val chatChannel =
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
CHAT_CHANNEL_ID,
|
CHAT_CHANNEL_ID,
|
||||||
"Hermes Chat Replies",
|
getString(R.string.notif_channel_chat_name),
|
||||||
NotificationManager.IMPORTANCE_HIGH,
|
NotificationManager.IMPORTANCE_HIGH,
|
||||||
).apply {
|
).apply {
|
||||||
description = "Alerts for new replies from Hermes"
|
description = getString(R.string.notif_channel_chat_desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|||||||
@@ -58,4 +58,16 @@
|
|||||||
<string name="screen_kanban">Kanban</string>
|
<string name="screen_kanban">Kanban</string>
|
||||||
<string name="screen_achievements">Achievements</string>
|
<string name="screen_achievements">Achievements</string>
|
||||||
<string name="screen_history">History</string>
|
<string name="screen_history">History</string>
|
||||||
|
|
||||||
|
<!-- Notifications -->
|
||||||
|
<string name="notif_title">Hermes</string>
|
||||||
|
<string name="notif_waiting_replies">Waiting for Hermes replies</string>
|
||||||
|
<string name="notif_new_message">New message</string>
|
||||||
|
<string name="notif_clarification_needed">Hermes needs a clarification</string>
|
||||||
|
<string name="notif_reply_placeholder">Type your reply\u2026</string>
|
||||||
|
<string name="notif_channel_service_name">Hermes Background Service</string>
|
||||||
|
<string name="notif_channel_service_desc">Keeps connection alive in the background</string>
|
||||||
|
<string name="notif_channel_chat_name">Hermes Chat Replies</string>
|
||||||
|
<string name="notif_channel_chat_desc">Alerts for new replies from Hermes</string>
|
||||||
|
<string name="action_reply">Reply</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user