mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Add vcard to message
This commit is contained in:
@@ -47,7 +47,7 @@ class SendScheduledMessage @Inject constructor(
|
||||
}
|
||||
.map { message ->
|
||||
val threadId = TelephonyCompat.getOrCreateThreadId(context, message.recipients)
|
||||
val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment(it) }
|
||||
val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment.Image(it) }
|
||||
SendMessage.Params(message.subId, threadId, message.recipients, message.body, attachments)
|
||||
}
|
||||
.flatMap(sendMessage::buildObservable)
|
||||
|
||||
@@ -23,22 +23,32 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.core.view.inputmethod.InputContentInfoCompat
|
||||
|
||||
data class Attachment(private val uri: Uri? = null, private val inputContent: InputContentInfoCompat? = null) {
|
||||
sealed class Attachment {
|
||||
|
||||
fun getUri(): Uri? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
inputContent?.contentUri ?: uri
|
||||
} else {
|
||||
uri
|
||||
data class Image(
|
||||
private val uri: Uri? = null,
|
||||
private val inputContent: InputContentInfoCompat? = null
|
||||
) : Attachment() {
|
||||
|
||||
fun getUri(): Uri? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
inputContent?.contentUri ?: uri
|
||||
} else {
|
||||
uri
|
||||
}
|
||||
}
|
||||
|
||||
fun isGif(context: Context): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && inputContent != null) {
|
||||
inputContent.description.hasMimeType("image/gif")
|
||||
} else {
|
||||
context.contentResolver.getType(uri) == "image/gif"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isGif(context: Context): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && inputContent != null) {
|
||||
inputContent.description.hasMimeType("image/gif")
|
||||
} else {
|
||||
context.contentResolver.getType(uri) == "image/gif"
|
||||
}
|
||||
}
|
||||
data class Contact(val vCard: String) : Attachment()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Attachments(attachments: List<Attachment>): List<Attachment> by attachments
|
||||
|
||||
Reference in New Issue
Block a user