forked from upstream-mirrors/quik
Add option to call or view conversation from qkreply
This commit is contained in:
@@ -23,6 +23,7 @@ import android.telephony.SmsMessage
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
import common.base.QkViewModel
|
||||
import injection.appComponent
|
||||
import interactor.MarkRead
|
||||
@@ -33,6 +34,7 @@ import io.reactivex.schedulers.Schedulers
|
||||
import model.Conversation
|
||||
import repository.MessageRepository
|
||||
import util.extensions.asObservable
|
||||
import util.extensions.mapNotNull
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -40,6 +42,7 @@ class QkReplyViewModel(intent: Intent) : QkViewModel<QkReplyView, QkReplyState>(
|
||||
|
||||
@Inject lateinit var markRead: MarkRead
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@Inject lateinit var sendMessage: SendMessage
|
||||
|
||||
private val conversation by lazy {
|
||||
@@ -74,6 +77,15 @@ class QkReplyViewModel(intent: Intent) : QkViewModel<QkReplyView, QkReplyState>(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { threadId -> markRead.execute(threadId) { view.finish() } }
|
||||
|
||||
// Call
|
||||
view.menuItemIntent
|
||||
.filter { id -> id == R.id.call }
|
||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||
.mapNotNull { conversation -> conversation.recipients.first()?.address }
|
||||
.doOnNext { address -> navigator.makePhoneCall(address) }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.finish() }
|
||||
|
||||
// Show all messages
|
||||
view.menuItemIntent
|
||||
.filter { id -> id == R.id.expand }
|
||||
@@ -90,6 +102,15 @@ class QkReplyViewModel(intent: Intent) : QkViewModel<QkReplyView, QkReplyState>(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { data -> newState { it.copy(expanded = false, data = data) } }
|
||||
|
||||
// View conversation
|
||||
view.menuItemIntent
|
||||
.filter { id -> id == R.id.view }
|
||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||
.mapNotNull { conversation -> conversation.id }
|
||||
.doOnNext { threadId -> navigator.showConversation(threadId) }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.finish() }
|
||||
|
||||
// Enable the send button when there is text input into the new message body or there's
|
||||
// an attachment, disable otherwise
|
||||
view.textChangedIntent
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
android:title="@string/qkreply_menu_read"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/call"
|
||||
android:title="@string/qkreply_menu_call" />
|
||||
|
||||
<item
|
||||
android:id="@+id/expand"
|
||||
android:title="@string/qkreply_menu_expand" />
|
||||
@@ -34,4 +38,8 @@
|
||||
android:title="@string/qkreply_menu_collapse"
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/view"
|
||||
android:title="@string/qkreply_menu_view" />
|
||||
|
||||
</menu>
|
||||
@@ -141,8 +141,10 @@
|
||||
<string name="widget_more">View more conversations</string>
|
||||
|
||||
<string name="qkreply_menu_read">Mark read</string>
|
||||
<string name="qkreply_menu_call">Call</string>
|
||||
<string name="qkreply_menu_expand">Show more</string>
|
||||
<string name="qkreply_menu_collapse">Show less</string>
|
||||
<string name="qkreply_menu_view">Open conversation</string>
|
||||
|
||||
<string name="theme_material">Material</string>
|
||||
<string name="theme_plus">QKSMS+</string>
|
||||
|
||||
Reference in New Issue
Block a user