forked from upstream-mirrors/quik
Only show recents when sharing
This commit is contained in:
@@ -284,10 +284,11 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
startActivityForResult(Intent.createChooser(intent, null), ATTACH_CONTACT_REQUEST_CODE)
|
||||
}
|
||||
|
||||
override fun showContacts(chips: List<Chip>) {
|
||||
override fun showContacts(sharing: Boolean, chips: List<Chip>) {
|
||||
message.hideKeyboard()
|
||||
val serialized = HashMap(chips.associate { chip -> chip.address to chip.contact?.lookupKey })
|
||||
val intent = Intent(this, ContactsActivity::class.java)
|
||||
.putExtra(ContactsActivity.SharingKey, sharing)
|
||||
.putExtra(ContactsActivity.ChipsKey, serialized)
|
||||
startActivityForResult(intent, SELECT_CONTACT_REQUEST_CODE)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun requestDefaultSms()
|
||||
fun requestStoragePermission()
|
||||
fun requestSmsPermission()
|
||||
fun showContacts(chips: List<Chip>)
|
||||
fun showContacts(sharing: Boolean, chips: List<Chip>)
|
||||
fun showKeyboard()
|
||||
fun requestCamera()
|
||||
fun requestGallery()
|
||||
|
||||
@@ -224,9 +224,10 @@ class ComposeViewModel @Inject constructor(
|
||||
override fun bindView(view: ComposeView) {
|
||||
super.bindView(view)
|
||||
|
||||
val sharing = sharedText.isNotEmpty() || sharedAttachments.isNotEmpty()
|
||||
if (shouldShowContacts) {
|
||||
shouldShowContacts = false
|
||||
view.showContacts(selectedChips.blockingFirst())
|
||||
view.showContacts(sharing, selectedChips.blockingFirst())
|
||||
}
|
||||
|
||||
view.chipsSelectedIntent
|
||||
@@ -257,7 +258,7 @@ class ComposeViewModel @Inject constructor(
|
||||
view.optionsItemIntent
|
||||
.filter { it == R.id.add }
|
||||
.withLatestFrom(selectedChips) { _, chips ->
|
||||
view.showContacts(chips)
|
||||
view.showContacts(sharing, chips)
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
@@ -269,7 +270,7 @@ class ComposeViewModel @Inject constructor(
|
||||
chipsReducer.onNext { contacts ->
|
||||
val result = contacts.filterNot { it == contact }
|
||||
if (result.isEmpty()) {
|
||||
view.showContacts(result)
|
||||
view.showContacts(sharing, result)
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import javax.inject.Inject
|
||||
class ContactsActivity : QkThemedActivity(), ContactsContract {
|
||||
|
||||
companion object {
|
||||
const val SharingKey = "sharing"
|
||||
const val ChipsKey = "chips"
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ import dagger.multibindings.IntoMap
|
||||
@Module
|
||||
class ContactsActivityModule {
|
||||
|
||||
@Provides
|
||||
fun provideIsSharing(activity: ContactsActivity): Boolean {
|
||||
return activity.intent.extras?.getBoolean(ContactsActivity.SharingKey, false) ?: false
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun provideChips(activity: ContactsActivity): HashMap<String, String?> {
|
||||
return activity.intent.extras?.getSerializable(ContactsActivity.ChipsKey)
|
||||
|
||||
@@ -48,6 +48,7 @@ import kotlinx.coroutines.rx2.awaitFirst
|
||||
import javax.inject.Inject
|
||||
|
||||
class ContactsViewModel @Inject constructor(
|
||||
sharing: Boolean,
|
||||
serializedChips: HashMap<String, String?>,
|
||||
syncContacts: ContactSync,
|
||||
private val contactFilter: ContactFilter,
|
||||
@@ -60,7 +61,9 @@ class ContactsViewModel @Inject constructor(
|
||||
|
||||
private val contactGroups: Observable<List<ContactGroup>> by lazy { contactsRepo.getUnmanagedContactGroups() }
|
||||
private val contacts: Observable<List<Contact>> by lazy { contactsRepo.getUnmanagedContacts() }
|
||||
private val recents: Observable<List<Conversation>> by lazy { conversationRepo.getUnmanagedConversations() }
|
||||
private val recents: Observable<List<Conversation>> by lazy {
|
||||
if (sharing) conversationRepo.getUnmanagedConversations() else Observable.just(listOf())
|
||||
}
|
||||
private val starredContacts: Observable<List<Contact>> by lazy { contactsRepo.getUnmanagedContacts(true) }
|
||||
|
||||
private val selectedChips = Observable.just(serializedChips)
|
||||
|
||||
Reference in New Issue
Block a user