forked from upstream-mirrors/quik
+1
-1
@@ -73,7 +73,7 @@ class BlockedMessagesAdapter @Inject constructor(
|
||||
|
||||
view.isActivated = isSelected(conversation.id)
|
||||
|
||||
view.avatars.contacts = conversation.recipients
|
||||
view.avatars.recipients = conversation.recipients
|
||||
view.title.collapseEnabled = conversation.recipients.size > 1
|
||||
view.title.text = conversation.getTitle()
|
||||
view.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
||||
|
||||
@@ -150,6 +150,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
.doOnNext { attach.setBackgroundTint(it.theme) }
|
||||
.doOnNext { attach.setTint(it.textPrimary) }
|
||||
.doOnNext { messageAdapter.theme = it }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
allThemes
|
||||
.autoDisposable(scope())
|
||||
.subscribe { messageList.scrapViews() }
|
||||
|
||||
@@ -177,7 +181,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
return
|
||||
}
|
||||
|
||||
threadId.onNext(state.selectedConversation)
|
||||
threadId.onNext(state.threadId)
|
||||
|
||||
title = when {
|
||||
state.selectedMessages > 0 -> getString(R.string.compose_title_selected, state.selectedMessages)
|
||||
|
||||
@@ -28,7 +28,7 @@ import io.realm.RealmResults
|
||||
data class ComposeState(
|
||||
val hasError: Boolean = false,
|
||||
val editingMode: Boolean = false,
|
||||
val selectedConversation: Long = 0,
|
||||
val threadId: Long = 0,
|
||||
val selectedChips: List<Chip> = ArrayList(),
|
||||
val sendAsGroup: Boolean = true,
|
||||
val conversationtitle: String = "",
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkViewModel
|
||||
import com.moez.QKSMS.common.util.BillingManager
|
||||
import com.moez.QKSMS.common.util.ClipboardUtils
|
||||
import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.MessageDetailsFormatter
|
||||
import com.moez.QKSMS.common.util.extensions.makeToast
|
||||
import com.moez.QKSMS.compat.SubscriptionManagerCompat
|
||||
@@ -77,6 +78,7 @@ class ComposeViewModel @Inject constructor(
|
||||
@Named("addresses") private val addresses: List<String>,
|
||||
@Named("text") private val sharedText: String,
|
||||
@Named("attachments") private val sharedAttachments: Attachments,
|
||||
private val colors: Colors,
|
||||
private val contactRepo: ContactRepository,
|
||||
private val context: Context,
|
||||
private val activeConversationManager: ActiveConversationManager,
|
||||
@@ -97,7 +99,7 @@ class ComposeViewModel @Inject constructor(
|
||||
private val subscriptionManager: SubscriptionManagerCompat
|
||||
) : QkViewModel<ComposeView, ComposeState>(ComposeState(
|
||||
editingMode = threadId == 0L && addresses.isEmpty(),
|
||||
selectedConversation = threadId,
|
||||
threadId = threadId,
|
||||
query = query)
|
||||
) {
|
||||
|
||||
@@ -171,13 +173,13 @@ class ComposeViewModel @Inject constructor(
|
||||
.takeUntil(state.filter { state -> !state.editingMode })
|
||||
.subscribe(selectedChips::onNext)
|
||||
|
||||
// When the conversation changes, mark read, and update the threadId and the messages for the adapter
|
||||
// When the conversation changes, mark read, and update the recipientId and the messages for the adapter
|
||||
disposables += conversation
|
||||
.distinctUntilChanged { conversation -> conversation.id }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { conversation ->
|
||||
val messages = messageRepo.getMessages(conversation.id)
|
||||
newState { copy(selectedConversation = conversation.id, messages = Pair(conversation, messages)) }
|
||||
newState { copy(threadId = conversation.id, messages = Pair(conversation, messages)) }
|
||||
messages
|
||||
}
|
||||
.switchMap { messages -> messages.asObservable() }
|
||||
|
||||
@@ -98,9 +98,6 @@ class MessagesAdapter @Inject constructor(
|
||||
field = value
|
||||
contactCache.clear()
|
||||
|
||||
// Update the theme
|
||||
theme = colors.theme(value?.first?.id ?: 0)
|
||||
|
||||
updateData(value?.second)
|
||||
}
|
||||
|
||||
@@ -145,9 +142,6 @@ class MessagesAdapter @Inject constructor(
|
||||
view.findViewById<ProgressBar>(R.id.cancel).setTint(theme.theme)
|
||||
} else {
|
||||
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
|
||||
view.avatar.threadId = conversation?.id ?: 0
|
||||
view.body.setTextColor(theme.textPrimary)
|
||||
view.body.setBackgroundTint(theme.theme)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@@ -187,6 +181,11 @@ class MessagesAdapter @Inject constructor(
|
||||
val next = if (position == itemCount - 1) null else getItem(position + 1)
|
||||
val view = viewHolder.containerView
|
||||
|
||||
val theme = when (message.isOutgoingMessage()) {
|
||||
true -> colors.theme()
|
||||
false -> colors.theme(contactCache[message.address]?.id ?: 0)
|
||||
}
|
||||
|
||||
// Update the selected state
|
||||
view.isActivated = isSelected(message.id) || highlight == message.id
|
||||
|
||||
@@ -231,11 +230,14 @@ class MessagesAdapter @Inject constructor(
|
||||
val media = message.parts.filter { !it.isSmil() && !it.isText() }
|
||||
view.setPadding(bottom = if (canGroup(message, next)) 0 else 16.dpToPx(context))
|
||||
|
||||
// Bind the avatar
|
||||
// Bind the avatar and bubble colour
|
||||
if (!message.isMe()) {
|
||||
view.avatar.threadId = conversation?.id ?: 0
|
||||
view.avatar.recipientId = contactCache[message.address]?.id ?: 0
|
||||
view.avatar.setContact(contactCache[message.address]?.contact)
|
||||
view.avatar.setVisible(!canGroup(message, next), View.INVISIBLE)
|
||||
|
||||
view.body.setTextColor(theme.textPrimary)
|
||||
view.body.setBackgroundTint(theme.theme)
|
||||
}
|
||||
|
||||
// Bind the body text
|
||||
|
||||
+5
-5
@@ -87,7 +87,7 @@ class ComposeItemAdapter @Inject constructor(private val colors: Colors) : QkAda
|
||||
|
||||
view.icon.isVisible = false
|
||||
|
||||
view.avatar.contacts = listOf(Recipient(contact = contact))
|
||||
view.avatar.recipients = listOf(Recipient(contact = contact))
|
||||
|
||||
view.title.text = contact.numbers.joinToString { it.address }
|
||||
|
||||
@@ -102,7 +102,7 @@ class ComposeItemAdapter @Inject constructor(private val colors: Colors) : QkAda
|
||||
view.icon.isVisible = prev !is ComposeItem.Recent
|
||||
view.icon.setImageResource(R.drawable.ic_history_black_24dp)
|
||||
|
||||
view.avatar.contacts = conversation.recipients
|
||||
view.avatar.recipients = conversation.recipients
|
||||
|
||||
view.title.text = conversation.getTitle()
|
||||
|
||||
@@ -123,7 +123,7 @@ class ComposeItemAdapter @Inject constructor(private val colors: Colors) : QkAda
|
||||
view.icon.isVisible = prev !is ComposeItem.Starred
|
||||
view.icon.setImageResource(R.drawable.ic_star_black_24dp)
|
||||
|
||||
view.avatar.contacts = listOf(Recipient(contact = contact))
|
||||
view.avatar.recipients = listOf(Recipient(contact = contact))
|
||||
|
||||
view.title.text = contact.name
|
||||
|
||||
@@ -139,7 +139,7 @@ class ComposeItemAdapter @Inject constructor(private val colors: Colors) : QkAda
|
||||
view.icon.isVisible = prev !is ComposeItem.Group
|
||||
view.icon.setImageResource(R.drawable.ic_people_black_24dp)
|
||||
|
||||
view.avatar.contacts = group.contacts.map { contact -> Recipient(contact = contact) }
|
||||
view.avatar.recipients = group.contacts.map { contact -> Recipient(contact = contact) }
|
||||
|
||||
view.title.text = group.title
|
||||
|
||||
@@ -158,7 +158,7 @@ class ComposeItemAdapter @Inject constructor(private val colors: Colors) : QkAda
|
||||
|
||||
view.icon.isVisible = false
|
||||
|
||||
view.avatar.contacts = listOf(Recipient(contact = contact))
|
||||
view.avatar.recipients = listOf(Recipient(contact = contact))
|
||||
|
||||
view.title.text = contact.name
|
||||
|
||||
|
||||
+7
-12
@@ -78,10 +78,9 @@ class ConversationInfoController(
|
||||
media.adapter = mediaAdapter
|
||||
media.addItemDecoration(itemDecoration)
|
||||
|
||||
themedActivity
|
||||
?.theme
|
||||
themedActivity?.theme
|
||||
?.autoDisposable(scope())
|
||||
?.subscribe { recipients?.scrapViews() }
|
||||
?.subscribe { recipients.scrapViews() }
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
@@ -91,7 +90,9 @@ class ConversationInfoController(
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun recipientClicks(): Observable<Long> = recipientAdapter.clicks
|
||||
override fun contactClicks(): Observable<Long> = recipientAdapter.contactClicks
|
||||
|
||||
override fun themeClicks(): Observable<Long> = recipientAdapter.themeClicks
|
||||
|
||||
override fun nameClicks(): Observable<*> = name.clicks()
|
||||
|
||||
@@ -99,8 +100,6 @@ class ConversationInfoController(
|
||||
|
||||
override fun notificationClicks(): Observable<*> = notifications.clicks()
|
||||
|
||||
override fun themeClicks(): Observable<*> = themePrefs.clicks()
|
||||
|
||||
override fun archiveClicks(): Observable<*> = archive.clicks()
|
||||
|
||||
override fun blockClicks(): Observable<*> = block.clicks()
|
||||
@@ -115,8 +114,6 @@ class ConversationInfoController(
|
||||
return
|
||||
}
|
||||
|
||||
themedActivity?.threadId?.onNext(state.threadId)
|
||||
recipientAdapter.threadId = state.threadId
|
||||
recipientAdapter.updateData(state.recipients)
|
||||
|
||||
name.setVisible(state.recipients?.size ?: 0 >= 2)
|
||||
@@ -124,8 +121,6 @@ class ConversationInfoController(
|
||||
|
||||
notifications.isEnabled = !state.blocked
|
||||
|
||||
themePrefs.isEnabled = !state.blocked
|
||||
|
||||
archive.isEnabled = !state.blocked
|
||||
archive.title = activity?.getString(when (state.archived) {
|
||||
true -> R.string.info_unarchive
|
||||
@@ -142,8 +137,8 @@ class ConversationInfoController(
|
||||
|
||||
override fun showNameDialog(name: String) = nameDialog.setText(name).show()
|
||||
|
||||
override fun showThemePicker(threadId: Long) {
|
||||
router.pushController(RouterTransaction.with(ThemePickerController(threadId))
|
||||
override fun showThemePicker(recipientId: Long) {
|
||||
router.pushController(RouterTransaction.with(ThemePickerController(recipientId))
|
||||
.pushChangeHandler(QkChangeHandler())
|
||||
.popChangeHandler(QkChangeHandler()))
|
||||
}
|
||||
|
||||
+6
-7
@@ -100,7 +100,7 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
super.bindIntents(view)
|
||||
|
||||
// Add or display the contact
|
||||
view.recipientClicks()
|
||||
view.contactClicks()
|
||||
.mapNotNull(conversationRepo::getRecipient)
|
||||
.doOnNext { recipient ->
|
||||
recipient.contact?.lookupKey?.let(navigator::showContact)
|
||||
@@ -109,6 +109,11 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
.autoDisposable(view.scope(Lifecycle.Event.ON_DESTROY)) // ... this should be the default
|
||||
.subscribe()
|
||||
|
||||
// Show the theme settings for the conversation
|
||||
view.themeClicks()
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe(view::showThemePicker)
|
||||
|
||||
// Show the conversation title dialog
|
||||
view.nameClicks()
|
||||
.withLatestFrom(conversation) { _, conversation -> conversation }
|
||||
@@ -130,12 +135,6 @@ class ConversationInfoPresenter @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation -> navigator.showNotificationSettings(conversation.id) }
|
||||
|
||||
// Show the theme settings for the conversation
|
||||
view.themeClicks()
|
||||
.withLatestFrom(conversation) { _, conversation -> conversation }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation -> view.showThemePicker(conversation.id) }
|
||||
|
||||
// Toggle the archived state of the conversation
|
||||
view.archiveClicks()
|
||||
.withLatestFrom(conversation) { _, conversation -> conversation }
|
||||
|
||||
+3
-3
@@ -23,18 +23,18 @@ import io.reactivex.Observable
|
||||
|
||||
interface ConversationInfoView : QkViewContract<ConversationInfoState> {
|
||||
|
||||
fun recipientClicks(): Observable<Long>
|
||||
fun contactClicks(): Observable<Long>
|
||||
fun themeClicks(): Observable<Long>
|
||||
fun nameClicks(): Observable<*>
|
||||
fun nameChanges(): Observable<String>
|
||||
fun notificationClicks(): Observable<*>
|
||||
fun themeClicks(): Observable<*>
|
||||
fun archiveClicks(): Observable<*>
|
||||
fun blockClicks(): Observable<*>
|
||||
fun deleteClicks(): Observable<*>
|
||||
fun confirmDelete(): Observable<*>
|
||||
|
||||
fun showNameDialog(name: String)
|
||||
fun showThemePicker(threadId: Long)
|
||||
fun showThemePicker(recipientId: Long)
|
||||
fun showBlockingDialog(conversations: List<Long>, block: Boolean)
|
||||
fun requestDefaultSms()
|
||||
fun showDeleteDialog()
|
||||
|
||||
+16
-13
@@ -20,24 +20,24 @@ package com.moez.QKSMS.feature.conversationinfo
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.base.QkRealmAdapter
|
||||
import com.moez.QKSMS.common.base.QkViewHolder
|
||||
import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||
import com.moez.QKSMS.model.Recipient
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.conversation_recipient_list_item.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ConversationRecipientAdapter @Inject constructor() : QkRealmAdapter<Recipient>() {
|
||||
class ConversationRecipientAdapter @Inject constructor(
|
||||
private val colors: Colors
|
||||
) : QkRealmAdapter<Recipient>() {
|
||||
|
||||
var threadId: Long = 0L
|
||||
val clicks: Subject<Long> = PublishSubject.create()
|
||||
|
||||
private val disposables = CompositeDisposable()
|
||||
val contactClicks: Subject<Long> = PublishSubject.create()
|
||||
val themeClicks: Subject<Long> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
@@ -45,7 +45,12 @@ class ConversationRecipientAdapter @Inject constructor() : QkRealmAdapter<Recipi
|
||||
return QkViewHolder(view).apply {
|
||||
view.setOnClickListener {
|
||||
val recipient = getItem(adapterPosition) ?: return@setOnClickListener
|
||||
clicks.onNext(recipient.id)
|
||||
contactClicks.onNext(recipient.id)
|
||||
}
|
||||
|
||||
view.theme.setOnClickListener {
|
||||
val recipient = getItem(adapterPosition) ?: return@setOnClickListener
|
||||
themeClicks.onNext(recipient.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +59,7 @@ class ConversationRecipientAdapter @Inject constructor() : QkRealmAdapter<Recipi
|
||||
val recipient = getItem(position) ?: return
|
||||
val view = holder.containerView
|
||||
|
||||
view.avatar.threadId = threadId
|
||||
view.avatar.recipientId = recipient.id
|
||||
view.avatar.setContact(recipient.contact)
|
||||
|
||||
view.name.text = recipient.contact?.name ?: recipient.address
|
||||
@@ -63,11 +68,9 @@ class ConversationRecipientAdapter @Inject constructor() : QkRealmAdapter<Recipi
|
||||
view.address.setVisible(recipient.contact != null)
|
||||
|
||||
view.add.setVisible(recipient.contact == null)
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView)
|
||||
disposables.clear()
|
||||
val theme = colors.theme(recipient.id)
|
||||
view.theme.setTint(theme.theme)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-4
@@ -32,6 +32,7 @@ import com.moez.QKSMS.common.util.DateFormatter
|
||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||
import kotlinx.android.synthetic.main.conversation_list_item.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -39,7 +40,8 @@ class ConversationsAdapter @Inject constructor(
|
||||
private val colors: Colors,
|
||||
private val context: Context,
|
||||
private val dateFormatter: DateFormatter,
|
||||
private val navigator: Navigator
|
||||
private val navigator: Navigator,
|
||||
private val phoneNumberUtils: PhoneNumberUtils
|
||||
) : QkRealmAdapter<Conversation>() {
|
||||
|
||||
init {
|
||||
@@ -60,7 +62,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
view.snippet.maxLines = 5
|
||||
|
||||
view.unread.isVisible = true
|
||||
view.unread.setTint(colors.theme().theme)
|
||||
|
||||
view.date.setTypeface(view.date.typeface, Typeface.BOLD)
|
||||
view.date.setTextColor(textColorPrimary)
|
||||
@@ -85,11 +86,12 @@ class ConversationsAdapter @Inject constructor(
|
||||
|
||||
override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) {
|
||||
val conversation = getItem(position) ?: return
|
||||
val lastMessage = conversation.lastMessage ?: return
|
||||
val view = viewHolder.containerView
|
||||
|
||||
view.isActivated = isSelected(conversation.id)
|
||||
|
||||
view.avatars.contacts = conversation.recipients
|
||||
view.avatars.recipients = conversation.recipients
|
||||
view.title.collapseEnabled = conversation.recipients.size > 1
|
||||
view.title.text = conversation.getTitle()
|
||||
view.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
||||
@@ -99,6 +101,16 @@ class ConversationsAdapter @Inject constructor(
|
||||
else -> conversation.snippet
|
||||
}
|
||||
view.pinned.isVisible = conversation.pinned
|
||||
|
||||
// If the last message wasn't incoming, then the colour doesn't really matter anyway
|
||||
val recipient = when (conversation.recipients.size) {
|
||||
1 -> conversation.recipients.firstOrNull()
|
||||
else -> conversation.recipients.find { recipient ->
|
||||
phoneNumberUtils.compare(recipient.address, lastMessage.address)
|
||||
}
|
||||
}
|
||||
|
||||
view.unread.setTint(colors.theme(recipient?.id ?: 0).theme)
|
||||
}
|
||||
|
||||
override fun getItemId(index: Int): Long {
|
||||
@@ -108,4 +120,4 @@ class ConversationsAdapter @Inject constructor(
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (getItem(position)?.unread == false) 0 else 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
// Set the theme color tint to the recyclerView, progressbar, and FAB
|
||||
theme
|
||||
.doOnNext { recyclerView.scrapViews() }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { theme ->
|
||||
// Set the color for the drawer icons
|
||||
@@ -183,6 +182,10 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
compose.setTint(theme.textPrimary)
|
||||
}
|
||||
|
||||
allThemes
|
||||
.autoDisposable(scope())
|
||||
.subscribe { recyclerView.scrapViews() }
|
||||
|
||||
itemTouchCallback.adapter = conversationsAdapter
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class SearchAdapter @Inject constructor(
|
||||
}
|
||||
view.title.text = title
|
||||
|
||||
view.avatars.contacts = result.conversation.recipients
|
||||
view.avatars.recipients = result.conversation.recipients
|
||||
|
||||
when (result.messages == 0) {
|
||||
true -> {
|
||||
|
||||
@@ -90,7 +90,7 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||
finish()
|
||||
}
|
||||
|
||||
threadId.onNext(state.selectedConversation)
|
||||
threadId.onNext(state.threadId)
|
||||
|
||||
title = state.title
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import io.realm.RealmResults
|
||||
|
||||
data class QkReplyState(
|
||||
val hasError: Boolean = false,
|
||||
val selectedConversation: Long = 0,
|
||||
val threadId: Long = 0,
|
||||
val title: String = "",
|
||||
val expanded: Boolean = false,
|
||||
val data: Pair<Conversation, RealmResults<Message>>? = null,
|
||||
|
||||
@@ -54,7 +54,7 @@ class QkReplyViewModel @Inject constructor(
|
||||
private val navigator: Navigator,
|
||||
private val sendMessage: SendMessage,
|
||||
private val subscriptionManager: SubscriptionManagerCompat
|
||||
) : QkViewModel<QkReplyView, QkReplyState>(QkReplyState(selectedConversation = threadId)) {
|
||||
) : QkViewModel<QkReplyView, QkReplyState>(QkReplyState(threadId = threadId)) {
|
||||
|
||||
private val conversation by lazy {
|
||||
conversationRepo.getConversationAsync(threadId)
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class ScheduledMessageAdapter @Inject constructor(
|
||||
val view = holder.containerView
|
||||
|
||||
// GroupAvatarView only accepts recipients, so map the phone numbers to recipients
|
||||
view.avatars.contacts = message.recipients.map { address -> Recipient(address = address) }
|
||||
view.avatars.recipients = message.recipients.map { address -> Recipient(address = address) }
|
||||
|
||||
view.recipients.text = message.recipients.joinToString(",") { address ->
|
||||
contactCache[address]?.name?.takeIf { it.isNotBlank() } ?: address
|
||||
|
||||
+4
-2
@@ -38,7 +38,9 @@ import kotlinx.android.synthetic.main.theme_picker_controller.*
|
||||
import kotlinx.android.synthetic.main.theme_picker_hsv.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerView, ThemePickerState, ThemePickerPresenter>(), ThemePickerView {
|
||||
class ThemePickerController(
|
||||
val recipientId: Long = 0L
|
||||
) : QkController<ThemePickerView, ThemePickerState, ThemePickerPresenter>(), ThemePickerView {
|
||||
|
||||
@Inject override lateinit var presenter: ThemePickerPresenter
|
||||
|
||||
@@ -107,7 +109,7 @@ class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerV
|
||||
override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject
|
||||
|
||||
override fun render(state: ThemePickerState) {
|
||||
tabs.setThreadId(state.threadId)
|
||||
tabs.setRecipientId(state.recipientId)
|
||||
|
||||
hex.setText(Integer.toHexString(state.newColor).takeLast(6))
|
||||
|
||||
|
||||
+5
-5
@@ -34,14 +34,14 @@ import javax.inject.Named
|
||||
|
||||
class ThemePickerPresenter @Inject constructor(
|
||||
prefs: Preferences,
|
||||
@Named("threadId") private val threadId: Long,
|
||||
@Named("recipientId") private val recipientId: Long,
|
||||
private val billingManager: BillingManager,
|
||||
private val colors: Colors,
|
||||
private val navigator: Navigator,
|
||||
private val widgetManager: WidgetManager
|
||||
) : QkPresenter<ThemePickerView, ThemePickerState>(ThemePickerState(threadId = threadId)) {
|
||||
) : QkPresenter<ThemePickerView, ThemePickerState>(ThemePickerState(recipientId = recipientId)) {
|
||||
|
||||
private val theme: Preference<Int> = prefs.theme(threadId)
|
||||
private val theme: Preference<Int> = prefs.theme(recipientId)
|
||||
|
||||
override fun bindIntents(view: ThemePickerView) {
|
||||
super.bindIntents(view)
|
||||
@@ -55,7 +55,7 @@ class ThemePickerPresenter @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { color ->
|
||||
theme.set(color)
|
||||
if (threadId == 0L) {
|
||||
if (recipientId == 0L) {
|
||||
widgetManager.updateTheme()
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class ThemePickerPresenter @Inject constructor(
|
||||
view.showQksmsPlusSnackbar()
|
||||
} else {
|
||||
theme.set(color)
|
||||
if (threadId == 0L) {
|
||||
if (recipientId == 0L) {
|
||||
widgetManager.updateTheme()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package com.moez.QKSMS.feature.themepicker
|
||||
|
||||
data class ThemePickerState(
|
||||
val threadId: Long = 0,
|
||||
val recipientId: Long = 0,
|
||||
val applyThemeVisible: Boolean = false,
|
||||
val newColor: Int = -1,
|
||||
val newTextColor: Int = -1
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ class ThemePickerModule(private val controller: ThemePickerController) {
|
||||
|
||||
@Provides
|
||||
@ControllerScope
|
||||
@Named("threadId")
|
||||
fun provideThreadId(): Long = controller.threadId
|
||||
@Named("recipientId")
|
||||
fun provideThreadId(): Long = controller.recipientId
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user