Temporary import strings.

This commit is contained in:
Benoit Marty 2023-03-28 16:19:22 +02:00 committed by Benoit Marty
parent 581ec6a1af
commit 8a100500f0
6 changed files with 95 additions and 35 deletions

View file

@ -28,7 +28,6 @@ import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.di.DefaultPreferences import io.element.android.libraries.di.DefaultPreferences
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
/** /**
* This class store the FCM token in SharedPrefs and ensure this token is retrieved. * This class store the FCM token in SharedPrefs and ensure this token is retrieved.
@ -69,7 +68,7 @@ class GoogleFcmHelper @Inject constructor(
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed") Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed")
} }
} else { } else {
Toast.makeText(context, StringR.string.no_valid_google_play_services_apk, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.no_valid_google_play_services_apk, 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.")
} }
} }

View file

@ -134,8 +134,8 @@ class UnifiedPushHelper @Inject constructor(
fun getCurrentDistributorName(): String { fun getCurrentDistributorName(): String {
return when { return when {
isEmbeddedDistributor() -> stringProvider.getString(StringR.string.unifiedpush_distributor_fcm_fallback) isEmbeddedDistributor() -> stringProvider.getString(R.string.unifiedpush_distributor_fcm_fallback)
isBackgroundSync() -> stringProvider.getString(StringR.string.unifiedpush_distributor_background_sync) isBackgroundSync() -> stringProvider.getString(R.string.unifiedpush_distributor_background_sync)
else -> context.getApplicationLabel(UnifiedPush.getDistributor(context)) else -> context.getApplicationLabel(UnifiedPush.getDistributor(context))
} }
} }

View file

@ -145,11 +145,11 @@ class NotificationUtils @Inject constructor(
*/ */
notificationManager.createNotificationChannel(NotificationChannel( notificationManager.createNotificationChannel(NotificationChannel(
NOISY_NOTIFICATION_CHANNEL_ID, NOISY_NOTIFICATION_CHANNEL_ID,
stringProvider.getString(StringR.string.notification_noisy_notifications).ifEmpty { "Noisy notifications" }, stringProvider.getString(R.string.notification_noisy_notifications).ifEmpty { "Noisy notifications" },
NotificationManager.IMPORTANCE_DEFAULT NotificationManager.IMPORTANCE_DEFAULT
) )
.apply { .apply {
description = stringProvider.getString(StringR.string.notification_noisy_notifications) description = stringProvider.getString(R.string.notification_noisy_notifications)
enableVibration(true) enableVibration(true)
enableLights(true) enableLights(true)
lightColor = accentColor lightColor = accentColor
@ -160,11 +160,11 @@ class NotificationUtils @Inject constructor(
*/ */
notificationManager.createNotificationChannel(NotificationChannel( notificationManager.createNotificationChannel(NotificationChannel(
SILENT_NOTIFICATION_CHANNEL_ID, SILENT_NOTIFICATION_CHANNEL_ID,
stringProvider.getString(StringR.string.notification_silent_notifications).ifEmpty { "Silent notifications" }, stringProvider.getString(R.string.notification_silent_notifications).ifEmpty { "Silent notifications" },
NotificationManager.IMPORTANCE_LOW NotificationManager.IMPORTANCE_LOW
) )
.apply { .apply {
description = stringProvider.getString(StringR.string.notification_silent_notifications) description = stringProvider.getString(R.string.notification_silent_notifications)
setSound(null, null) setSound(null, null)
enableLights(true) enableLights(true)
lightColor = accentColor lightColor = accentColor
@ -172,22 +172,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(StringR.string.notification_listening_for_events).ifEmpty { "Listening for events" }, stringProvider.getString(R.string.notification_listening_for_events).ifEmpty { "Listening for events" },
NotificationManager.IMPORTANCE_MIN NotificationManager.IMPORTANCE_MIN
) )
.apply { .apply {
description = stringProvider.getString(StringR.string.notification_listening_for_events) description = stringProvider.getString(R.string.notification_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(StringR.string.call).ifEmpty { "Call" }, stringProvider.getString(R.string.call).ifEmpty { "Call" },
NotificationManager.IMPORTANCE_HIGH NotificationManager.IMPORTANCE_HIGH
) )
.apply { .apply {
description = stringProvider.getString(StringR.string.call) description = stringProvider.getString(R.string.call)
setSound(null, null) setSound(null, null)
enableLights(true) enableLights(true)
lightColor = accentColor lightColor = accentColor
@ -242,11 +242,11 @@ class NotificationUtils @Inject constructor(
// Title for API < 16 devices. // Title for API < 16 devices.
.setContentTitle(roomInfo.roomDisplayName) .setContentTitle(roomInfo.roomDisplayName)
// Content for API < 16 devices. // Content for API < 16 devices.
.setContentText(stringProvider.getString(StringR.string.notification_new_messages)) .setContentText(stringProvider.getString(R.string.notification_new_messages))
// 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(
StringR.plurals.room_new_messages_notification, R.plurals.room_new_messages_notification,
messageStyle.messages.size, messageStyle.messages.size,
messageStyle.messages.size messageStyle.messages.size
) )
@ -292,7 +292,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(StringR.string.action_mark_room_read), markRoomReadPendingIntent stringProvider.getString(R.string.action_mark_room_read), markRoomReadPendingIntent
) )
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
.setShowsUserInterface(false) .setShowsUserInterface(false)
@ -373,7 +373,7 @@ class NotificationUtils @Inject constructor(
addAction( addAction(
R.drawable.vector_notification_reject_invitation, R.drawable.vector_notification_reject_invitation,
stringProvider.getString(StringR.string.action_reject), stringProvider.getString(R.string.action_reject),
rejectIntentPendingIntent rejectIntentPendingIntent
) )
@ -390,7 +390,7 @@ class NotificationUtils @Inject constructor(
) )
addAction( addAction(
R.drawable.vector_notification_accept_invitation, R.drawable.vector_notification_accept_invitation,
stringProvider.getString(StringR.string.action_join), stringProvider.getString(R.string.action_join),
joinIntentPendingIntent joinIntentPendingIntent
) )
@ -693,7 +693,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(StringR.string.settings_troubleshoot_test_push_notification_content)) .setContentText(stringProvider.getString(R.string.settings_troubleshoot_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))

View file

@ -19,13 +19,13 @@ package io.element.android.libraries.push.impl.notifications
import android.graphics.Bitmap import android.graphics.Bitmap
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.Person import androidx.core.app.Person
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
import io.element.android.services.toolbox.api.strings.StringProvider import io.element.android.services.toolbox.api.strings.StringProvider
import me.gujun.android.span.Span import me.gujun.android.span.Span
import me.gujun.android.span.span import me.gujun.android.span.span
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
class RoomGroupMessageCreator @Inject constructor( class RoomGroupMessageCreator @Inject constructor(
private val bitmapLoader: NotificationBitmapLoader, private val bitmapLoader: NotificationBitmapLoader,
@ -50,9 +50,9 @@ class RoomGroupMessageCreator @Inject constructor(
} }
val tickerText = if (roomIsGroup) { val tickerText = if (roomIsGroup) {
stringProvider.getString(StringR.string.notification_ticker_text_group, roomName, events.last().senderName, events.last().description) stringProvider.getString(R.string.notification_ticker_text_group, roomName, events.last().senderName, events.last().description)
} else { } else {
stringProvider.getString(StringR.string.notification_ticker_text_dm, events.last().senderName, events.last().description) stringProvider.getString(R.string.notification_ticker_text_dm, events.last().senderName, events.last().description)
} }
val largeBitmap = getRoomBitmap(events) val largeBitmap = getRoomBitmap(events)
@ -99,7 +99,7 @@ class RoomGroupMessageCreator @Inject constructor(
} }
when { when {
event.isSmartReplyError() -> addMessage( event.isSmartReplyError() -> addMessage(
stringProvider.getString(StringR.string.notification_inline_reply_failed), stringProvider.getString(R.string.notification_inline_reply_failed),
event.timestamp, event.timestamp,
senderPerson senderPerson
) )
@ -121,7 +121,7 @@ class RoomGroupMessageCreator @Inject constructor(
1 -> createFirstMessageSummaryLine(events.first(), roomName, roomIsDirect) 1 -> createFirstMessageSummaryLine(events.first(), roomName, roomIsDirect)
else -> { else -> {
stringProvider.getQuantityString( stringProvider.getQuantityString(
StringR.plurals.notification_compat_summary_line_for_room, R.plurals.notification_compat_summary_line_for_room,
events.size, events.size,
roomName, roomName,
events.size events.size

View file

@ -18,11 +18,10 @@ package io.element.android.libraries.push.impl.notifications
import android.app.Notification import android.app.Notification
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import io.element.android.libraries.push.impl.R
import io.element.android.services.toolbox.api.strings.StringProvider import io.element.android.services.toolbox.api.strings.StringProvider
import javax.inject.Inject import javax.inject.Inject
import io.element.android.libraries.ui.strings.R as StringR
/** /**
* ======== Build summary notification ========= * ======== Build summary notification =========
* On Android 7.0 (API level 24) and higher, the system automatically builds a summary for * On Android 7.0 (API level 24) and higher, the system automatically builds a summary for
@ -66,10 +65,10 @@ class SummaryGroupMessageCreator @Inject constructor(
// FIXME roomIdToEventMap.size is not correct, this is the number of rooms // FIXME roomIdToEventMap.size is not correct, this is the number of rooms
val nbEvents = roomNotifications.size + simpleNotifications.size val nbEvents = roomNotifications.size + simpleNotifications.size
val sumTitle = stringProvider.getQuantityString(StringR.plurals.notification_compat_summary_title, nbEvents, nbEvents) val sumTitle = stringProvider.getQuantityString(R.plurals.notification_compat_summary_title, nbEvents, nbEvents)
summaryInboxStyle.setBigContentTitle(sumTitle) summaryInboxStyle.setBigContentTitle(sumTitle)
// TODO get latest event? // TODO get latest event?
.setSummaryText(stringProvider.getQuantityString(StringR.plurals.notification_unread_notified_messages, nbEvents, nbEvents)) .setSummaryText(stringProvider.getQuantityString(R.plurals.notification_unread_notified_messages, nbEvents, nbEvents))
return if (useCompleteNotificationFormat) { return if (useCompleteNotificationFormat) {
notificationUtils.buildSummaryListNotification( notificationUtils.buildSummaryListNotification(
summaryInboxStyle, summaryInboxStyle,
@ -101,21 +100,21 @@ 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(StringR.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(
StringR.plurals.room_new_messages_notification, R.plurals.room_new_messages_notification,
messageNotificationCount, messageNotificationCount messageNotificationCount, messageNotificationCount
) )
if (roomCount > 1) { if (roomCount > 1) {
// In several rooms // In several rooms
val roomStr = stringProvider.getQuantityString( val roomStr = stringProvider.getQuantityString(
StringR.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(
StringR.string.notification_unread_notified_messages_in_room_and_invitation, R.string.notification_unread_notified_messages_in_room_and_invitation,
messageStr, messageStr,
roomStr, roomStr,
invitationsStr invitationsStr
@ -123,7 +122,7 @@ class SummaryGroupMessageCreator @Inject constructor(
} else { } else {
// In one room // In one room
stringProvider.getString( stringProvider.getString(
StringR.string.notification_unread_notified_messages_and_invitation, R.string.notification_unread_notified_messages_and_invitation,
messageStr, messageStr,
invitationsStr invitationsStr
) )
@ -135,13 +134,13 @@ class SummaryGroupMessageCreator @Inject constructor(
} else { } else {
// No invitation, only messages // No invitation, only messages
val messageStr = stringProvider.getQuantityString( val messageStr = stringProvider.getQuantityString(
StringR.plurals.room_new_messages_notification, R.plurals.room_new_messages_notification,
messageNotificationCount, messageNotificationCount messageNotificationCount, messageNotificationCount
) )
if (roomCount > 1) { if (roomCount > 1) {
// In several rooms // In several rooms
val roomStr = stringProvider.getQuantityString(StringR.plurals.notification_unread_notified_messages_in_room_rooms, roomCount, roomCount) val roomStr = stringProvider.getQuantityString(R.plurals.notification_unread_notified_messages_in_room_rooms, roomCount, roomCount)
stringProvider.getString(StringR.string.notification_unread_notified_messages_in_room, messageStr, roomStr) stringProvider.getString(R.string.notification_unread_notified_messages_in_room, messageStr, roomStr)
} else { } else {
// In one room // In one room
messageStr messageStr

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2023 New Vector Ltd
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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="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_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_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">
<item quantity="one">%d new message</item>
<item quantity="other">%d new messages</item>
</plurals>
<plurals name="notification_unread_notified_messages">
<item quantity="one">%d unread notified message</item>
<item quantity="other">%d unread notified messages</item>
</plurals>
<plurals name="notification_unread_notified_messages_in_room_rooms">
<item quantity="one">%d room</item>
<item quantity="other">%d rooms</item>
</plurals>
<plurals name="notification_invitations">
<item quantity="one">%d invitation</item>
<item quantity="other">%d invitations</item>
</plurals>
<plurals name="notification_compat_summary_line_for_room">
<item quantity="one">%1$s: %2$d message</item>
<item quantity="other">%1$s: %2$d messages</item>
</plurals>
<plurals name="notification_compat_summary_title">
<item quantity="one">%d notification</item>
<item quantity="other">%d notifications</item>
</plurals>
</resources>