Skip to content

Commit cd9a1fe

Browse files
committed
Cleanup: remove unused summaryLine field.
1 parent d304977 commit cd9a1fe

File tree

4 files changed

+1
-58
lines changed

4 files changed

+1
-58
lines changed

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactory.kt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
package io.element.android.libraries.push.impl.notifications
1010

1111
import android.app.Notification
12-
import android.graphics.Typeface
13-
import android.text.style.StyleSpan
14-
import androidx.core.text.buildSpannedString
15-
import androidx.core.text.inSpans
1612
import coil3.ImageLoader
1713
import dev.zacsweers.metro.AppScope
1814
import dev.zacsweers.metro.ContributesBinding
1915
import io.element.android.libraries.matrix.api.core.RoomId
2016
import io.element.android.libraries.matrix.api.core.SessionId
2117
import io.element.android.libraries.matrix.api.core.ThreadId
22-
import io.element.android.libraries.push.impl.R
2318
import io.element.android.libraries.push.impl.notifications.factories.NotificationAccountParams
2419
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
2520
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
@@ -98,7 +93,6 @@ class DefaultNotificationDataFactory(
9893
notification = notification,
9994
roomId = roomId,
10095
threadId = threadId,
101-
summaryLine = createRoomMessagesGroupSummaryLine(events, roomName, isDm),
10296
messageCount = events.size,
10397
latestTimestamp = events.maxOf { it.timestamp },
10498
shouldBing = events.any { it.noisy }
@@ -123,7 +117,6 @@ class DefaultNotificationDataFactory(
123117
OneShotNotification(
124118
tag = event.roomId.value,
125119
notification = notificationCreator.createRoomInvitationNotification(notificationAccountParams, event),
126-
summaryLine = event.description,
127120
isNoisy = event.noisy,
128121
timestamp = event.timestamp
129122
)
@@ -140,7 +133,6 @@ class DefaultNotificationDataFactory(
140133
OneShotNotification(
141134
tag = event.eventId.value,
142135
notification = notificationCreator.createSimpleEventNotification(notificationAccountParams, event),
143-
summaryLine = event.description,
144136
isNoisy = event.noisy,
145137
timestamp = event.timestamp
146138
)
@@ -157,7 +149,6 @@ class DefaultNotificationDataFactory(
157149
OneShotNotification(
158150
tag = event.eventId.value,
159151
notification = notificationCreator.createFallbackNotification(notificationAccountParams, event),
160-
summaryLine = event.description.orEmpty(),
161152
isNoisy = false,
162153
timestamp = event.timestamp
163154
)
@@ -184,53 +175,12 @@ class DefaultNotificationDataFactory(
184175
)
185176
}
186177
}
187-
188-
private fun createRoomMessagesGroupSummaryLine(events: List<NotifiableMessageEvent>, roomName: String, roomIsDm: Boolean): CharSequence {
189-
return when (events.size) {
190-
1 -> createFirstMessageSummaryLine(events.first(), roomName, roomIsDm)
191-
else -> {
192-
stringProvider.getQuantityString(
193-
R.plurals.notification_compat_summary_line_for_room,
194-
events.size,
195-
roomName,
196-
events.size
197-
)
198-
}
199-
}
200-
}
201-
202-
private fun createFirstMessageSummaryLine(event: NotifiableMessageEvent, roomName: String, roomIsDm: Boolean): CharSequence {
203-
return if (roomIsDm) {
204-
buildSpannedString {
205-
event.senderDisambiguatedDisplayName?.let {
206-
inSpans(StyleSpan(Typeface.BOLD)) {
207-
append(it)
208-
append(": ")
209-
}
210-
}
211-
append(event.description)
212-
}
213-
} else {
214-
buildSpannedString {
215-
inSpans(StyleSpan(Typeface.BOLD)) {
216-
append(roomName)
217-
append(": ")
218-
event.senderDisambiguatedDisplayName?.let {
219-
append(it)
220-
append(" ")
221-
}
222-
}
223-
append(event.description)
224-
}
225-
}
226-
}
227178
}
228179

229180
data class RoomNotification(
230181
val notification: Notification,
231182
val roomId: RoomId,
232183
val threadId: ThreadId?,
233-
val summaryLine: CharSequence,
234184
val messageCount: Int,
235185
val latestTimestamp: Long,
236186
val shouldBing: Boolean,
@@ -239,7 +189,6 @@ data class RoomNotification(
239189
return notification == other.notification &&
240190
roomId == other.roomId &&
241191
threadId == other.threadId &&
242-
summaryLine.toString() == other.summaryLine.toString() &&
243192
messageCount == other.messageCount &&
244193
latestTimestamp == other.latestTimestamp &&
245194
shouldBing == other.shouldBing
@@ -249,7 +198,6 @@ data class RoomNotification(
249198
data class OneShotNotification(
250199
val notification: Notification,
251200
val tag: String,
252-
val summaryLine: CharSequence,
253201
val isNoisy: Boolean,
254202
val timestamp: Long,
255203
)

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultSummaryGroupMessageCreatorTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class DefaultSummaryGroupMessageCreatorTest {
3939
RoomNotification(
4040
notification = Notification(),
4141
roomId = A_ROOM_ID,
42-
summaryLine = "",
4342
messageCount = 1,
4443
latestTimestamp = A_FAKE_TIMESTAMP + 10,
4544
shouldBing = true,

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationDataFactoryTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class NotificationDataFactoryTest {
6464
OneShotNotification(
6565
notification = expectedNotification,
6666
tag = A_ROOM_ID.value,
67-
summaryLine = AN_INVITATION_EVENT.description,
6867
isNoisy = AN_INVITATION_EVENT.noisy,
6968
timestamp = AN_INVITATION_EVENT.timestamp
7069
)
@@ -83,7 +82,6 @@ class NotificationDataFactoryTest {
8382
OneShotNotification(
8483
notification = expectedNotification,
8584
tag = AN_EVENT_ID.value,
86-
summaryLine = A_SIMPLE_EVENT.description,
8785
isNoisy = A_SIMPLE_EVENT.noisy,
8886
timestamp = AN_INVITATION_EVENT.timestamp
8987
)
@@ -105,7 +103,6 @@ class NotificationDataFactoryTest {
105103
existingNotification = null,
106104
),
107105
roomId = A_ROOM_ID,
108-
summaryLine = "A room name: Bob Hello world!",
109106
messageCount = events.size,
110107
latestTimestamp = events.maxOf { it.timestamp },
111108
shouldBing = events.any { it.noisy },
@@ -161,7 +158,6 @@ class NotificationDataFactoryTest {
161158
existingNotification = null,
162159
),
163160
roomId = A_ROOM_ID,
164-
summaryLine = "A room name: Bob Hello world!",
165161
messageCount = withRedactedRemoved.size,
166162
latestTimestamp = withRedactedRemoved.maxOf { it.timestamp },
167163
shouldBing = withRedactedRemoved.any { it.noisy },

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationRendererTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private const val USE_COMPLETE_NOTIFICATION_FORMAT = true
4343

4444
private val A_SUMMARY_NOTIFICATION = SummaryNotification.Update(A_NOTIFICATION)
4545
private val ONE_SHOT_NOTIFICATION =
46-
OneShotNotification(notification = A_NOTIFICATION, tag = "ignored", summaryLine = "ignored", isNoisy = false, timestamp = -1)
46+
OneShotNotification(notification = A_NOTIFICATION, tag = "ignored", isNoisy = false, timestamp = -1)
4747

4848
@RunWith(RobolectricTestRunner::class)
4949
class NotificationRendererTest {

0 commit comments

Comments
 (0)