Commit 7f3fe75d authored by dev-ritik's avatar dev-ritik

Adds camera image alertDialog

parent d18051a7
...@@ -342,9 +342,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -342,9 +342,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
when (requestCode) { when (requestCode) {
REQUEST_CODE_FOR_PERFORM_CAMERA -> takenPhotoUri?.let { uri -> REQUEST_CODE_FOR_PERFORM_CAMERA -> takenPhotoUri?.let { uri ->
uri.getBitmpap(requireContext())?.let { bitmap -> showCameraImageAttachmentDialog(uri)
presenter.uploadImage(chatRoomId, "image/png", uri, bitmap, "")
}
} }
REQUEST_CODE_FOR_PERFORM_SAF -> resultData?.data?.let { REQUEST_CODE_FOR_PERFORM_SAF -> resultData?.data?.let {
showFileAttachmentDialog(it) showFileAttachmentDialog(it)
......
...@@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable ...@@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import androidx.core.view.isVisible import androidx.core.view.isVisible
import chat.rocket.android.emoji.internal.GlideApp import chat.rocket.android.emoji.internal.GlideApp
import chat.rocket.android.util.extensions.getBitmpap
import chat.rocket.android.util.extensions.getFileName import chat.rocket.android.util.extensions.getFileName
import chat.rocket.android.util.extensions.getMimeType import chat.rocket.android.util.extensions.getMimeType
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
...@@ -97,4 +98,44 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) { ...@@ -97,4 +98,44 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
cancelButton.setOnClickListener { alertDialog.dismiss() } cancelButton.setOnClickListener { alertDialog.dismiss() }
alertDialog.show() alertDialog.show()
} }
\ No newline at end of file
fun ChatRoomFragment.showCameraImageAttachmentDialog(uri: Uri) {
imagePreview.isVisible = false
audioVideoAttachment.isVisible = false
textFile.isVisible = false
activity?.let { context ->
description.text.clear()
GlideApp
.with(context)
.asBitmap()
.load(uri)
.fitCenter()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
imagePreview.setImageBitmap(resource)
}
})
imagePreview.isVisible = true
}
sendButton.setOnClickListener {
uri.getBitmpap(requireContext())?.let { bitmap ->
presenter.uploadImage(
chatRoomId,
"image/png",
uri,
bitmap,
(citation ?: "") + description.text.toString())
}
alertDialog.dismiss()
}
cancelButton.setOnClickListener { alertDialog.dismiss() }
alertDialog.show()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment