Cleanup up string for push and notification (before integrating to Localazy)
This commit is contained in:
committed by
Benoit Marty
parent
9036237030
commit
68769a21e2
@@ -38,7 +38,6 @@ dependencies {
|
||||
implementation(libs.serialization.json)
|
||||
|
||||
implementation(projects.libraries.architecture)
|
||||
implementation(projects.libraries.uiStrings)
|
||||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.di)
|
||||
implementation(projects.libraries.androidutils)
|
||||
|
||||
@@ -71,7 +71,7 @@ class GoogleFcmHelper @Inject constructor(
|
||||
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed")
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(context, R.string.no_valid_google_play_services_apk, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.push_no_valid_google_play_services_apk_android, Toast.LENGTH_SHORT).show()
|
||||
Timber.e("No valid Google Play Services found. Cannot use FCM.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ class UnifiedPushHelper @Inject constructor(
|
||||
) {
|
||||
val internalDistributorName = stringProvider.getString(
|
||||
if (fcmHelper.isFirebaseAvailable()) {
|
||||
StringR.string.unifiedpush_distributor_fcm_fallback
|
||||
R.string.push_distributor_firebase
|
||||
} else {
|
||||
StringR.string.unifiedpush_distributor_background_sync
|
||||
R.string.push_distributor_background_sync
|
||||
}
|
||||
)
|
||||
|
||||
@@ -60,7 +60,7 @@ class UnifiedPushHelper @Inject constructor(
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setTitle(stringProvider.getString(StringR.string.unifiedpush_getdistributors_dialog_title))
|
||||
.setTitle(stringProvider.getString(R.string.push_choose_distributor_dialog_title))
|
||||
.setItems(distributorsName.toTypedArray()) { _, which ->
|
||||
val distributor = distributors[which]
|
||||
onDistributorSelected(distributor)
|
||||
@@ -133,8 +133,8 @@ class UnifiedPushHelper @Inject constructor(
|
||||
|
||||
fun getCurrentDistributorName(): String {
|
||||
return when {
|
||||
isEmbeddedDistributor() -> stringProvider.getString(R.string.unifiedpush_distributor_fcm_fallback)
|
||||
isBackgroundSync() -> stringProvider.getString(R.string.unifiedpush_distributor_background_sync)
|
||||
isEmbeddedDistributor() -> stringProvider.getString(R.string.push_distributor_firebase)
|
||||
isBackgroundSync() -> stringProvider.getString(R.string.push_distributor_background_sync)
|
||||
else -> context.getApplicationLabel(UnifiedPush.getDistributor(context))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||
noisy = false,
|
||||
timestamp = clock.epochMillis(),
|
||||
senderName = session.roomService().getRoomMember(session.myUserId, room.roomId)?.displayName
|
||||
?: context?.getString(StringR.string.notification_sender_me),
|
||||
?: context?.getString(R.string.notification_sender_me),
|
||||
senderId = session.myUserId,
|
||||
body = message,
|
||||
imageUriString = null,
|
||||
@@ -216,7 +216,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||
false,
|
||||
clock.epochMillis(),
|
||||
session.myUser?.displayname
|
||||
?: context?.getString(StringR.string.notification_sender_me),
|
||||
?: context?.getString(R.string.notification_sender_me),
|
||||
session.myUserId,
|
||||
message,
|
||||
roomId,
|
||||
|
||||
@@ -55,7 +55,6 @@ import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import io.element.android.libraries.ui.strings.R as StringR
|
||||
|
||||
// TODO EAx Split into factories
|
||||
@SingleIn(AppScope::class)
|
||||
@@ -154,11 +153,11 @@ class NotificationUtils @Inject constructor(
|
||||
*/
|
||||
notificationManager.createNotificationChannel(NotificationChannel(
|
||||
NOISY_NOTIFICATION_CHANNEL_ID,
|
||||
stringProvider.getString(R.string.notification_noisy_notifications).ifEmpty { "Noisy notifications" },
|
||||
stringProvider.getString(R.string.notification_channel_noisy).ifEmpty { "Noisy notifications" },
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
.apply {
|
||||
description = stringProvider.getString(R.string.notification_noisy_notifications)
|
||||
description = stringProvider.getString(R.string.notification_channel_noisy)
|
||||
enableVibration(true)
|
||||
enableLights(true)
|
||||
lightColor = accentColor
|
||||
@@ -169,11 +168,11 @@ class NotificationUtils @Inject constructor(
|
||||
*/
|
||||
notificationManager.createNotificationChannel(NotificationChannel(
|
||||
SILENT_NOTIFICATION_CHANNEL_ID,
|
||||
stringProvider.getString(R.string.notification_silent_notifications).ifEmpty { "Silent notifications" },
|
||||
stringProvider.getString(R.string.notification_channel_silent).ifEmpty { "Silent notifications" },
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
)
|
||||
.apply {
|
||||
description = stringProvider.getString(R.string.notification_silent_notifications)
|
||||
description = stringProvider.getString(R.string.notification_channel_silent)
|
||||
setSound(null, null)
|
||||
enableLights(true)
|
||||
lightColor = accentColor
|
||||
@@ -181,22 +180,22 @@ class NotificationUtils @Inject constructor(
|
||||
|
||||
notificationManager.createNotificationChannel(NotificationChannel(
|
||||
LISTENING_FOR_EVENTS_NOTIFICATION_CHANNEL_ID,
|
||||
stringProvider.getString(R.string.notification_listening_for_events).ifEmpty { "Listening for events" },
|
||||
stringProvider.getString(R.string.notification_channel_listening_for_events).ifEmpty { "Listening for events" },
|
||||
NotificationManager.IMPORTANCE_MIN
|
||||
)
|
||||
.apply {
|
||||
description = stringProvider.getString(R.string.notification_listening_for_events)
|
||||
description = stringProvider.getString(R.string.notification_channel_listening_for_events)
|
||||
setSound(null, null)
|
||||
setShowBadge(false)
|
||||
})
|
||||
|
||||
notificationManager.createNotificationChannel(NotificationChannel(
|
||||
CALL_NOTIFICATION_CHANNEL_ID,
|
||||
stringProvider.getString(R.string.call).ifEmpty { "Call" },
|
||||
stringProvider.getString(R.string.notification_channel_call).ifEmpty { "Call" },
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
.apply {
|
||||
description = stringProvider.getString(R.string.call)
|
||||
description = stringProvider.getString(R.string.notification_channel_call)
|
||||
setSound(null, null)
|
||||
enableLights(true)
|
||||
lightColor = accentColor
|
||||
@@ -255,7 +254,7 @@ class NotificationUtils @Inject constructor(
|
||||
// Number of new notifications for API <24 (M and below) devices.
|
||||
.setSubText(
|
||||
stringProvider.getQuantityString(
|
||||
R.plurals.room_new_messages_notification,
|
||||
R.plurals.notification_new_messages_for_room,
|
||||
messageStyle.messages.size,
|
||||
messageStyle.messages.size
|
||||
)
|
||||
@@ -301,7 +300,7 @@ class NotificationUtils @Inject constructor(
|
||||
|
||||
NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_material_done_all_white,
|
||||
stringProvider.getString(R.string.action_mark_room_read), markRoomReadPendingIntent
|
||||
stringProvider.getString(R.string.notification_room_action_mark_as_read), markRoomReadPendingIntent
|
||||
)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
@@ -312,11 +311,11 @@ class NotificationUtils @Inject constructor(
|
||||
if (!roomInfo.hasSmartReplyError) {
|
||||
buildQuickReplyIntent(roomInfo.sessionId, roomInfo.roomId, threadId, senderDisplayNameForReplyCompat)?.let { replyPendingIntent ->
|
||||
val remoteInput = RemoteInput.Builder(NotificationBroadcastReceiver.KEY_TEXT_REPLY)
|
||||
.setLabel(stringProvider.getString(StringR.string.action_quick_reply))
|
||||
.setLabel(stringProvider.getString(R.string.notification_room_action_quick_reply))
|
||||
.build()
|
||||
NotificationCompat.Action.Builder(
|
||||
R.drawable.vector_notification_quick_reply,
|
||||
stringProvider.getString(StringR.string.action_quick_reply), replyPendingIntent
|
||||
stringProvider.getString(R.string.notification_room_action_quick_reply), replyPendingIntent
|
||||
)
|
||||
.addRemoteInput(remoteInput)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
|
||||
@@ -383,7 +382,7 @@ class NotificationUtils @Inject constructor(
|
||||
|
||||
addAction(
|
||||
R.drawable.vector_notification_reject_invitation,
|
||||
stringProvider.getString(R.string.action_reject),
|
||||
stringProvider.getString(R.string.notification_invitation_action_reject),
|
||||
rejectIntentPendingIntent
|
||||
)
|
||||
|
||||
@@ -401,7 +400,7 @@ class NotificationUtils @Inject constructor(
|
||||
)
|
||||
addAction(
|
||||
R.drawable.vector_notification_accept_invitation,
|
||||
stringProvider.getString(R.string.action_join),
|
||||
stringProvider.getString(R.string.notification_invitation_action_join),
|
||||
joinIntentPendingIntent
|
||||
)
|
||||
|
||||
@@ -667,7 +666,7 @@ class NotificationUtils @Inject constructor(
|
||||
888,
|
||||
NotificationCompat.Builder(context, NOISY_NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(buildMeta.applicationName)
|
||||
.setContentText(stringProvider.getString(R.string.settings_troubleshoot_test_push_notification_content))
|
||||
.setContentText(stringProvider.getString(R.string.notification_test_push_notification_content))
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setLargeIcon(getBitmap(context, R.drawable.element_logo_green))
|
||||
.setColor(ContextCompat.getColor(context, R.color.notification_accent_color))
|
||||
|
||||
@@ -105,18 +105,23 @@ class SummaryGroupMessageCreator @Inject constructor(
|
||||
val messageNotificationCount = messageEventsCount + simpleEventsCount
|
||||
|
||||
val privacyTitle = if (invitationEventsCount > 0) {
|
||||
val invitationsStr = stringProvider.getQuantityString(R.plurals.notification_invitations, invitationEventsCount, invitationEventsCount)
|
||||
val invitationsStr = stringProvider.getQuantityString(
|
||||
R.plurals.notification_invitations,
|
||||
invitationEventsCount,
|
||||
invitationEventsCount
|
||||
)
|
||||
if (messageNotificationCount > 0) {
|
||||
// Invitation and message
|
||||
val messageStr = stringProvider.getQuantityString(
|
||||
R.plurals.room_new_messages_notification,
|
||||
R.plurals.notification_new_messages_for_room,
|
||||
messageNotificationCount, messageNotificationCount
|
||||
)
|
||||
if (roomCount > 1) {
|
||||
// In several rooms
|
||||
val roomStr = stringProvider.getQuantityString(
|
||||
R.plurals.notification_unread_notified_messages_in_room_rooms,
|
||||
roomCount, roomCount
|
||||
roomCount,
|
||||
roomCount
|
||||
)
|
||||
stringProvider.getString(
|
||||
R.string.notification_unread_notified_messages_in_room_and_invitation,
|
||||
@@ -139,13 +144,22 @@ class SummaryGroupMessageCreator @Inject constructor(
|
||||
} else {
|
||||
// No invitation, only messages
|
||||
val messageStr = stringProvider.getQuantityString(
|
||||
R.plurals.room_new_messages_notification,
|
||||
messageNotificationCount, messageNotificationCount
|
||||
R.plurals.notification_new_messages_for_room,
|
||||
messageNotificationCount,
|
||||
messageNotificationCount
|
||||
)
|
||||
if (roomCount > 1) {
|
||||
// In several rooms
|
||||
val roomStr = stringProvider.getQuantityString(R.plurals.notification_unread_notified_messages_in_room_rooms, roomCount, roomCount)
|
||||
stringProvider.getString(R.string.notification_unread_notified_messages_in_room, messageStr, roomStr)
|
||||
val roomStr = stringProvider.getQuantityString(
|
||||
R.plurals.notification_unread_notified_messages_in_room_rooms,
|
||||
roomCount,
|
||||
roomCount
|
||||
)
|
||||
stringProvider.getString(
|
||||
R.string.notification_unread_notified_messages_in_room,
|
||||
messageStr,
|
||||
roomStr
|
||||
)
|
||||
} else {
|
||||
// In one room
|
||||
messageStr
|
||||
|
||||
@@ -15,27 +15,29 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="no_valid_google_play_services_apk">No valid Google Play Services APK found. Notifications may not work properly.</string>
|
||||
<string name="unifiedpush_getdistributors_dialog_title">Choose how to receive notifications</string>
|
||||
<string name="unifiedpush_distributor_fcm_fallback">Google Services</string>
|
||||
<string name="unifiedpush_distributor_background_sync">Background synchronization</string>
|
||||
<string name="push_no_valid_google_play_services_apk_android">No valid Google Play Services found. Notifications may not work properly.</string>
|
||||
<string name="push_choose_distributor_dialog_title">Choose how to receive notifications</string>
|
||||
<string name="push_distributor_firebase">Google Services</string>
|
||||
<string name="push_distributor_background_sync">Background synchronization</string>
|
||||
|
||||
<string name="notification_listening_for_events">Listening for events</string>
|
||||
<string name="notification_noisy_notifications">Noisy notifications</string>
|
||||
<string name="notification_silent_notifications">Silent notifications</string>
|
||||
<string name="call">Call</string>
|
||||
<string name="notification_channel_listening_for_events">Listening for events</string>
|
||||
<string name="notification_channel_noisy">Noisy notifications</string>
|
||||
<string name="notification_channel_silent">Silent notifications</string>
|
||||
<string name="notification_channel_call">Call</string>
|
||||
<string name="notification_sender_me">Me</string>
|
||||
<string name="notification_new_messages">New Messages</string>
|
||||
<string name="action_mark_room_read">Mark as read</string>
|
||||
<string name="action_join">Join</string>
|
||||
<string name="action_reject">Reject</string>
|
||||
<string name="settings_troubleshoot_test_push_notification_content">You are viewing the notification! Click me!</string>
|
||||
<string name="notification_room_action_mark_as_read">Mark as read</string>
|
||||
<string name="notification_room_action_quick_reply">Quick reply</string>
|
||||
<string name="notification_invitation_action_join">Join</string>
|
||||
<string name="notification_invitation_action_reject">Reject</string>
|
||||
<string name="notification_test_push_notification_content">You are viewing the notification! Click me!</string>
|
||||
<string name="notification_ticker_text_dm">%1$s: %2$s</string>
|
||||
<string name="notification_ticker_text_group">%1$s: %2$s %3$s</string>
|
||||
<string name="notification_inline_reply_failed">** Failed to send - please open room</string>
|
||||
<string name="notification_unread_notified_messages_in_room_and_invitation">%1$s in %2$s and %3$s"</string>
|
||||
<string name="notification_unread_notified_messages_and_invitation">%1$s and %2$s"</string>
|
||||
<string name="notification_unread_notified_messages_in_room">%1$s in %2$s"</string>
|
||||
<plurals name="room_new_messages_notification">
|
||||
<plurals name="notification_new_messages_for_room">
|
||||
<item quantity="one">%d new message</item>
|
||||
<item quantity="other">%d new messages</item>
|
||||
</plurals>
|
||||
|
||||
Reference in New Issue
Block a user