forked from upstream-mirrors/quik
@@ -42,13 +42,11 @@ class ComposeActivityModule {
|
|||||||
fun provideThreadId(activity: ComposeActivity): Long = activity.intent.extras?.getLong("threadId") ?: 0L
|
fun provideThreadId(activity: ComposeActivity): Long = activity.intent.extras?.getLong("threadId") ?: 0L
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("address")
|
@Named("addresses")
|
||||||
fun provideAddress(activity: ComposeActivity): String {
|
fun provideAddresses(activity: ComposeActivity): List<String> {
|
||||||
var address = ""
|
|
||||||
|
|
||||||
activity.intent.data?.let {
|
activity.intent.data?.let {
|
||||||
val data = it.toString()
|
val data = it.toString()
|
||||||
address = when {
|
var address = when {
|
||||||
it.scheme?.startsWith("smsto") == true -> data.replace("smsto:", "")
|
it.scheme?.startsWith("smsto") == true -> data.replace("smsto:", "")
|
||||||
it.scheme?.startsWith("mmsto") == true -> data.replace("mmsto:", "")
|
it.scheme?.startsWith("mmsto") == true -> data.replace("mmsto:", "")
|
||||||
it.scheme?.startsWith("sms") == true -> data.replace("sms:", "")
|
it.scheme?.startsWith("sms") == true -> data.replace("sms:", "")
|
||||||
@@ -58,9 +56,11 @@ class ComposeActivityModule {
|
|||||||
|
|
||||||
// The dialer app on Oreo sends a URL encoded string, make sure to decode it
|
// The dialer app on Oreo sends a URL encoded string, make sure to decode it
|
||||||
if (address.contains('%')) address = URLDecoder.decode(address, "UTF-8")
|
if (address.contains('%')) address = URLDecoder.decode(address, "UTF-8")
|
||||||
|
|
||||||
|
return address.split(",")
|
||||||
}
|
}
|
||||||
|
|
||||||
return address
|
return listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ import javax.inject.Named
|
|||||||
class ComposeViewModel @Inject constructor(
|
class ComposeViewModel @Inject constructor(
|
||||||
@Named("query") private val query: String,
|
@Named("query") private val query: String,
|
||||||
@Named("threadId") private val threadId: Long,
|
@Named("threadId") private val threadId: Long,
|
||||||
@Named("address") private val address: String,
|
@Named("addresses") private val addresses: List<String>,
|
||||||
@Named("text") private val sharedText: String,
|
@Named("text") private val sharedText: String,
|
||||||
@Named("attachments") private val sharedAttachments: Attachments,
|
@Named("attachments") private val sharedAttachments: Attachments,
|
||||||
private val contactRepo: ContactRepository,
|
private val contactRepo: ContactRepository,
|
||||||
@@ -96,7 +96,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
private val sendMessage: SendMessage,
|
private val sendMessage: SendMessage,
|
||||||
private val subscriptionManager: SubscriptionManagerCompat
|
private val subscriptionManager: SubscriptionManagerCompat
|
||||||
) : QkViewModel<ComposeView, ComposeState>(ComposeState(
|
) : QkViewModel<ComposeView, ComposeState>(ComposeState(
|
||||||
editingMode = threadId == 0L && address.isBlank(),
|
editingMode = threadId == 0L && addresses.isEmpty(),
|
||||||
selectedConversation = threadId,
|
selectedConversation = threadId,
|
||||||
query = query)
|
query = query)
|
||||||
) {
|
) {
|
||||||
@@ -109,7 +109,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
private val searchResults: Subject<List<Message>> = BehaviorSubject.create()
|
private val searchResults: Subject<List<Message>> = BehaviorSubject.create()
|
||||||
private val searchSelection: Subject<Long> = BehaviorSubject.createDefault(-1)
|
private val searchSelection: Subject<Long> = BehaviorSubject.createDefault(-1)
|
||||||
|
|
||||||
private var shouldShowContacts = threadId == 0L && address.isBlank()
|
private var shouldShowContacts = threadId == 0L && addresses.isEmpty()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val initialConversation = threadId.takeIf { it != 0L }
|
val initialConversation = threadId.takeIf { it != 0L }
|
||||||
@@ -160,8 +160,8 @@ class ComposeViewModel @Inject constructor(
|
|||||||
.filter { conversation -> conversation.isValid }
|
.filter { conversation -> conversation.isValid }
|
||||||
.subscribe(conversation::onNext)
|
.subscribe(conversation::onNext)
|
||||||
|
|
||||||
if (address.isNotBlank()) {
|
if (addresses.isNotEmpty()) {
|
||||||
selectedChips.onNext(listOf(Chip(address)))
|
selectedChips.onNext(addresses.map { address -> Chip(address) })
|
||||||
}
|
}
|
||||||
|
|
||||||
disposables += chipsReducer
|
disposables += chipsReducer
|
||||||
|
|||||||
Reference in New Issue
Block a user