feat: notifications localisation

This commit is contained in:
2026-06-05 23:56:49 +02:00
parent ed3371aa6f
commit 890dd0004a
3 changed files with 50 additions and 15 deletions
@@ -14,7 +14,6 @@ import com.bitcointxoko.gudariwallet.R
object NotificationHelper {
// ── Intent extra key — read by MainActivity ───────────────────────────────
// Public so MainActivity can reference it without a magic string.
const val EXTRA_PAYMENT_HASH = "extra_payment_hash"
// ── Channel setup ─────────────────────────────────────────────────────────
@@ -25,10 +24,10 @@ object NotificationHelper {
nm.createNotificationChannel(
NotificationChannel(
NotificationConstants.CHANNEL_PAYMENTS,
"Payments",
context.getString(R.string.notif_channel_payments_name),
NotificationManager.IMPORTANCE_HIGH
).apply {
description = "Incoming and outgoing Lightning payment alerts"
description = context.getString(R.string.notif_channel_payments_desc)
enableVibration(true)
enableLights(true)
}
@@ -37,10 +36,10 @@ object NotificationHelper {
nm.createNotificationChannel(
NotificationChannel(
NotificationConstants.CHANNEL_SERVICE_STATUS,
"Wallet Monitor",
context.getString(R.string.notif_channel_service_name),
NotificationManager.IMPORTANCE_LOW
).apply {
description = "Background service monitoring for incoming payments"
description = context.getString(R.string.notif_channel_service_desc)
setShowBadge(false)
enableVibration(false)
setSound(null, null)
@@ -56,8 +55,9 @@ object NotificationHelper {
* screen for [paymentHash].
*/
fun notifyPaymentReceived(context: Context, amountSats: Long, memo: String?, paymentHash: String) {
val title = "Payment received · +$amountSats sats"
val text = if (!memo.isNullOrBlank()) memo else "No memo"
val title = context.getString(R.string.notif_payment_received_title, amountSats)
val text = if (!memo.isNullOrBlank()) memo
else context.getString(R.string.notif_payment_received_no_memo)
val notification = NotificationCompat.Builder(context, NotificationConstants.CHANNEL_PAYMENTS)
.setSmallIcon(R.drawable.ic_notification)
@@ -70,7 +70,7 @@ object NotificationHelper {
.setStyle(
NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText("+$amountSats sats")
.setSummaryText(context.getString(R.string.notif_payment_received_summary, amountSats))
)
.build()
@@ -83,8 +83,8 @@ object NotificationHelper {
* screen for [paymentHash].
*/
fun notifyPaymentSent(context: Context, amountSats: Long, paymentHash: String) {
val title = "Payment sent"
val text = "$amountSats sats"
val title = context.getString(R.string.notif_payment_sent_title)
val text = context.getString(R.string.notif_payment_sent_text, amountSats)
notify(
context,
NotificationConstants.NOTIF_ID_PAYMENT_SENT,
@@ -97,8 +97,8 @@ object NotificationHelper {
fun buildServiceNotification(context: Context): Notification {
return NotificationCompat.Builder(context, NotificationConstants.CHANNEL_SERVICE_STATUS)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle("Gudari Wallet")
.setContentText("Monitoring for incoming payments")
.setContentTitle(context.getString(R.string.notif_service_title))
.setContentText(context.getString(R.string.notif_service_text))
.setOngoing(true)
.setSilent(true)
.setShowWhen(false)
+19
View File
@@ -0,0 +1,19 @@
<resources>
<!-- NotificationHelper -->
<string name="notif_channel_payments_name">Pagos</string>
<string name="notif_channel_payments_desc">Alertas de pagos Lightning entrantes y salientes</string>
<string name="notif_channel_service_name">Monitor de cartera</string>
<string name="notif_channel_service_desc">Servicio en segundo plano para pagos entrantes</string>
<string name="notif_payment_received_title">Pago recibido · +%1$d sats</string>
<string name="notif_payment_received_no_memo">Sin nota</string>
<string name="notif_payment_received_summary">+%1$d sats</string>
<string name="notif_payment_sent_title">Pago enviado</string>
<string name="notif_payment_sent_text">%1$d sats</string>
<string name="notif_service_title">Gudari Wallet</string>
<string name="notif_service_text">Monitorizando pagos entrantes</string>
</resources>
+16
View File
@@ -1,4 +1,20 @@
<resources>
<string name="app_name">Gudari Wallet</string>
<string name="nfc_hce_description">Gudari Wallet NFC payment sharing</string>
<!-- NotificationHelper -->
<string name="notif_channel_payments_name">Payments</string>
<string name="notif_channel_payments_desc">Incoming and outgoing Lightning payment alerts</string>
<string name="notif_channel_service_name">Wallet Monitor</string>
<string name="notif_channel_service_desc">Background service monitoring for incoming payments</string>
<string name="notif_payment_received_title">Payment received · +%1$d sats</string>
<string name="notif_payment_received_no_memo">No memo</string>
<string name="notif_payment_received_summary">+%1$d sats</string>
<string name="notif_payment_sent_title">Payment sent</string>
<string name="notif_payment_sent_text">%1$d sats</string>
<string name="notif_service_title">Gudari Wallet</string>
<string name="notif_service_text">Monitoring for incoming payments</string>
</resources>