forked from upstream-mirrors/quik
Move conversation menu options to ConversationInfoActivity
This commit is contained in:
@@ -62,8 +62,7 @@ class ComposeActivity : QkThemedActivity<ComposeViewModel>(), ComposeView {
|
||||
override val chipDeletedIntent: Subject<Contact> by lazy { chipsAdapter.chipDeleted }
|
||||
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
||||
override val callIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val archiveIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val deleteIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val infoIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val copyTextIntent: Subject<Message> = PublishSubject.create()
|
||||
override val forwardMessageIntent: Subject<Message> = PublishSubject.create()
|
||||
override val deleteMessageIntent: Subject<Message> = PublishSubject.create()
|
||||
@@ -194,18 +193,8 @@ class ComposeActivity : QkThemedActivity<ComposeViewModel>(), ComposeView {
|
||||
if (state.editingMode && chips.adapter == null) chips.adapter = chipsAdapter
|
||||
if (state.editingMode && contacts.adapter == null) contacts.adapter = contactsAdapter
|
||||
|
||||
toolbar.menu.findItem(R.id.call)?.run {
|
||||
isVisible = !state.editingMode
|
||||
}
|
||||
|
||||
toolbar.menu.findItem(R.id.archive)?.run {
|
||||
isVisible = !state.editingMode
|
||||
setTitle(if (state.archived) R.string.menu_unarchive else R.string.menu_archive)
|
||||
}
|
||||
|
||||
toolbar.menu.findItem(R.id.delete)?.run {
|
||||
isVisible = !state.editingMode
|
||||
}
|
||||
toolbar.menu.findItem(R.id.call)?.isVisible = !state.editingMode
|
||||
toolbar.menu.findItem(R.id.info)?.isVisible = !state.editingMode
|
||||
|
||||
if (chipsAdapter.data.isEmpty() && state.selectedContacts.isNotEmpty()) {
|
||||
message.showKeyboard()
|
||||
@@ -246,8 +235,7 @@ class ComposeActivity : QkThemedActivity<ComposeViewModel>(), ComposeView {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.call -> callIntent.onNext(Unit)
|
||||
R.id.archive -> archiveIntent.onNext(Unit)
|
||||
R.id.delete -> deleteIntent.onNext(Unit)
|
||||
R.id.info -> infoIntent.onNext(Unit)
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val chipDeletedIntent: Subject<Contact>
|
||||
val menuReadyIntent: Observable<Unit>
|
||||
val callIntent: Subject<Unit>
|
||||
val archiveIntent: Subject<Unit>
|
||||
val deleteIntent: Subject<Unit>
|
||||
val infoIntent: Subject<Unit>
|
||||
val copyTextIntent: Subject<Message>
|
||||
val forwardMessageIntent: Subject<Message>
|
||||
val deleteMessageIntent: Subject<Message>
|
||||
|
||||
@@ -64,9 +64,6 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@Inject lateinit var syncContacts: ContactSync
|
||||
@Inject lateinit var markArchived: MarkArchived
|
||||
@Inject lateinit var markUnarchived: MarkUnarchived
|
||||
@Inject lateinit var deleteConversation: DeleteConversation
|
||||
@Inject lateinit var sendMessage: SendMessage
|
||||
@Inject lateinit var retrySending: RetrySending
|
||||
@Inject lateinit var markRead: MarkRead
|
||||
@@ -159,9 +156,6 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
||||
|
||||
disposables += sendMessage
|
||||
disposables += markRead
|
||||
disposables += markArchived
|
||||
disposables += markUnarchived
|
||||
disposables += deleteConversation
|
||||
disposables += conversation.subscribe()
|
||||
disposables += messages.subscribe()
|
||||
disposables += attachments.subscribe { attachments -> newState { it.copy(attachments = attachments) } }
|
||||
@@ -269,22 +263,11 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { address -> navigator.makePhoneCall(address) }
|
||||
|
||||
// Toggle the archived state of the conversation
|
||||
view.archiveIntent
|
||||
// Open the conversation settings if info button is clicked
|
||||
view.infoIntent
|
||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation ->
|
||||
when (conversation.archived) {
|
||||
true -> markUnarchived.execute(conversation.id, { context.makeToast(R.string.toast_unarchived) })
|
||||
false -> markArchived.execute(conversation.id, { context.makeToast(R.string.toast_archived) })
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the conversation
|
||||
view.deleteIntent
|
||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation -> deleteConversation.execute(conversation.id) }
|
||||
.subscribe { conversation -> navigator.showConversationInfo(conversation.id) }
|
||||
|
||||
view.messageClickIntent
|
||||
.filter { message -> message.isFailedMessage() }
|
||||
|
||||
Reference in New Issue
Block a user