diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt index d9b0504a..5d7b789c 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt @@ -42,13 +42,11 @@ class ComposeActivityModule { fun provideThreadId(activity: ComposeActivity): Long = activity.intent.extras?.getLong("threadId") ?: 0L @Provides - @Named("address") - fun provideAddress(activity: ComposeActivity): String { - var address = "" - + @Named("addresses") + fun provideAddresses(activity: ComposeActivity): List { activity.intent.data?.let { val data = it.toString() - address = when { + var address = when { it.scheme?.startsWith("smsto") == true -> data.replace("smsto:", "") it.scheme?.startsWith("mmsto") == true -> data.replace("mmsto:", "") 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 if (address.contains('%')) address = URLDecoder.decode(address, "UTF-8") + + return address.split(",") } - return address + return listOf() } @Provides diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index 61181d2f..ded142e5 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -74,7 +74,7 @@ import javax.inject.Named class ComposeViewModel @Inject constructor( @Named("query") private val query: String, @Named("threadId") private val threadId: Long, - @Named("address") private val address: String, + @Named("addresses") private val addresses: List, @Named("text") private val sharedText: String, @Named("attachments") private val sharedAttachments: Attachments, private val contactRepo: ContactRepository, @@ -96,7 +96,7 @@ class ComposeViewModel @Inject constructor( private val sendMessage: SendMessage, private val subscriptionManager: SubscriptionManagerCompat ) : QkViewModel(ComposeState( - editingMode = threadId == 0L && address.isBlank(), + editingMode = threadId == 0L && addresses.isEmpty(), selectedConversation = threadId, query = query) ) { @@ -109,7 +109,7 @@ class ComposeViewModel @Inject constructor( private val searchResults: Subject> = BehaviorSubject.create() private val searchSelection: Subject = BehaviorSubject.createDefault(-1) - private var shouldShowContacts = threadId == 0L && address.isBlank() + private var shouldShowContacts = threadId == 0L && addresses.isEmpty() init { val initialConversation = threadId.takeIf { it != 0L } @@ -160,8 +160,8 @@ class ComposeViewModel @Inject constructor( .filter { conversation -> conversation.isValid } .subscribe(conversation::onNext) - if (address.isNotBlank()) { - selectedChips.onNext(listOf(Chip(address))) + if (addresses.isNotEmpty()) { + selectedChips.onNext(addresses.map { address -> Chip(address) }) } disposables += chipsReducer