@@ -130,7 +130,13 @@ class MessagesListFragment : BaseFragment<FragmentMessagesListBinding>(),
130
130
private val currentFolder: LocalFolder ?
131
131
get() = labelsViewModel.activeFolderLiveData.value
132
132
133
- private val adapter by lazy { MsgsPagedListAdapter () }
133
+ private val adapter by lazy {
134
+ MsgsPagedListAdapter (null , object : MsgsPagedListAdapter .OnMessageClickListener {
135
+ override fun onMsgClick (msgEntity : MessageEntity ) {
136
+ onMsgClicked(msgEntity)
137
+ }
138
+ })
139
+ }
134
140
135
141
private var keepSelectionInMemory = false
136
142
private var isForceSendingEnabled: Boolean = true
@@ -346,58 +352,6 @@ class MessagesListFragment : BaseFragment<FragmentMessagesListBinding>(),
346
352
}
347
353
}
348
354
349
- /* override fun onMsgClick(msgEntity: MessageEntity) {
350
- activeMsgEntity = msgEntity
351
- if (tracker?.hasSelection() == true) {
352
- return
353
- }
354
-
355
- val isOutbox =
356
- JavaEmailConstants.FOLDER_OUTBOX.equals(currentFolder?.fullName, ignoreCase = true)
357
- val isRawMsgAvailable = msgEntity.rawMessageWithoutAttachments?.isNotEmpty() ?: false
358
- if (isOutbox || isRawMsgAvailable || GeneralUtil.isConnected(context)) {
359
- when (msgEntity.msgState) {
360
- MessageState.ERROR_ORIGINAL_MESSAGE_MISSING,
361
- MessageState.ERROR_ORIGINAL_ATTACHMENT_NOT_FOUND,
362
- MessageState.ERROR_CACHE_PROBLEM,
363
- MessageState.ERROR_DURING_CREATION,
364
- MessageState.ERROR_SENDING_FAILED,
365
- MessageState.ERROR_PRIVATE_KEY_NOT_FOUND,
366
- MessageState.ERROR_COPY_NOT_SAVED_IN_SENT_FOLDER,
367
- MessageState.ERROR_PASSWORD_PROTECTED -> handleOutgoingMsgWhichHasSomeError(
368
- msgEntity
369
- )
370
- else -> {
371
- if (isOutbox && !isRawMsgAvailable) {
372
- showTwoWayDialog(
373
- requestCode = REQUEST_CODE_MESSAGE_DETAILS_UNAVAILABLE,
374
- dialogTitle = "",
375
- dialogMsg = getString(R.string.message_failed_to_create),
376
- positiveButtonTitle = getString(R.string.delete_message),
377
- negativeButtonTitle = getString(R.string.cancel),
378
- isCancelable = true
379
- )
380
- } else {
381
- currentFolder?.let { localFolder ->
382
- navController?.navigate(
383
- MessagesListFragmentDirections.actionMessagesListFragmentToMessageDetailsFragment(
384
- messageEntity = msgEntity,
385
- localFolder = localFolder
386
- )
387
- )
388
- }
389
- }
390
- }
391
- }
392
- } else {
393
- showInfoSnackbar(
394
- view,
395
- getString(R.string.internet_connection_is_not_available),
396
- Snackbar.LENGTH_LONG
397
- )
398
- }
399
- }*/
400
-
401
355
fun onDrawerStateChanged (slideOffset : Float , isOpened : Boolean ) {
402
356
when {
403
357
slideOffset > 0 -> {
@@ -1291,6 +1245,58 @@ class MessagesListFragment : BaseFragment<FragmentMessagesListBinding>(),
1291
1245
}
1292
1246
}
1293
1247
1248
+ private fun onMsgClicked (msgEntity : MessageEntity ) {
1249
+ activeMsgEntity = msgEntity
1250
+ if (tracker?.hasSelection() == true ) {
1251
+ return
1252
+ }
1253
+
1254
+ val isOutbox =
1255
+ JavaEmailConstants .FOLDER_OUTBOX .equals(currentFolder?.fullName, ignoreCase = true )
1256
+ val isRawMsgAvailable = msgEntity.rawMessageWithoutAttachments?.isNotEmpty() ? : false
1257
+ if (isOutbox || isRawMsgAvailable || GeneralUtil .isConnected(context)) {
1258
+ when (msgEntity.msgState) {
1259
+ MessageState .ERROR_ORIGINAL_MESSAGE_MISSING ,
1260
+ MessageState .ERROR_ORIGINAL_ATTACHMENT_NOT_FOUND ,
1261
+ MessageState .ERROR_CACHE_PROBLEM ,
1262
+ MessageState .ERROR_DURING_CREATION ,
1263
+ MessageState .ERROR_SENDING_FAILED ,
1264
+ MessageState .ERROR_PRIVATE_KEY_NOT_FOUND ,
1265
+ MessageState .ERROR_COPY_NOT_SAVED_IN_SENT_FOLDER ,
1266
+ MessageState .ERROR_PASSWORD_PROTECTED -> handleOutgoingMsgWhichHasSomeError(
1267
+ msgEntity
1268
+ )
1269
+ else -> {
1270
+ if (isOutbox && ! isRawMsgAvailable) {
1271
+ showTwoWayDialog(
1272
+ requestCode = REQUEST_CODE_MESSAGE_DETAILS_UNAVAILABLE ,
1273
+ dialogTitle = " " ,
1274
+ dialogMsg = getString(R .string.message_failed_to_create),
1275
+ positiveButtonTitle = getString(R .string.delete_message),
1276
+ negativeButtonTitle = getString(R .string.cancel),
1277
+ isCancelable = true
1278
+ )
1279
+ } else {
1280
+ currentFolder?.let { localFolder ->
1281
+ navController?.navigate(
1282
+ MessagesListFragmentDirections .actionMessagesListFragmentToMessageDetailsFragment(
1283
+ messageEntity = msgEntity,
1284
+ localFolder = localFolder
1285
+ )
1286
+ )
1287
+ }
1288
+ }
1289
+ }
1290
+ }
1291
+ } else {
1292
+ showInfoSnackbar(
1293
+ view,
1294
+ getString(R .string.internet_connection_is_not_available),
1295
+ Snackbar .LENGTH_LONG
1296
+ )
1297
+ }
1298
+ }
1299
+
1294
1300
companion object {
1295
1301
private const val REQUEST_CODE_RETRY_TO_SEND_MESSAGES = 11
1296
1302
private const val REQUEST_CODE_ERROR_DURING_CREATION = 12
0 commit comments