forked from upstream-mirrors/quik
+3
-1
@@ -90,7 +90,9 @@ class ConversationInfoController(
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun contactClicks(): Observable<Long> = recipientAdapter.contactClicks
|
||||
override fun recipientClicks(): Observable<Long> = recipientAdapter.recipientClicks
|
||||
|
||||
override fun recipientLongClicks(): Observable<Long> = recipientAdapter.recipientLongClicks
|
||||
|
||||
override fun themeClicks(): Observable<Long> = recipientAdapter.themeClicks
|
||||
|
||||
|
||||
+18
-1
@@ -18,9 +18,13 @@
|
||||
*/
|
||||
package com.moez.QKSMS.feature.conversationinfo
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkPresenter
|
||||
import com.moez.QKSMS.common.util.ClipboardUtils
|
||||
import com.moez.QKSMS.common.util.extensions.makeToast
|
||||
import com.moez.QKSMS.extensions.asObservable
|
||||
import com.moez.QKSMS.extensions.mapNotNull
|
||||
import com.moez.QKSMS.interactor.DeleteConversations
|
||||
@@ -32,6 +36,7 @@ import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
@@ -42,6 +47,7 @@ import javax.inject.Named
|
||||
class ConversationInfoPresenter @Inject constructor(
|
||||
@Named("threadId") threadId: Long,
|
||||
messageRepo: MessageRepository,
|
||||
private val context: Context,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val deleteConversations: DeleteConversations,
|
||||
private val markArchived: MarkArchived,
|
||||
@@ -100,7 +106,7 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
super.bindIntents(view)
|
||||
|
||||
// Add or display the contact
|
||||
view.contactClicks()
|
||||
view.recipientClicks()
|
||||
.mapNotNull(conversationRepo::getRecipient)
|
||||
.doOnNext { recipient ->
|
||||
recipient.contact?.lookupKey?.let(navigator::showContact)
|
||||
@@ -109,6 +115,17 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
.autoDisposable(view.scope(Lifecycle.Event.ON_DESTROY)) // ... this should be the default
|
||||
.subscribe()
|
||||
|
||||
// Copy phone number
|
||||
view.recipientLongClicks()
|
||||
.mapNotNull(conversationRepo::getRecipient)
|
||||
.map { recipient -> recipient.address }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { address ->
|
||||
ClipboardUtils.copy(context, address)
|
||||
context.makeToast(R.string.info_copied_address)
|
||||
}
|
||||
|
||||
// Show the theme settings for the conversation
|
||||
view.themeClicks()
|
||||
.autoDisposable(view.scope())
|
||||
|
||||
+2
-1
@@ -23,7 +23,8 @@ import io.reactivex.Observable
|
||||
|
||||
interface ConversationInfoView : QkViewContract<ConversationInfoState> {
|
||||
|
||||
fun contactClicks(): Observable<Long>
|
||||
fun recipientClicks(): Observable<Long>
|
||||
fun recipientLongClicks(): Observable<Long>
|
||||
fun themeClicks(): Observable<Long>
|
||||
fun nameClicks(): Observable<*>
|
||||
fun nameChanges(): Observable<String>
|
||||
|
||||
+9
-2
@@ -36,7 +36,8 @@ class ConversationRecipientAdapter @Inject constructor(
|
||||
private val colors: Colors
|
||||
) : QkRealmAdapter<Recipient>() {
|
||||
|
||||
val contactClicks: Subject<Long> = PublishSubject.create()
|
||||
val recipientClicks: Subject<Long> = PublishSubject.create()
|
||||
val recipientLongClicks: Subject<Long> = PublishSubject.create()
|
||||
val themeClicks: Subject<Long> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
@@ -45,7 +46,13 @@ class ConversationRecipientAdapter @Inject constructor(
|
||||
return QkViewHolder(view).apply {
|
||||
view.setOnClickListener {
|
||||
val recipient = getItem(adapterPosition) ?: return@setOnClickListener
|
||||
contactClicks.onNext(recipient.id)
|
||||
recipientClicks.onNext(recipient.id)
|
||||
}
|
||||
|
||||
view.setOnLongClickListener {
|
||||
val recipient = getItem(adapterPosition) ?: return@setOnLongClickListener false
|
||||
recipientLongClicks.onNext(recipient.id)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
view.theme.setOnClickListener {
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
<string name="message_status_failed">Failed to send. Tap to try again</string>
|
||||
|
||||
<string name="info_title">Details</string>
|
||||
<string name="info_copied_address">Address copied</string>
|
||||
<string name="info_name">Conversation title</string>
|
||||
<string name="info_notifications">Notifications</string>
|
||||
<string name="info_theme">Theme</string>
|
||||
|
||||
Reference in New Issue
Block a user