mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
allow adding multiple mms attachments
This commit is contained in:
@@ -42,6 +42,7 @@ import com.simplemobiletools.smsmessenger.helpers.*
|
|||||||
import com.simplemobiletools.smsmessenger.models.*
|
import com.simplemobiletools.smsmessenger.models.*
|
||||||
import com.simplemobiletools.smsmessenger.receivers.SmsSentReceiver
|
import com.simplemobiletools.smsmessenger.receivers.SmsSentReceiver
|
||||||
import kotlinx.android.synthetic.main.activity_thread.*
|
import kotlinx.android.synthetic.main.activity_thread.*
|
||||||
|
import kotlinx.android.synthetic.main.item_attachment.view.*
|
||||||
import kotlinx.android.synthetic.main.item_selected_contact.view.*
|
import kotlinx.android.synthetic.main.item_selected_contact.view.*
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
@@ -56,7 +57,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>()
|
private var attachmentUris = LinkedHashSet<Uri>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -213,10 +214,6 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
thread_add_attachment.setOnClickListener {
|
thread_add_attachment.setOnClickListener {
|
||||||
launchPickPhotoVideoIntent()
|
launchPickPhotoVideoIntent()
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_remove_attachment.setOnClickListener {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun blockNumber() {
|
private fun blockNumber() {
|
||||||
@@ -325,7 +322,16 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addAttachment(uri: Uri) {
|
private fun addAttachment(uri: Uri) {
|
||||||
|
if (attachmentUris.contains(uri)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
attachmentUris.add(uri)
|
attachmentUris.add(uri)
|
||||||
|
thread_attachments_holder.beVisible()
|
||||||
|
val attachmentView = layoutInflater.inflate(R.layout.item_attachment, null).apply {
|
||||||
|
thread_attachments_wrapper.addView(this)
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -337,20 +343,20 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
.apply(options)
|
.apply(options)
|
||||||
.listener(object : RequestListener<Drawable> {
|
.listener(object : RequestListener<Drawable> {
|
||||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||||
thread_attachment_preview.beGone()
|
attachmentView.thread_attachment_preview.beGone()
|
||||||
thread_remove_attachment.beGone()
|
attachmentView.thread_remove_attachment.beGone()
|
||||||
showErrorToast(e?.localizedMessage ?: "")
|
showErrorToast(e?.localizedMessage ?: "")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
attachmentView.thread_attachment_preview.beVisible()
|
||||||
thread_remove_attachment.beVisible()
|
attachmentView.thread_remove_attachment.beVisible()
|
||||||
checkSendMessageAvailability()
|
checkSendMessageAvailability()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.into(thread_attachment_preview)
|
.into(attachmentView.thread_attachment_preview)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkSendMessageAvailability() {
|
private fun checkSendMessageAvailability() {
|
||||||
|
@@ -95,7 +95,7 @@
|
|||||||
android:id="@+id/message_divider"
|
android:id="@+id/message_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_above="@+id/thread_attachment_preview"
|
android:layout_above="@+id/thread_attachments_holder"
|
||||||
android:background="@color/divider_grey"
|
android:background="@color/divider_grey"
|
||||||
android:importantForAccessibility="no" />
|
android:importantForAccessibility="no" />
|
||||||
|
|
||||||
@@ -112,25 +112,27 @@
|
|||||||
android:padding="@dimen/normal_margin"
|
android:padding="@dimen/normal_margin"
|
||||||
android:src="@drawable/ic_plus_vector" />
|
android:src="@drawable/ic_plus_vector" />
|
||||||
|
|
||||||
<ImageView
|
<HorizontalScrollView
|
||||||
android:id="@+id/thread_attachment_preview"
|
android:id="@+id/thread_attachments_holder"
|
||||||
android:layout_width="@dimen/attachment_preview_size"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/attachment_preview_size"
|
android:layout_height="wrap_content"
|
||||||
android:layout_above="@+id/thread_type_message"
|
android:layout_above="@+id/thread_type_message"
|
||||||
android:layout_alignStart="@+id/thread_type_message"
|
android:layout_alignStart="@+id/thread_type_message"
|
||||||
android:layout_marginTop="@dimen/normal_margin"
|
android:layout_marginTop="@dimen/normal_margin"
|
||||||
android:layout_marginBottom="@dimen/small_margin"
|
android:layout_marginBottom="@dimen/small_margin"
|
||||||
android:visibility="gone" />
|
android:overScrollMode="never"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/thread_remove_attachment"
|
android:id="@+id/thread_attachments_wrapper"
|
||||||
android:layout_width="@dimen/remove_attachment_size"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/remove_attachment_size"
|
android:layout_height="@dimen/attachment_preview_size"
|
||||||
android:layout_alignTop="@+id/thread_attachment_preview"
|
android:divider="@drawable/linear_layout_horizontal_divider"
|
||||||
android:layout_alignEnd="@+id/thread_attachment_preview"
|
android:orientation="horizontal"
|
||||||
android:padding="@dimen/tiny_margin"
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
android:src="@drawable/ic_cross_vector"
|
android:showDividers="middle" />
|
||||||
android:visibility="gone" />
|
</HorizontalScrollView>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
android:id="@+id/thread_type_message"
|
android:id="@+id/thread_type_message"
|
||||||
|
23
app/src/main/res/layout/item_attachment.xml
Normal file
23
app/src/main/res/layout/item_attachment.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/conversation_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/thread_attachment_preview"
|
||||||
|
android:layout_width="@dimen/attachment_preview_size"
|
||||||
|
android:layout_height="@dimen/attachment_preview_size"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/thread_remove_attachment"
|
||||||
|
android:layout_width="@dimen/remove_attachment_size"
|
||||||
|
android:layout_height="@dimen/remove_attachment_size"
|
||||||
|
android:layout_alignTop="@+id/thread_attachment_preview"
|
||||||
|
android:layout_alignEnd="@+id/thread_attachment_preview"
|
||||||
|
android:padding="@dimen/tiny_margin"
|
||||||
|
android:src="@drawable/ic_cross_vector"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Reference in New Issue
Block a user