mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-18 03:48:52 +01:00
add delay send mms. add group send to individual recipients - sms and mms. add immediate show messages in convo, not wait for sent. new qktransaction that replaces android/smsmms transaction with mods for quik. lots of code cleanups and removing superfluous code. some bug fixes.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
@@ -36,7 +35,6 @@ import dev.octoshrimpy.quik.extensions.isImage
|
||||
import dev.octoshrimpy.quik.extensions.isVCard
|
||||
|
||||
|
||||
@SuppressLint("Range")
|
||||
class Attachment (
|
||||
context: Context,
|
||||
var uri: Uri = Uri.EMPTY,
|
||||
|
||||
@@ -35,7 +35,9 @@ open class Conversation(
|
||||
var blockingClient: Int? = null,
|
||||
var blockReason: String? = null,
|
||||
|
||||
var name: String = "" // For group chats, the user is allowed to set a custom title for the conversation
|
||||
var name: String = "", // custom title
|
||||
|
||||
var sendAsGroup: Boolean = false,
|
||||
) : RealmObject() {
|
||||
|
||||
val date: Long get() = lastMessage?.date ?: 0
|
||||
|
||||
@@ -28,6 +28,10 @@ import io.realm.annotations.Index
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Message : RealmObject() {
|
||||
companion object {
|
||||
const val TYPE_SMS = "sms"
|
||||
const val TYPE_MMS = "mms"
|
||||
}
|
||||
|
||||
enum class AttachmentType { TEXT, IMAGE, VIDEO, AUDIO, SLIDESHOW, NOT_LOADED }
|
||||
|
||||
@@ -73,14 +77,19 @@ open class Message : RealmObject() {
|
||||
var textContentType: String = ""
|
||||
var parts: RealmList<MmsPart> = RealmList()
|
||||
|
||||
var sendAsGroup: Boolean = false
|
||||
|
||||
fun getUri(): Uri {
|
||||
val baseUri = if (isMms()) Mms.CONTENT_URI else Sms.CONTENT_URI
|
||||
return ContentUris.withAppendedId(baseUri, contentId)
|
||||
if (contentId == 0L)
|
||||
return Uri.EMPTY
|
||||
return ContentUris.withAppendedId(
|
||||
if (isMms()) Mms.CONTENT_URI else Sms.CONTENT_URI, contentId
|
||||
)
|
||||
}
|
||||
|
||||
fun isMms(): Boolean = type == "mms"
|
||||
fun isMms(): Boolean = type == TYPE_MMS
|
||||
|
||||
fun isSms(): Boolean = type == "sms"
|
||||
fun isSms(): Boolean = type == TYPE_SMS
|
||||
|
||||
fun isMe(): Boolean {
|
||||
val isIncomingMms = isMms() && (boxId == Mms.MESSAGE_BOX_INBOX || boxId == Mms.MESSAGE_BOX_ALL)
|
||||
@@ -90,7 +99,7 @@ open class Message : RealmObject() {
|
||||
}
|
||||
|
||||
fun isOutgoingMessage(): Boolean {
|
||||
val isOutgoingMms = isMms() && boxId == Mms.MESSAGE_BOX_OUTBOX
|
||||
val isOutgoingMms = isMms() && (boxId == Mms.MESSAGE_BOX_OUTBOX)
|
||||
val isOutgoingSms = isSms() && (boxId == Sms.MESSAGE_TYPE_FAILED
|
||||
|| boxId == Sms.MESSAGE_TYPE_OUTBOX
|
||||
|| boxId == Sms.MESSAGE_TYPE_QUEUED)
|
||||
@@ -98,9 +107,6 @@ open class Message : RealmObject() {
|
||||
return isOutgoingMms || isOutgoingSms
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text that should be copied to the clipboard
|
||||
*/
|
||||
fun getText(withSubject: Boolean = true): String {
|
||||
val messageText = when {
|
||||
isSms() -> body
|
||||
@@ -139,10 +145,10 @@ open class Message : RealmObject() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
// Add subject
|
||||
getCleansedSubject().takeIf { it.isNotEmpty() }?.run(sb::appendln)
|
||||
getCleansedSubject().takeIf { it.isNotEmpty() }?.run(sb::appendLine)
|
||||
|
||||
// Add parts
|
||||
parts.mapNotNull { it.getSummary() }.forEach { summary -> sb.appendln(summary) }
|
||||
parts.mapNotNull { it.getSummary() }.forEach { summary -> sb.appendLine(summary) }
|
||||
|
||||
sb.toString().trim()
|
||||
}
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.ContentResolver.MimeTypeInfo
|
||||
import android.net.Uri
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.core.net.toUri
|
||||
import io.realm.RealmObject
|
||||
import io.realm.RealmResults
|
||||
import io.realm.annotations.Index
|
||||
@@ -50,9 +48,12 @@ open class MmsPart : RealmObject() {
|
||||
.build()
|
||||
|
||||
fun getBestFilename(): String =
|
||||
if (File(name).extension.isNotEmpty()) name ?: "unknown"
|
||||
else "$name." + (MimeTypeMap.getSingleton().getExtensionFromMimeType(type)
|
||||
?: type.substringAfter("/"))
|
||||
if (name.isNullOrBlank()) "unknown"
|
||||
else if (File(name!!).extension.isNotEmpty()) name!!
|
||||
else "$name" +
|
||||
if (type.isBlank()) ""
|
||||
else ".${MimeTypeMap.getSingleton().getExtensionFromMimeType(type)
|
||||
?: type.substringAfter("/")}"
|
||||
|
||||
fun getSummary(): String? = when {
|
||||
type == "application/smil" -> null
|
||||
|
||||
Reference in New Issue
Block a user