forked from upstream-mirrors/quik
Use Long for subject instead of RealmObject
This commit is contained in:
@@ -58,17 +58,6 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
private val rxPrefs: RxSharedPreferences
|
||||
) : SyncRepository {
|
||||
|
||||
/**
|
||||
* Holds data that should be persisted across full syncs
|
||||
*/
|
||||
private data class PersistedData(
|
||||
val id: Long,
|
||||
val archived: Boolean,
|
||||
val blocked: Boolean,
|
||||
val pinned: Boolean,
|
||||
val name: String
|
||||
)
|
||||
|
||||
override val syncProgress: Subject<SyncRepository.SyncProgress> =
|
||||
BehaviorSubject.createDefault(SyncRepository.SyncProgress.Idle())
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ import com.moez.QKSMS.common.util.extensions.setVisible
|
||||
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
||||
import com.moez.QKSMS.model.Attachment
|
||||
import com.moez.QKSMS.model.Contact
|
||||
import com.moez.QKSMS.model.Message
|
||||
import com.moez.QKSMS.model.MmsPart
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import dagger.android.AndroidInjection
|
||||
@@ -91,10 +89,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
||||
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||
override val sendAsGroupIntent by lazy { sendAsGroupBackground.clicks() }
|
||||
override val messageClickIntent: Subject<Message> by lazy { messageAdapter.clicks }
|
||||
override val messagePartClickIntent: Subject<MmsPart> by lazy { messageAdapter.partClicks }
|
||||
override val messageClickIntent: Subject<Long> by lazy { messageAdapter.clicks }
|
||||
override val messagePartClickIntent: Subject<Long> by lazy { messageAdapter.partClicks }
|
||||
override val messagesSelectedIntent by lazy { messageAdapter.selectionChanges }
|
||||
override val cancelSendingIntent: Subject<Message> by lazy { messageAdapter.cancelSending }
|
||||
override val cancelSendingIntent: Subject<Long> by lazy { messageAdapter.cancelSending }
|
||||
override val attachmentDeletedIntent: Subject<Attachment> by lazy { attachmentAdapter.attachmentDeleted }
|
||||
override val textChangedIntent by lazy { message.textChanges() }
|
||||
override val attachIntent by lazy { Observable.merge(attach.clicks(), attachingBackground.clicks()) }
|
||||
|
||||
@@ -24,8 +24,6 @@ import androidx.core.view.inputmethod.InputContentInfoCompat
|
||||
import com.moez.QKSMS.common.base.QkView
|
||||
import com.moez.QKSMS.model.Attachment
|
||||
import com.moez.QKSMS.model.Contact
|
||||
import com.moez.QKSMS.model.Message
|
||||
import com.moez.QKSMS.model.MmsPart
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.Subject
|
||||
|
||||
@@ -40,10 +38,10 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val menuReadyIntent: Observable<Unit>
|
||||
val optionsItemIntent: Observable<Int>
|
||||
val sendAsGroupIntent: Observable<*>
|
||||
val messageClickIntent: Subject<Message>
|
||||
val messagePartClickIntent: Subject<MmsPart>
|
||||
val messageClickIntent: Subject<Long>
|
||||
val messagePartClickIntent: Subject<Long>
|
||||
val messagesSelectedIntent: Observable<List<Long>>
|
||||
val cancelSendingIntent: Subject<Message>
|
||||
val cancelSendingIntent: Subject<Long>
|
||||
val attachmentDeletedIntent: Subject<Attachment>
|
||||
val textChangedIntent: Observable<CharSequence>
|
||||
val attachIntent: Observable<Unit>
|
||||
|
||||
@@ -420,6 +420,7 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
// Retry sending
|
||||
view.messageClickIntent
|
||||
.mapNotNull(messageRepo::getMessage)
|
||||
.filter { message -> message.isFailedMessage() }
|
||||
.doOnNext { message -> retrySending.execute(message) }
|
||||
.autoDisposable(view.scope())
|
||||
@@ -427,12 +428,14 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
// Media attachment clicks
|
||||
view.messagePartClickIntent
|
||||
.mapNotNull(messageRepo::getPart)
|
||||
.filter { part -> part.isImage() || part.isVideo() }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { part -> navigator.showMedia(part.id) }
|
||||
|
||||
// Non-media attachment clicks
|
||||
view.messagePartClickIntent
|
||||
.mapNotNull(messageRepo::getPart)
|
||||
.filter { part -> !part.isImage() && !part.isVideo() }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { part ->
|
||||
@@ -451,6 +454,7 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
// Cancel sending a message
|
||||
view.cancelSendingIntent
|
||||
.mapNotNull(messageRepo::getMessage)
|
||||
.doOnNext { message -> view.setDraft(message.getText()) }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { message -> cancelMessage.execute(message.id) }
|
||||
|
||||
@@ -53,7 +53,6 @@ import com.moez.QKSMS.feature.compose.BubbleUtils.getBubble
|
||||
import com.moez.QKSMS.feature.compose.part.PartsAdapter
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
import com.moez.QKSMS.model.Message
|
||||
import com.moez.QKSMS.model.MmsPart
|
||||
import com.moez.QKSMS.model.Recipient
|
||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||
import com.moez.QKSMS.util.Preferences
|
||||
@@ -88,9 +87,9 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
}
|
||||
|
||||
val clicks: Subject<Message> = PublishSubject.create()
|
||||
val partClicks: Subject<MmsPart> = PublishSubject.create()
|
||||
val cancelSending: Subject<Message> = PublishSubject.create()
|
||||
val clicks: Subject<Long> = PublishSubject.create()
|
||||
val partClicks: Subject<Long> = PublishSubject.create()
|
||||
val cancelSending: Subject<Long> = PublishSubject.create()
|
||||
|
||||
var data: Pair<Conversation, RealmResults<Message>>? = null
|
||||
set(value) {
|
||||
@@ -167,7 +166,7 @@ class MessagesAdapter @Inject constructor(
|
||||
when (toggleSelection(message.id, false)) {
|
||||
true -> view.isActivated = isSelected(message.id)
|
||||
false -> {
|
||||
clicks.onNext(message)
|
||||
clicks.onNext(message.id)
|
||||
expanded[message.id] = view.status.visibility != View.VISIBLE
|
||||
notifyItemChanged(adapterPosition)
|
||||
}
|
||||
@@ -195,7 +194,7 @@ class MessagesAdapter @Inject constructor(
|
||||
view.findViewById<ProgressBar>(R.id.cancel)?.let { cancel ->
|
||||
val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
|
||||
cancel.setVisible(isCancellable)
|
||||
cancel.clicks().subscribe { cancelSending.onNext(message) }
|
||||
cancel.clicks().subscribe { cancelSending.onNext(message.id) }
|
||||
cancel.progress = 2
|
||||
|
||||
if (isCancellable) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class FileBinder @Inject constructor(colors: Colors, private val context: Contex
|
||||
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
||||
.let(view.fileBackground::setBackgroundResource)
|
||||
|
||||
view.setOnClickListener { clicks.onNext(part) }
|
||||
view.setOnClickListener { clicks.onNext(part.id) }
|
||||
|
||||
Observable.just(part.getUri())
|
||||
.map(context.contentResolver::openInputStream)
|
||||
|
||||
@@ -47,7 +47,7 @@ class MediaBinder @Inject constructor(colors: Colors, private val context: Conte
|
||||
canGroupWithNext: Boolean
|
||||
) {
|
||||
view.video.setVisible(part.isVideo())
|
||||
view.setOnClickListener { clicks.onNext(part) }
|
||||
view.setOnClickListener { clicks.onNext(part.id) }
|
||||
|
||||
view.thumbnail.bubbleStyle = when {
|
||||
!canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.reactivex.subjects.Subject
|
||||
|
||||
abstract class PartBinder {
|
||||
|
||||
val clicks: Subject<MmsPart> = PublishSubject.create()
|
||||
val clicks: Subject<Long> = PublishSubject.create()
|
||||
|
||||
abstract val partLayout: Int
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class PartsAdapter @Inject constructor(
|
||||
partBinders.forEach { binder -> binder.theme = value }
|
||||
}
|
||||
|
||||
val clicks = Observable.merge(partBinders.map { it.clicks })
|
||||
val clicks: Observable<Long> = Observable.merge(partBinders.map { it.clicks })
|
||||
|
||||
private lateinit var message: Message
|
||||
private var previous: Message? = null
|
||||
|
||||
@@ -56,7 +56,7 @@ class VCardBinder @Inject constructor(colors: Colors, private val context: Conte
|
||||
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
||||
.let(view.vCardBackground::setBackgroundResource)
|
||||
|
||||
view.setOnClickListener { clicks.onNext(part) }
|
||||
view.setOnClickListener { clicks.onNext(part.id) }
|
||||
|
||||
Observable.just(part.getUri())
|
||||
.map(context.contentResolver::openInputStream)
|
||||
|
||||
-2
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package com.moez.QKSMS.feature.conversationinfo
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkPresenter
|
||||
@@ -46,7 +45,6 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
@Named("threadId") threadId: Long,
|
||||
messageRepo: MessageRepository,
|
||||
private val contactAddedListener: ContactAddedListener,
|
||||
private val context: Context,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val deleteConversations: DeleteConversations,
|
||||
private val markArchived: MarkArchived,
|
||||
|
||||
Reference in New Issue
Block a user