forked from upstream-mirrors/quik
Fix theme color for conversation avatars
This commit is contained in:
@@ -43,6 +43,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value can be changes if we should use the theme from a particular conversation
|
||||||
|
*/
|
||||||
|
var threadId: Long = 0
|
||||||
|
|
||||||
var contact: Contact? = null
|
var contact: Contact? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@@ -64,7 +69,7 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
|
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
colors.theme
|
colors.themeForConversation(threadId)
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
.subscribe { color -> background.setTint(color) }
|
.subscribe { color -> background.setTint(color) }
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
?: Contact(numbers = RealmList(PhoneNumber(address = address))) // Fallback to a fake contact
|
?: Contact(numbers = RealmList(PhoneNumber(address = address))) // Fallback to a fake contact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.avatar.threadId = data?.first?.id ?: 0
|
||||||
view.avatar.contact = contactMap[address]
|
view.avatar.contact = contactMap[address]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class ConversationInfoActivity : QkThemedActivity<ConversationInfoViewModel>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipientAdapter.data = state.recipients
|
recipientAdapter.data = state.recipients
|
||||||
|
recipientAdapter.threadId = state.threadId
|
||||||
|
|
||||||
notifications.setVisible(!state.blocked)
|
notifications.setVisible(!state.blocked)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import data.model.Recipient
|
|||||||
|
|
||||||
data class ConversationInfoState(
|
data class ConversationInfoState(
|
||||||
val recipients: List<Recipient> = listOf(),
|
val recipients: List<Recipient> = listOf(),
|
||||||
|
val threadId: Long = 0,
|
||||||
val archived: Boolean = false,
|
val archived: Boolean = false,
|
||||||
val blocked: Boolean = false,
|
val blocked: Boolean = false,
|
||||||
val media: List<MmsPart> = ArrayList(),
|
val media: List<MmsPart> = ArrayList(),
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
val threadId = intent.extras?.getLong("threadId") ?: 0L
|
val threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||||
|
|
||||||
|
newState { it.copy(threadId = threadId) }
|
||||||
|
|
||||||
conversation = messageRepo.getConversationAsync(threadId)
|
conversation = messageRepo.getConversationAsync(threadId)
|
||||||
.asObservable<Conversation>()
|
.asObservable<Conversation>()
|
||||||
.filter { conversation -> conversation.isLoaded }
|
.filter { conversation -> conversation.isLoaded }
|
||||||
|
|||||||
+3
@@ -41,6 +41,8 @@ class ConversationRecipientAdapter @Inject constructor(
|
|||||||
private val navigator: Navigator
|
private val navigator: Navigator
|
||||||
) : QkAdapter<Recipient>() {
|
) : QkAdapter<Recipient>() {
|
||||||
|
|
||||||
|
var threadId: Long = 0L
|
||||||
|
|
||||||
private val disposables = CompositeDisposable()
|
private val disposables = CompositeDisposable()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
@@ -65,6 +67,7 @@ class ConversationRecipientAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.avatar.threadId = threadId
|
||||||
view.avatar.contact = recipient.contact
|
view.avatar.contact = recipient.contact
|
||||||
|
|
||||||
view.name.text = recipient.contact?.name ?: recipient.address
|
view.name.text = recipient.contact?.name ?: recipient.address
|
||||||
|
|||||||
Reference in New Issue
Block a user