feat: notifications localisation
This commit is contained in:
@@ -14,7 +14,6 @@ import com.bitcointxoko.gudariwallet.R
|
|||||||
object NotificationHelper {
|
object NotificationHelper {
|
||||||
|
|
||||||
// ── Intent extra key — read by MainActivity ───────────────────────────────
|
// ── Intent extra key — read by MainActivity ───────────────────────────────
|
||||||
// Public so MainActivity can reference it without a magic string.
|
|
||||||
const val EXTRA_PAYMENT_HASH = "extra_payment_hash"
|
const val EXTRA_PAYMENT_HASH = "extra_payment_hash"
|
||||||
|
|
||||||
// ── Channel setup ─────────────────────────────────────────────────────────
|
// ── Channel setup ─────────────────────────────────────────────────────────
|
||||||
@@ -25,10 +24,10 @@ object NotificationHelper {
|
|||||||
nm.createNotificationChannel(
|
nm.createNotificationChannel(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
NotificationConstants.CHANNEL_PAYMENTS,
|
NotificationConstants.CHANNEL_PAYMENTS,
|
||||||
"Payments",
|
context.getString(R.string.notif_channel_payments_name),
|
||||||
NotificationManager.IMPORTANCE_HIGH
|
NotificationManager.IMPORTANCE_HIGH
|
||||||
).apply {
|
).apply {
|
||||||
description = "Incoming and outgoing Lightning payment alerts"
|
description = context.getString(R.string.notif_channel_payments_desc)
|
||||||
enableVibration(true)
|
enableVibration(true)
|
||||||
enableLights(true)
|
enableLights(true)
|
||||||
}
|
}
|
||||||
@@ -37,10 +36,10 @@ object NotificationHelper {
|
|||||||
nm.createNotificationChannel(
|
nm.createNotificationChannel(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
NotificationConstants.CHANNEL_SERVICE_STATUS,
|
NotificationConstants.CHANNEL_SERVICE_STATUS,
|
||||||
"Wallet Monitor",
|
context.getString(R.string.notif_channel_service_name),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW
|
||||||
).apply {
|
).apply {
|
||||||
description = "Background service monitoring for incoming payments"
|
description = context.getString(R.string.notif_channel_service_desc)
|
||||||
setShowBadge(false)
|
setShowBadge(false)
|
||||||
enableVibration(false)
|
enableVibration(false)
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
@@ -56,8 +55,9 @@ object NotificationHelper {
|
|||||||
* screen for [paymentHash].
|
* screen for [paymentHash].
|
||||||
*/
|
*/
|
||||||
fun notifyPaymentReceived(context: Context, amountSats: Long, memo: String?, paymentHash: String) {
|
fun notifyPaymentReceived(context: Context, amountSats: Long, memo: String?, paymentHash: String) {
|
||||||
val title = "Payment received · +$amountSats sats"
|
val title = context.getString(R.string.notif_payment_received_title, amountSats)
|
||||||
val text = if (!memo.isNullOrBlank()) memo else "No memo"
|
val text = if (!memo.isNullOrBlank()) memo
|
||||||
|
else context.getString(R.string.notif_payment_received_no_memo)
|
||||||
|
|
||||||
val notification = NotificationCompat.Builder(context, NotificationConstants.CHANNEL_PAYMENTS)
|
val notification = NotificationCompat.Builder(context, NotificationConstants.CHANNEL_PAYMENTS)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
@@ -70,7 +70,7 @@ object NotificationHelper {
|
|||||||
.setStyle(
|
.setStyle(
|
||||||
NotificationCompat.BigTextStyle()
|
NotificationCompat.BigTextStyle()
|
||||||
.bigText(text)
|
.bigText(text)
|
||||||
.setSummaryText("+$amountSats sats")
|
.setSummaryText(context.getString(R.string.notif_payment_received_summary, amountSats))
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ object NotificationHelper {
|
|||||||
* screen for [paymentHash].
|
* screen for [paymentHash].
|
||||||
*/
|
*/
|
||||||
fun notifyPaymentSent(context: Context, amountSats: Long, paymentHash: String) {
|
fun notifyPaymentSent(context: Context, amountSats: Long, paymentHash: String) {
|
||||||
val title = "Payment sent"
|
val title = context.getString(R.string.notif_payment_sent_title)
|
||||||
val text = "−$amountSats sats"
|
val text = context.getString(R.string.notif_payment_sent_text, amountSats)
|
||||||
notify(
|
notify(
|
||||||
context,
|
context,
|
||||||
NotificationConstants.NOTIF_ID_PAYMENT_SENT,
|
NotificationConstants.NOTIF_ID_PAYMENT_SENT,
|
||||||
@@ -97,8 +97,8 @@ object NotificationHelper {
|
|||||||
fun buildServiceNotification(context: Context): Notification {
|
fun buildServiceNotification(context: Context): Notification {
|
||||||
return NotificationCompat.Builder(context, NotificationConstants.CHANNEL_SERVICE_STATUS)
|
return NotificationCompat.Builder(context, NotificationConstants.CHANNEL_SERVICE_STATUS)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setContentTitle("Gudari Wallet")
|
.setContentTitle(context.getString(R.string.notif_service_title))
|
||||||
.setContentText("Monitoring for incoming payments")
|
.setContentText(context.getString(R.string.notif_service_text))
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setSilent(true)
|
.setSilent(true)
|
||||||
.setShowWhen(false)
|
.setShowWhen(false)
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,4 +1,20 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Gudari Wallet</string>
|
<string name="app_name">Gudari Wallet</string>
|
||||||
<string name="nfc_hce_description">Gudari Wallet NFC payment sharing</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>
|
</resources>
|
||||||
Reference in New Issue
Block a user