forked from upstream-mirrors/quik
#824 - Ask user to set QK as default SMS app if they attempt something that requires it
This commit is contained in:
@@ -356,6 +356,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
// Delete the messages
|
// Delete the messages
|
||||||
view.optionsItemIntent
|
view.optionsItemIntent
|
||||||
.filter { it == R.id.delete }
|
.filter { it == R.id.delete }
|
||||||
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
||||||
deleteMessages.execute(DeleteMessages.Params(messages, conversation.id))
|
deleteMessages.execute(DeleteMessages.Params(messages, conversation.id))
|
||||||
}
|
}
|
||||||
@@ -612,11 +613,8 @@ class ComposeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Send a message when the send button is clicked, and disable editing mode if it's enabled
|
// Send a message when the send button is clicked, and disable editing mode if it's enabled
|
||||||
view.sendIntent
|
view.sendIntent
|
||||||
.filter {
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
val hasPermission = permissionManager.hasSendSms()
|
.filter { permissionManager.hasSendSms().also { if (!it) view.requestSmsPermission() } }
|
||||||
if (!hasPermission) view.requestSmsPermission()
|
|
||||||
hasPermission
|
|
||||||
}
|
|
||||||
.withLatestFrom(view.textChangedIntent) { _, body -> body }
|
.withLatestFrom(view.textChangedIntent) { _, body -> body }
|
||||||
.map { body -> body.toString() }
|
.map { body -> body.toString() }
|
||||||
.withLatestFrom(state, attachments, conversation, selectedContacts) { body, state, attachments, conversation, contacts ->
|
.withLatestFrom(state, attachments, conversation, selectedContacts) { body, state, attachments, conversation, contacts ->
|
||||||
|
|||||||
+4
-1
@@ -26,6 +26,7 @@ import com.moez.QKSMS.interactor.MarkArchived
|
|||||||
import com.moez.QKSMS.interactor.MarkBlocked
|
import com.moez.QKSMS.interactor.MarkBlocked
|
||||||
import com.moez.QKSMS.interactor.MarkUnarchived
|
import com.moez.QKSMS.interactor.MarkUnarchived
|
||||||
import com.moez.QKSMS.interactor.MarkUnblocked
|
import com.moez.QKSMS.interactor.MarkUnblocked
|
||||||
|
import com.moez.QKSMS.manager.PermissionManager
|
||||||
import com.moez.QKSMS.model.Conversation
|
import com.moez.QKSMS.model.Conversation
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
import com.moez.QKSMS.repository.MessageRepository
|
import com.moez.QKSMS.repository.MessageRepository
|
||||||
@@ -46,7 +47,8 @@ class ConversationInfoPresenter @Inject constructor(
|
|||||||
private val markUnarchived: MarkUnarchived,
|
private val markUnarchived: MarkUnarchived,
|
||||||
private val markBlocked: MarkBlocked,
|
private val markBlocked: MarkBlocked,
|
||||||
private val markUnblocked: MarkUnblocked,
|
private val markUnblocked: MarkUnblocked,
|
||||||
private val navigator: Navigator
|
private val navigator: Navigator,
|
||||||
|
private val permissionManager: PermissionManager
|
||||||
) : QkPresenter<ConversationInfoView, ConversationInfoState>(
|
) : QkPresenter<ConversationInfoView, ConversationInfoState>(
|
||||||
ConversationInfoState(threadId = threadId, media = messageRepo.getPartsForConversation(threadId))
|
ConversationInfoState(threadId = threadId, media = messageRepo.getPartsForConversation(threadId))
|
||||||
) {
|
) {
|
||||||
@@ -151,6 +153,7 @@ class ConversationInfoPresenter @Inject constructor(
|
|||||||
|
|
||||||
// Show the delete confirmation dialog
|
// Show the delete confirmation dialog
|
||||||
view.deleteClicks()
|
view.deleteClicks()
|
||||||
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { view.showDeleteDialog() }
|
.subscribe { view.showDeleteDialog() }
|
||||||
|
|
||||||
|
|||||||
@@ -206,45 +206,75 @@ class MainViewModel @Inject constructor(
|
|||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
view.optionsItemIntent
|
view.optionsItemIntent
|
||||||
.withLatestFrom(view.conversationsSelectedIntent) { itemId, conversations ->
|
.filter { itemId -> itemId == R.id.archive }
|
||||||
when (itemId) {
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
R.id.archive -> {
|
markArchived.execute(conversations)
|
||||||
markArchived.execute(conversations)
|
view.clearSelection()
|
||||||
view.clearSelection()
|
}
|
||||||
}
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.unarchive -> {
|
view.optionsItemIntent
|
||||||
markUnarchived.execute(conversations)
|
.filter { itemId -> itemId == R.id.unarchive }
|
||||||
view.clearSelection()
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
}
|
markUnarchived.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.delete -> view.showDeleteDialog(conversations)
|
view.optionsItemIntent
|
||||||
|
.filter { itemId -> itemId == R.id.delete }
|
||||||
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
|
view.showDeleteDialog(conversations)
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.pin -> {
|
view.optionsItemIntent
|
||||||
markPinned.execute(conversations)
|
.filter { itemId -> itemId == R.id.pin }
|
||||||
view.clearSelection()
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
}
|
markPinned.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.unpin -> {
|
view.optionsItemIntent
|
||||||
markUnpinned.execute(conversations)
|
.filter { itemId -> itemId == R.id.unpin }
|
||||||
view.clearSelection()
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
}
|
markUnpinned.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.read -> {
|
view.optionsItemIntent
|
||||||
markRead.execute(conversations)
|
.filter { itemId -> itemId == R.id.read }
|
||||||
view.clearSelection()
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
}
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
|
markRead.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.unread -> {
|
view.optionsItemIntent
|
||||||
markUnread.execute(conversations)
|
.filter { itemId -> itemId == R.id.unread }
|
||||||
view.clearSelection()
|
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||||
}
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
|
markUnread.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
R.id.block -> {
|
view.optionsItemIntent
|
||||||
markBlocked.execute(conversations)
|
.filter { itemId -> itemId == R.id.block }
|
||||||
view.clearSelection()
|
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||||
}
|
markBlocked.execute(conversations)
|
||||||
}
|
view.clearSelection()
|
||||||
}
|
}
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|||||||
Reference in New Issue
Block a user