check the Send Message button availabilty at adding an attachment
This commit is contained in:
parent
52a7376694
commit
2ffdaa0712
1 changed files with 14 additions and 3 deletions
|
|
@ -52,6 +52,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private var bus: EventBus? = null
|
private var bus: EventBus? = null
|
||||||
private var participants = ArrayList<Contact>()
|
private var participants = ArrayList<Contact>()
|
||||||
private var messages = ArrayList<Message>()
|
private var messages = ArrayList<Message>()
|
||||||
|
private var attachmentUris = ArrayList<Uri>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
@ -173,8 +174,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
|
|
||||||
thread_send_message.isClickable = false
|
thread_send_message.isClickable = false
|
||||||
thread_type_message.onTextChangeListener {
|
thread_type_message.onTextChangeListener {
|
||||||
thread_send_message.isClickable = it.isNotEmpty()
|
checkSendMessageAvailability()
|
||||||
thread_send_message.alpha = if (it.isEmpty()) 0.4f else 0.9f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
confirm_manage_contacts.setOnClickListener {
|
confirm_manage_contacts.setOnClickListener {
|
||||||
|
|
@ -308,6 +308,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAttachment(uri: Uri) {
|
private fun addAttachment(uri: Uri) {
|
||||||
|
attachmentUris.add(uri)
|
||||||
val roundedCornersRadius = resources.getDimension(R.dimen.medium_margin).toInt()
|
val roundedCornersRadius = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
|
@ -328,13 +329,23 @@ class ThreadActivity : SimpleActivity() {
|
||||||
override fun onResourceReady(dr: Drawable?, a: Any?, t: Target<Drawable>?, d: DataSource?, i: Boolean): Boolean {
|
override fun onResourceReady(dr: Drawable?, a: Any?, t: Target<Drawable>?, d: DataSource?, i: Boolean): Boolean {
|
||||||
thread_attachment_preview.beVisible()
|
thread_attachment_preview.beVisible()
|
||||||
thread_remove_attachment.beVisible()
|
thread_remove_attachment.beVisible()
|
||||||
|
checkSendMessageAvailability()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.into(thread_attachment_preview)
|
.into(thread_attachment_preview)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkSendMessageAvailability() {
|
||||||
|
if (thread_type_message.text.isNotEmpty() || attachmentUris.isNotEmpty()) {
|
||||||
|
thread_send_message.isClickable = true
|
||||||
|
thread_send_message.alpha = 0.9f
|
||||||
|
} else {
|
||||||
|
thread_send_message.isClickable = false
|
||||||
|
thread_send_message.alpha = 0.4f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// show selected contacts, properly split to new lines when appropriate
|
// show selected contacts, properly split to new lines when appropriate
|
||||||
// based on https://stackoverflow.com/a/13505029/1967672
|
// based on https://stackoverflow.com/a/13505029/1967672
|
||||||
private fun showSelectedContact(views: ArrayList<View>) {
|
private fun showSelectedContact(views: ArrayList<View>) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue