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