Only show recents when sharing

This commit is contained in:
Moez Bhatti
2019-11-23 23:48:42 -05:00
parent 5dbc7aee0b
commit a1fcecd79e
6 changed files with 17 additions and 6 deletions
@@ -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
}