Loading domain/src/main/java/com/moez/QKSMS/interactor/AddScheduledMessage.kt +12 −7 Original line number Diff line number Diff line Loading @@ -27,16 +27,21 @@ class AddScheduledMessage @Inject constructor( private val updateScheduledMessageAlarms: UpdateScheduledMessageAlarms ) : Interactor<AddScheduledMessage.Params>() { data class Params(val date: Long, data class Params( val date: Long, val subId: Int, val recipients: List<String>, val sendAsGroup: Boolean, val body: String, val attachments: List<String>) val attachments: List<String> ) override fun buildObservable(params: Params): Flowable<*> { return Flowable.just(params) .map { scheduledMessageRepo.saveScheduledMessage(it.date, it.subId, it.recipients, it.sendAsGroup, it.body, it.attachments) } .map { scheduledMessageRepo.saveScheduledMessage(it.date, it.subId, it.recipients, it.sendAsGroup, it.body, it.attachments) } .flatMap { updateScheduledMessageAlarms.buildObservable(Unit) } } Loading domain/src/main/java/com/moez/QKSMS/interactor/DeleteMessages.kt +3 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ class DeleteMessages @Inject constructor( override fun buildObservable(params: Params): Flowable<*> { return Flowable.just(params.messageIds.toLongArray()) .doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages .doOnNext { params.threadId?.let { conversationRepo.updateConversations(it) } } // Update the conversation .doOnNext { params.threadId?.let { conversationRepo.updateConversations(it) } // Update the conversation } .doOnNext { params.threadId?.let { notificationManager.update(it) } } .flatMap { updateBadge.buildObservable(Unit) } // Update the badge } Loading domain/src/main/java/com/moez/QKSMS/interactor/ReceiveMms.kt +10 −3 Original line number Diff line number Diff line Loading @@ -58,10 +58,17 @@ class ReceiveMms @Inject constructor( if (blocked) messageRepo.deleteMessages(message.id) } } .doOnNext { message -> conversationRepo.updateConversations(message.threadId) } // Update the conversation .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) } // Map message to conversation .doOnNext { message -> conversationRepo.updateConversations(message.threadId) // Update the conversation } .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) // Map message to conversation } .filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations .doOnNext { conversation -> if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary .doOnNext { conversation -> // Unarchive conversation if necessary if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } .map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread .doOnNext(notificationManager::update) // Update the notification .flatMap { updateBadge.buildObservable(Unit) } // Update the badge Loading domain/src/main/java/com/moez/QKSMS/interactor/ReceiveSms.kt +11 −4 Original line number Diff line number Diff line Loading @@ -53,14 +53,21 @@ class ReceiveSms @Inject constructor( val time = messages[0].timestampMillis val body: String = messages .mapNotNull { message -> message.displayMessageBody } .reduce { body, new -> body + new } ?: "" .reduce { body, new -> body + new } messageRepo.insertReceivedSms(it.subId, address, body, time) // Add the message to the db } .doOnNext { message -> conversationRepo.updateConversations(message.threadId) } // Update the conversation .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) } // Map message to conversation .doOnNext { message -> conversationRepo.updateConversations(message.threadId) // Update the conversation } .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) // Map message to conversation } .filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations .doOnNext { conversation -> if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary .doOnNext { conversation -> // Unarchive conversation if necessary if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } .map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread .doOnNext { threadId -> notificationManager.update(threadId) } // Update the notification .doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts Loading domain/src/main/java/com/moez/QKSMS/interactor/SendMessage.kt +7 −5 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ package com.moez.QKSMS.interactor import com.moez.QKSMS.model.Attachment import com.moez.QKSMS.repository.ConversationRepository import com.moez.QKSMS.repository.MessageRepository import com.moez.QKSMS.repository.SyncRepository import io.reactivex.Flowable import javax.inject.Inject class SendMessage @Inject constructor( private val conversationRepo: ConversationRepository, private val messageRepo: MessageRepository, private val syncRepo: SyncRepository private val messageRepo: MessageRepository ) : Interactor<SendMessage.Params>() { data class Params( Loading @@ -37,11 +35,15 @@ class SendMessage @Inject constructor( val addresses: List<String>, val body: String, val attachments: List<Attachment> = listOf(), val delay: Int = 0) val delay: Int = 0 ) override fun buildObservable(params: Params): Flowable<*> = Flowable.just(Unit) .filter { params.addresses.isNotEmpty() } .doOnNext { messageRepo.sendMessage(params.subId, params.threadId, params.addresses, params.body, params.attachments, params.delay) } .doOnNext { messageRepo.sendMessage(params.subId, params.threadId, params.addresses, params.body, params.attachments, params.delay) } .map { // On some manufacturers, we can't obtain a threadId for a new conversation. In // this case, find the threadId manually now that it contains a message Loading Loading
domain/src/main/java/com/moez/QKSMS/interactor/AddScheduledMessage.kt +12 −7 Original line number Diff line number Diff line Loading @@ -27,16 +27,21 @@ class AddScheduledMessage @Inject constructor( private val updateScheduledMessageAlarms: UpdateScheduledMessageAlarms ) : Interactor<AddScheduledMessage.Params>() { data class Params(val date: Long, data class Params( val date: Long, val subId: Int, val recipients: List<String>, val sendAsGroup: Boolean, val body: String, val attachments: List<String>) val attachments: List<String> ) override fun buildObservable(params: Params): Flowable<*> { return Flowable.just(params) .map { scheduledMessageRepo.saveScheduledMessage(it.date, it.subId, it.recipients, it.sendAsGroup, it.body, it.attachments) } .map { scheduledMessageRepo.saveScheduledMessage(it.date, it.subId, it.recipients, it.sendAsGroup, it.body, it.attachments) } .flatMap { updateScheduledMessageAlarms.buildObservable(Unit) } } Loading
domain/src/main/java/com/moez/QKSMS/interactor/DeleteMessages.kt +3 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ class DeleteMessages @Inject constructor( override fun buildObservable(params: Params): Flowable<*> { return Flowable.just(params.messageIds.toLongArray()) .doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages .doOnNext { params.threadId?.let { conversationRepo.updateConversations(it) } } // Update the conversation .doOnNext { params.threadId?.let { conversationRepo.updateConversations(it) } // Update the conversation } .doOnNext { params.threadId?.let { notificationManager.update(it) } } .flatMap { updateBadge.buildObservable(Unit) } // Update the badge } Loading
domain/src/main/java/com/moez/QKSMS/interactor/ReceiveMms.kt +10 −3 Original line number Diff line number Diff line Loading @@ -58,10 +58,17 @@ class ReceiveMms @Inject constructor( if (blocked) messageRepo.deleteMessages(message.id) } } .doOnNext { message -> conversationRepo.updateConversations(message.threadId) } // Update the conversation .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) } // Map message to conversation .doOnNext { message -> conversationRepo.updateConversations(message.threadId) // Update the conversation } .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) // Map message to conversation } .filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations .doOnNext { conversation -> if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary .doOnNext { conversation -> // Unarchive conversation if necessary if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } .map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread .doOnNext(notificationManager::update) // Update the notification .flatMap { updateBadge.buildObservable(Unit) } // Update the badge Loading
domain/src/main/java/com/moez/QKSMS/interactor/ReceiveSms.kt +11 −4 Original line number Diff line number Diff line Loading @@ -53,14 +53,21 @@ class ReceiveSms @Inject constructor( val time = messages[0].timestampMillis val body: String = messages .mapNotNull { message -> message.displayMessageBody } .reduce { body, new -> body + new } ?: "" .reduce { body, new -> body + new } messageRepo.insertReceivedSms(it.subId, address, body, time) // Add the message to the db } .doOnNext { message -> conversationRepo.updateConversations(message.threadId) } // Update the conversation .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) } // Map message to conversation .doOnNext { message -> conversationRepo.updateConversations(message.threadId) // Update the conversation } .mapNotNull { message -> conversationRepo.getOrCreateConversation(message.threadId) // Map message to conversation } .filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations .doOnNext { conversation -> if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary .doOnNext { conversation -> // Unarchive conversation if necessary if (conversation.archived) conversationRepo.markUnarchived(conversation.id) } .map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread .doOnNext { threadId -> notificationManager.update(threadId) } // Update the notification .doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts Loading
domain/src/main/java/com/moez/QKSMS/interactor/SendMessage.kt +7 −5 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ package com.moez.QKSMS.interactor import com.moez.QKSMS.model.Attachment import com.moez.QKSMS.repository.ConversationRepository import com.moez.QKSMS.repository.MessageRepository import com.moez.QKSMS.repository.SyncRepository import io.reactivex.Flowable import javax.inject.Inject class SendMessage @Inject constructor( private val conversationRepo: ConversationRepository, private val messageRepo: MessageRepository, private val syncRepo: SyncRepository private val messageRepo: MessageRepository ) : Interactor<SendMessage.Params>() { data class Params( Loading @@ -37,11 +35,15 @@ class SendMessage @Inject constructor( val addresses: List<String>, val body: String, val attachments: List<Attachment> = listOf(), val delay: Int = 0) val delay: Int = 0 ) override fun buildObservable(params: Params): Flowable<*> = Flowable.just(Unit) .filter { params.addresses.isNotEmpty() } .doOnNext { messageRepo.sendMessage(params.subId, params.threadId, params.addresses, params.body, params.attachments, params.delay) } .doOnNext { messageRepo.sendMessage(params.subId, params.threadId, params.addresses, params.body, params.attachments, params.delay) } .map { // On some manufacturers, we can't obtain a threadId for a new conversation. In // this case, find the threadId manually now that it contains a message Loading