Add ability to attach and send photos

This commit is contained in:
Moez Bhatti
2018-01-12 18:46:47 -05:00
parent 432f71ee95
commit 161f673914
11 changed files with 230 additions and 42 deletions
@@ -20,6 +20,7 @@ package presentation.feature.compose
import android.app.AlertDialog
import android.content.res.ColorStateList
import android.graphics.Bitmap
import android.graphics.PorterDuff
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
@@ -62,6 +63,7 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
override val copyTextIntent: Subject<Message> = PublishSubject.create()
override val forwardMessageIntent: Subject<Message> = PublishSubject.create()
override val deleteMessageIntent: Subject<Message> = PublishSubject.create()
override val attachmentDeletedIntent: Subject<Bitmap> by lazy { attachmentAdapter.attachmentDeleted }
override val textChangedIntent by lazy { message.textChanges() }
override val attachIntent by lazy { attach.clicks() }
override val sendIntent by lazy { send.clicks() }
@@ -69,6 +71,7 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
@Inject lateinit var chipsAdapter: ChipsAdapter
@Inject lateinit var contactsAdapter: ContactAdapter
@Inject lateinit var messageAdapter: MessagesAdapter
@Inject lateinit var attachmentAdapter: AttachmentAdapter
init {
appComponent.inject(this)
@@ -120,6 +123,9 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
messageList.layoutManager = layoutManager
messageList.adapter = messageAdapter
attachments.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
attachments.adapter = attachmentAdapter
messageBackground.backgroundTintMode = PorterDuff.Mode.MULTIPLY
val states = arrayOf(
@@ -206,6 +212,11 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
messageAdapter.updateData(state.messages)
}
attachments.setVisible(state.attachments.isNotEmpty())
if (attachmentAdapter.data !== state.attachments) {
attachmentAdapter.data = state.attachments
}
if (title != state.title) title = state.title
send.isEnabled = state.canSend