mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
#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
|
||||
view.optionsItemIntent
|
||||
.filter { it == R.id.delete }
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
||||
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
|
||||
view.sendIntent
|
||||
.filter {
|
||||
val hasPermission = permissionManager.hasSendSms()
|
||||
if (!hasPermission) view.requestSmsPermission()
|
||||
hasPermission
|
||||
}
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||
.filter { permissionManager.hasSendSms().also { if (!it) view.requestSmsPermission() } }
|
||||
.withLatestFrom(view.textChangedIntent) { _, body -> body }
|
||||
.map { body -> body.toString() }
|
||||
.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.MarkUnarchived
|
||||
import com.moez.QKSMS.interactor.MarkUnblocked
|
||||
import com.moez.QKSMS.manager.PermissionManager
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
@@ -46,7 +47,8 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
private val markUnarchived: MarkUnarchived,
|
||||
private val markBlocked: MarkBlocked,
|
||||
private val markUnblocked: MarkUnblocked,
|
||||
private val navigator: Navigator
|
||||
private val navigator: Navigator,
|
||||
private val permissionManager: PermissionManager
|
||||
) : QkPresenter<ConversationInfoView, ConversationInfoState>(
|
||||
ConversationInfoState(threadId = threadId, media = messageRepo.getPartsForConversation(threadId))
|
||||
) {
|
||||
@@ -151,6 +153,7 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
|
||||
// Show the delete confirmation dialog
|
||||
view.deleteClicks()
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showDeleteDialog() }
|
||||
|
||||
|
||||
@@ -206,45 +206,75 @@ class MainViewModel @Inject constructor(
|
||||
.subscribe()
|
||||
|
||||
view.optionsItemIntent
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { itemId, conversations ->
|
||||
when (itemId) {
|
||||
R.id.archive -> {
|
||||
markArchived.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.filter { itemId -> itemId == R.id.archive }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markArchived.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
R.id.unarchive -> {
|
||||
markUnarchived.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.unarchive }
|
||||
.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 -> {
|
||||
markPinned.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.pin }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markPinned.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
R.id.unpin -> {
|
||||
markUnpinned.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.unpin }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markUnpinned.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
R.id.read -> {
|
||||
markRead.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.read }
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markRead.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
R.id.unread -> {
|
||||
markUnread.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.unread }
|
||||
.filter { permissionManager.isDefaultSms().also { if (!it) navigator.showDefaultSmsDialog() } }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markUnread.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
R.id.block -> {
|
||||
markBlocked.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
}
|
||||
view.optionsItemIntent
|
||||
.filter { itemId -> itemId == R.id.block }
|
||||
.withLatestFrom(view.conversationsSelectedIntent) { _, conversations ->
|
||||
markBlocked.execute(conversations)
|
||||
view.clearSelection()
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
Reference in New Issue
Block a user