From ddcb1fa54acd65ba755ac1e6ff8ddeb17c2993cb Mon Sep 17 00:00:00 2001 From: yenda Date: Mon, 15 Jun 2020 17:12:11 +0200 Subject: [PATCH] use resources for notification text for localization Signed-off-by: yenda --- .../im/status/ethereum/module/ForegroundService.java | 10 ++++++---- .../ethereum/module/NewMessageSignalHandler.java | 3 +-- .../android/src/main/res/values/strings.xml | 8 ++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 modules/react-native-status/android/src/main/res/values/strings.xml diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/ForegroundService.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/ForegroundService.java index 3264e9c48d..2ac5848066 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/ForegroundService.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/ForegroundService.java @@ -33,7 +33,7 @@ public class ForegroundService extends Service { NotificationManager notificationManager = context.getSystemService(NotificationManager.class); NotificationChannel channel = new NotificationChannel(CHANNEL_ID, - "Status Service", + context.getResources().getString(R.string.status_service), NotificationManager.IMPORTANCE_HIGH); channel.setShowBadge(false); notificationManager.createNotificationChannel(channel); @@ -57,16 +57,18 @@ public class ForegroundService extends Service { Intent stopIntent = new Intent(NewMessageSignalHandler.ACTION_TAP_STOP); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 0, stopIntent, PendingIntent.FLAG_CANCEL_CURRENT); - String content = "Keep Status running to receive notifications"; + String content = context.getResources().getString(R.string.keep_status_running); Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(R.drawable.ic_stat_notify_status) - .setContentTitle("Background notification service opened") + .setContentTitle(context.getResources().getString(R.string.background_service_opened)) .setContentText(content) .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_MESSAGE) .setContentIntent(pendingIntent) .setNumber(0) - .addAction(R.drawable.ic_stat_notify_status, "STOP", stopPendingIntent) + .addAction(R.drawable.ic_stat_notify_status, + context.getResources().getString(R.string.stop), + stopPendingIntent) .build(); // the id of the foreground notification MUST NOT be 0 startForeground(1, notification); diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NewMessageSignalHandler.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NewMessageSignalHandler.java index 1fec13990b..1b7824d9f9 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NewMessageSignalHandler.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NewMessageSignalHandler.java @@ -49,7 +49,6 @@ public class NewMessageSignalHandler { public static final String ACTION_TAP_STOP = "im.status.ethereum.module.TAP_STOP"; private static final String GROUP_STATUS_MESSAGES = "im.status.notifications.message"; private static final String CHANNEL_NAME = "Status"; - private static final String CHANNEL_DESCRIPTION = "Get notifications on new messages and mentions"; private static final String CHANNEL_ID = "status-chat-notifications"; private static final String TAG = "StatusModule"; private NotificationManager notificationManager; @@ -161,7 +160,7 @@ public class NewMessageSignalHandler { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() + "/" + R.raw.notification_sound); NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); - channel.setDescription(CHANNEL_DESCRIPTION); + channel.setDescription(context.getResources().getString(R.string.channel_description)); AudioAttributes audioAttributes = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .build(); diff --git a/modules/react-native-status/android/src/main/res/values/strings.xml b/modules/react-native-status/android/src/main/res/values/strings.xml new file mode 100644 index 0000000000..09a5d6804c --- /dev/null +++ b/modules/react-native-status/android/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + Status Service + STOP + Keep Status running to receive notifications + Background notification service opened + Get notifications on new messages and mentions + +