feat: restore mms

This commit is contained in:
darthpaul 2021-09-18 16:14:58 +01:00
parent 9656207135
commit e10a410788
10 changed files with 438 additions and 142 deletions

View file

@ -6,7 +6,7 @@ data class ExportedMessage(
@SerializedName("threadId")
val threadId: Long,
@SerializedName("sms")
val sms: List<Map<String, String>>,
val sms: List<SmsBackup>,
@SerializedName("mms")
val mms: List<Map<String, Any>>,
val mms: List<MmsBackup>,
)

View file

@ -0,0 +1,28 @@
package com.simplemobiletools.smsmessenger.models
import android.content.ContentValues
import android.provider.Telephony
import androidx.core.content.contentValuesOf
import com.google.gson.annotations.SerializedName
data class MmsAddress(
@SerializedName("address")
val address: String,
@SerializedName("msg_id")
val msgId: Int,
@SerializedName("type")
val type: Int,
@SerializedName("charset")
val charset: Int
) {
fun toContentValues(): ContentValues {
// msgId would be added at the point of insertion
// because it may have changed
return contentValuesOf(
Telephony.Mms.Addr.ADDRESS to address,
Telephony.Mms.Addr.TYPE to type,
Telephony.Mms.Addr.CHARSET to charset,
)
}
}

View file

@ -0,0 +1,73 @@
package com.simplemobiletools.smsmessenger.models
import android.content.ContentValues
import android.provider.Telephony
import androidx.core.content.contentValuesOf
import com.google.gson.annotations.SerializedName
data class MmsBackup(
@SerializedName("creator")
val creator: String?,
@SerializedName("ct_t")
val contentType: String?,
@SerializedName("d_rpt")
val deliveryReport: Int,
@SerializedName("date")
val date: Long,
@SerializedName("date_sent")
val dateSent: Long,
@SerializedName("locked")
val locked: Int,
@SerializedName("m_id")
val messageId: String?,
@SerializedName("m_type")
val messageType: Int,
@SerializedName("msg_box")
val messageBox: Int,
@SerializedName("read")
val read: Int,
@SerializedName("rr")
val readReport: Int,
@SerializedName("seen")
val seen: Int,
@SerializedName("text_only")
val textOnly: Int,
@SerializedName("st")
val status: String?,
@SerializedName("sub")
val subject: String?,
@SerializedName("sub_cs")
val subjectCharSet: String?,
@SerializedName("sub_id")
val subscriptionId: Long,
@SerializedName("thread_id")
val threadId: Long,
@SerializedName("tr_id")
val transactionId: String?,
@SerializedName("addresses")
val addresses: List<MmsAddress>,
@SerializedName("parts")
val mmsParts: List<MmsPart>,
) {
fun toContentValues(): ContentValues {
return contentValuesOf(
Telephony.Mms.TRANSACTION_ID to transactionId,
Telephony.Mms.SUBSCRIPTION_ID to subscriptionId,
Telephony.Mms.SUBJECT to subject,
Telephony.Mms.DATE to date,
Telephony.Mms.DATE_SENT to dateSent,
Telephony.Mms.LOCKED to locked,
Telephony.Mms.READ to read,
Telephony.Mms.STATUS to status,
Telephony.Mms.SUBJECT_CHARSET to subjectCharSet,
Telephony.Mms.SEEN to seen,
Telephony.Mms.MESSAGE_TYPE to messageType,
Telephony.Mms.MESSAGE_BOX to messageBox,
Telephony.Mms.DELIVERY_REPORT to deliveryReport,
Telephony.Mms.READ_REPORT to readReport,
Telephony.Mms.CONTENT_TYPE to contentType,
Telephony.Mms.TEXT_ONLY to textOnly,
)
}
}

View file

@ -0,0 +1,60 @@
package com.simplemobiletools.smsmessenger.models
import android.content.ContentValues
import android.provider.Telephony
import androidx.core.content.contentValuesOf
import com.google.gson.annotations.SerializedName
data class MmsPart(
@SerializedName("cd")
val contentDisposition: String?,
@SerializedName("chset")
val charset: String?,
@SerializedName("cid")
val contentId: String?,
@SerializedName("cl")
val contentLocation: String?,
@SerializedName("ct")
val contentType: String,
@SerializedName("ctt_s")
val ctStart: String?,
@SerializedName("ctt_t")
val ctType: String?,
@SerializedName("_data")
val `data`: String?,
@SerializedName("fn")
val filename: String?,
@SerializedName("_id")
val id: Long,
@SerializedName("mid")
val messageId: Long,
@SerializedName("name")
val name: String,
@SerializedName("seq")
val sequenceOrder: Int,
@SerializedName("text")
val text: String?,
@SerializedName("mms_content")
val mmsContent: String?,
) {
fun toContentValues(): ContentValues {
return contentValuesOf(
Telephony.Mms.Part.CONTENT_DISPOSITION to contentDisposition,
Telephony.Mms.Part.CHARSET to charset,
Telephony.Mms.Part.CONTENT_ID to contentId,
Telephony.Mms.Part.CONTENT_LOCATION to contentLocation,
Telephony.Mms.Part.CONTENT_TYPE to contentType,
Telephony.Mms.Part.CT_START to ctStart,
Telephony.Mms.Part.CT_TYPE to ctType,
Telephony.Mms.Part.FILENAME to filename,
Telephony.Mms.Part.NAME to name,
Telephony.Mms.Part.SEQ to sequenceOrder,
Telephony.Mms.Part.TEXT to text,
)
}
fun isNonText(): Boolean {
return !(text != null || contentType.lowercase().startsWith("text") || contentType.lowercase() == "application/smil")
}
}

View file

@ -1,46 +1,52 @@
package com.simplemobiletools.smsmessenger.models
import android.content.ContentValues
import android.provider.Telephony
import androidx.core.content.contentValuesOf
import com.google.gson.annotations.SerializedName
data class SmsBackup(
@SerializedName(Telephony.Sms._ID)
val id: Long,
@SerializedName(Telephony.Sms.ADDRESS)
val address: String,
@SerializedName(Telephony.Sms.BODY)
val body: String,
@SerializedName(Telephony.Sms.CREATOR)
val creator: String,
@SerializedName(Telephony.Sms.DATE)
val date: Long,
@SerializedName(Telephony.Sms.DATE_SENT)
val dateSent: Int,
@SerializedName(Telephony.Sms.ERROR_CODE)
val errorCode: Int,
@SerializedName(Telephony.Sms.LOCKED)
val locked: Int,
@SerializedName(Telephony.Sms.PERSON)
val person: String,
@SerializedName(Telephony.Sms.PROTOCOL)
val protocol: String,
@SerializedName("read")
val read: Int,
@SerializedName("reply_path_present")
val replyPathPresent: Any,
@SerializedName("seen")
val seen: Int,
@SerializedName("service_center")
val serviceCenter: Any,
@SerializedName("status")
val status: Int,
@SerializedName("sub_id")
val subId: Int,
@SerializedName("subject")
val subject: Any,
@SerializedName("thread_id")
val threadId: Long,
@SerializedName("sub_id")
val subscriptionId: Long,
@SerializedName("address")
val address: String,
@SerializedName("body")
val body: String,
@SerializedName("date")
val date: Long,
@SerializedName("date_sent")
val dateSent: Long,
@SerializedName("locked")
val locked: Int,
@SerializedName("protocol")
val protocol: String?,
@SerializedName("read")
val read: Int,
@SerializedName("status")
val status: Int,
@SerializedName("type")
val type: Int
)
val type: Int,
@SerializedName("service_center")
val serviceCenter: String?
) {
fun toContentValues(): ContentValues {
return contentValuesOf(
Telephony.Sms.THREAD_ID to threadId,
Telephony.Sms.SUBSCRIPTION_ID to subscriptionId,
Telephony.Sms.ADDRESS to address,
Telephony.Sms.BODY to body,
Telephony.Sms.DATE to date,
Telephony.Sms.DATE_SENT to dateSent,
Telephony.Sms.LOCKED to locked,
Telephony.Sms.PROTOCOL to protocol,
Telephony.Sms.READ to read,
Telephony.Sms.STATUS to status,
Telephony.Sms.TYPE to type,
Telephony.Sms.SERVICE_CENTER to serviceCenter,
)
}
}