From 2e4d30ef29e8120e44b235ed273fa35db677270f Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Fri, 10 Apr 2020 12:07:53 -0500 Subject: [PATCH 1/4] Set `tickerText` to improve accessibility of notifications. Signed-off-by: Nolan Darilek --- gradle.properties | 2 +- .../features/notifications/NotificationDrawerManager.kt | 9 ++++++++- .../riotx/features/notifications/NotificationUtils.kt | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2e2b110f15..d9d9e57cbc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ # The setting is particularly useful for tweaking memory settings. android.enableJetifier=true android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx8192m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt index 94d3860cca..7307e08c56 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt @@ -343,12 +343,19 @@ class NotificationDrawerManager @Inject constructor(private val context: Context globalLastMessageTimestamp = lastMessageTimestamp } + val tickerText = if (roomEventGroupInfo.isDirect) { + String.format("%s: %s", events[0].senderName, events[0].description) + } else { + String.format("%s: %s %s", roomName, events[0].senderName, events[0].description) + } + val notification = notificationUtils.buildMessagesListNotification( style, roomEventGroupInfo, largeBitmap, lastMessageTimestamp, - myUserDisplayName) + myUserDisplayName, + tickerText) // is there an id for this room? notificationUtils.showNotificationMessage(roomId, ROOM_MESSAGES_NOTIFICATION_ID, notification) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt index 50fb5b70de..178235ab5f 100755 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt @@ -381,7 +381,8 @@ class NotificationUtils @Inject constructor(private val context: Context, roomInfo: RoomEventGroupInfo, largeIcon: Bitmap?, lastMessageTimestamp: Long, - senderDisplayNameForReplyCompat: String?): Notification { + senderDisplayNameForReplyCompat: String?, + tickerText: String): Notification { val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color) // Build the pending intent for when the notification is clicked val openRoomIntent = buildOpenRoomIntent(roomInfo.roomId) @@ -478,6 +479,7 @@ class NotificationUtils @Inject constructor(private val context: Context, System.currentTimeMillis().toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT) setDeleteIntent(pendingIntent) } + .setTicker(tickerText) .build() } From 6bbded1e65ab00a3035bbe2440e3afefa64ecf58 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 7 May 2020 15:14:31 +0000 Subject: [PATCH 2/4] Use string resource for generating ticker text. --- .../riotx/features/notifications/NotificationDrawerManager.kt | 4 ++-- vector/src/main/res/values/strings.xml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt index 7307e08c56..66a80be89e 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt @@ -344,9 +344,9 @@ class NotificationDrawerManager @Inject constructor(private val context: Context } val tickerText = if (roomEventGroupInfo.isDirect) { - String.format("%s: %s", events[0].senderName, events[0].description) + stringProvider.getString(R.string.notification_ticker_text_dm, events[0].senderName, events[0].description) } else { - String.format("%s: %s %s", roomName, events[0].senderName, events[0].description) + stringProvider.getString(R.string.notification_ticker_text_group, roomName, events[0].senderName, events[0].description) } val notification = notificationUtils.buildMessagesListNotification( diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index ae2cb7bbbb..9d20908b14 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1089,6 +1089,8 @@ New Invitation Me ** Failed to send - please open room + %1$s: %2$s + %1$s: %2$s %3$s Search for historical From 6e8e7164c6f0c5cc365d97d09879b19074eed9fe Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 7 May 2020 15:29:42 +0000 Subject: [PATCH 3/4] Use last event when generating ticker text. --- .../riotx/features/notifications/NotificationDrawerManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt index 66a80be89e..9e3a298378 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationDrawerManager.kt @@ -344,9 +344,9 @@ class NotificationDrawerManager @Inject constructor(private val context: Context } val tickerText = if (roomEventGroupInfo.isDirect) { - stringProvider.getString(R.string.notification_ticker_text_dm, events[0].senderName, events[0].description) + stringProvider.getString(R.string.notification_ticker_text_dm, events.last().senderName, events.last().description) } else { - stringProvider.getString(R.string.notification_ticker_text_group, roomName, events[0].senderName, events[0].description) + stringProvider.getString(R.string.notification_ticker_text_group, roomName, events.last().senderName, events.last().description) } val notification = notificationUtils.buildMessagesListNotification( From 35ee7f0b40bc03d1f659c366750d7ae2b98659b9 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 7 May 2020 15:38:28 +0000 Subject: [PATCH 4/4] Add changelog entry. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 16b39cc6b1..2bdef0f177 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Improvements 🙌: - Cross-Signing | Restore history after recover from passphrase (#1214) - Cross-Sign | QR code scan confirmation screens design update (#1187) - Emoji Verification | It's not the same butterfly! (#1220) + - Improve notification accessibility with ticker text (#1226) Bugfix 🐛: - Missing avatar/displayname after verification request message (#841)