@@ -198,75 +198,76 @@ class ThreadFragment : Fragment() {
198
198
adapter = ThreadAdapter (
199
199
shouldLoadDistantResources = shouldLoadDistantResources(),
200
200
isCalendarEventExpandedMap = threadViewModel.isCalendarEventExpandedMap,
201
- onContactClicked = {
202
- safeNavigate(
203
- resId = R .id.detailedContactBottomSheetDialog,
204
- args = DetailedContactBottomSheetDialogArgs (it).toBundle(),
205
- )
206
- },
207
- onDraftClicked = { message ->
208
- trackNewMessageEvent(OPEN_FROM_DRAFT_NAME )
209
- twoPaneViewModel.navigateToNewMessage(
210
- arrivedFromExistingDraft = true ,
211
- draftLocalUuid = message.draftLocalUuid,
212
- draftResource = message.draftResource,
213
- messageUid = message.uid,
214
- )
215
- },
216
- onDeleteDraftClicked = { message ->
217
- trackMessageActionsEvent(" deleteDraft" )
218
- mainViewModel.currentMailbox.value?.let { mailbox -> threadViewModel.deleteDraft(message, mailbox) }
219
- },
220
- onAttachmentClicked = { attachment ->
221
- attachment.resource?.let { resource ->
201
+ threadAdapterCallbacks = ThreadAdapter .ThreadAdapterCallbacks (
202
+ onContactClicked = {
222
203
safeNavigate(
223
204
resId = R .id.detailedContactBottomSheetDialog,
224
205
args = DetailedContactBottomSheetDialogArgs (it).toBundle(),
225
206
)
226
- }
227
- },
228
- onDownloadAllClicked = { message ->
229
- trackAttachmentActionsEvent(" downloadAll" )
230
- downloadAllAttachments(message)
231
- },
232
- onReplyClicked = { message ->
233
- trackMessageActionsEvent(ACTION_REPLY_NAME )
234
- replyTo(message)
235
- },
236
- onMenuClicked = { message ->
237
- message.navigateToActionsBottomSheet()
238
- },
239
- onAllExpandedMessagesLoaded = ::scrollToFirstUnseenMessage,
240
- navigateToAttendeeBottomSheet = { attendees ->
241
- safeNavigate(
242
- resId = R .id.attendeesBottomSheetDialog,
243
- args = AttendeesBottomSheetDialogArgs (attendees.toTypedArray()).toBundle(),
244
- )
245
- },
246
- navigateToNewMessageActivity = { twoPaneViewModel.navigateToNewMessage(mailToUri = it) },
247
- navigateToDownloadProgressDialog = ::safeNavigate,
248
- replyToCalendarEvent = { attendanceState, message ->
249
- threadViewModel.replyToCalendarEvent(
250
- attendanceState,
251
- message,
252
- ).observe(viewLifecycleOwner) { successfullyUpdated ->
253
- if (successfullyUpdated) {
254
- snackbarManager.setValue(getString(R .string.snackbarCalendarChoiceSent))
255
- threadViewModel.fetchCalendarEvents(listOf (message), forceFetch = true )
256
- } else {
257
- snackbarManager.setValue(getString(R .string.errorCalendarChoiceCouldNotBeSent))
258
- threadAdapter.undoUserAttendanceClick(message)
207
+ },
208
+ onDraftClicked = { message ->
209
+ trackNewMessageEvent(OPEN_FROM_DRAFT_NAME )
210
+ twoPaneViewModel.navigateToNewMessage(
211
+ arrivedFromExistingDraft = true ,
212
+ draftLocalUuid = message.draftLocalUuid,
213
+ draftResource = message.draftResource,
214
+ messageUid = message.uid,
215
+ )
216
+ },
217
+ onDeleteDraftClicked = { message ->
218
+ trackMessageActionsEvent(" deleteDraft" )
219
+ mainViewModel.currentMailbox.value?.let { mailbox -> threadViewModel.deleteDraft(message, mailbox) }
220
+ },
221
+ onAttachmentClicked = { attachment ->
222
+ attachment.resource?.let { resource ->
223
+ safeNavigate(
224
+ resId = R .id.attachmentActionsBottomSheetDialog,
225
+ args = AttachmentActionsBottomSheetDialogArgs (resource).toBundle(),
226
+ )
227
+ }
228
+ },
229
+ onDownloadAllClicked = { message ->
230
+ trackAttachmentActionsEvent(" downloadAll" )
231
+ downloadAllAttachments(message)
232
+ },
233
+ onReplyClicked = { message ->
234
+ trackMessageActionsEvent(ACTION_REPLY_NAME )
235
+ replyTo(message)
236
+ },
237
+ onMenuClicked = { message ->
238
+ message.navigateToActionsBottomSheet()
239
+ },
240
+ onAllExpandedMessagesLoaded = ::scrollToFirstUnseenMessage,
241
+ navigateToAttendeeBottomSheet = { attendees ->
242
+ safeNavigate(
243
+ resId = R .id.attendeesBottomSheetDialog,
244
+ args = AttendeesBottomSheetDialogArgs (attendees.toTypedArray()).toBundle(),
245
+ )
246
+ },
247
+ navigateToNewMessageActivity = { twoPaneViewModel.navigateToNewMessage(mailToUri = it) },
248
+ navigateToDownloadProgressDialog = ::safeNavigate,
249
+ replyToCalendarEvent = { attendanceState, message ->
250
+ threadViewModel.replyToCalendarEvent(
251
+ attendanceState,
252
+ message,
253
+ ).observe(viewLifecycleOwner) { successfullyUpdated ->
254
+ if (successfullyUpdated) {
255
+ snackbarManager.setValue(getString(R .string.snackbarCalendarChoiceSent))
256
+ threadViewModel.fetchCalendarEvents(listOf (message), forceFetch = true )
257
+ } else {
258
+ snackbarManager.setValue(getString(R .string.errorCalendarChoiceCouldNotBeSent))
259
+ threadAdapter.undoUserAttendanceClick(message)
260
+ }
261
+ }
262
+ },
263
+ promptLink = { data, type ->
264
+ // When adding a phone number to contacts, Google decodes this value in case it's url-encoded. But I could not
265
+ // reproduce this issue when manually creating a url-encoded href. If this is triggered, fix it by also
266
+ // decoding it at that step.
267
+ if (type == ContextMenuType .PHONE && data.contains(' %' )) Sentry .withScope { scope ->
268
+ scope.level = SentryLevel .ERROR
269
+ Sentry .captureMessage(" Google was right, phone numbers can be url-encoded. Needs to be fixed" )
259
270
}
260
- }
261
- },
262
- promptLink = { data, type ->
263
- // When adding a phone number to contacts, Google decodes this value in case it's url-encoded. But I could not
264
- // reproduce this issue when manually creating a url-encoded href. If this is triggered, fix it by also
265
- // decoding it at that step.
266
- if (type == ContextMenuType .PHONE && data.contains(' %' )) Sentry .withScope { scope ->
267
- scope.level = SentryLevel .ERROR
268
- Sentry .captureMessage(" Google was right, phone numbers can be url-encoded. Needs to be fixed" )
269
- }
270
271
271
272
when (type) {
272
273
ContextMenuType .LINK -> linkContextualMenuAlertDialog.show(data)
0 commit comments