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