Merge branch 'master' into feature/451-recycle-bin
This commit is contained in:
commit
dbf582b239
33 changed files with 570 additions and 590 deletions
|
|
@ -0,0 +1,13 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class BackupType {
|
||||
@SerialName("sms")
|
||||
SMS,
|
||||
|
||||
@SerialName("mms")
|
||||
MMS,
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
enum class ImportResult {
|
||||
IMPORT_FAIL, IMPORT_OK, IMPORT_PARTIAL, IMPORT_NOTHING_NEW
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@Serializable(with = BackupSerializer::class)
|
||||
sealed class MessagesBackup() {
|
||||
@SerialName("backupType")
|
||||
abstract val backupType: BackupType
|
||||
}
|
||||
|
||||
object BackupSerializer :
|
||||
JsonContentPolymorphicSerializer<MessagesBackup>(MessagesBackup::class) {
|
||||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<out MessagesBackup> {
|
||||
return when (element.jsonObject["backupType"]?.jsonPrimitive?.content) {
|
||||
"sms" -> SmsBackup.serializer()
|
||||
"mms" -> MmsBackup.serializer()
|
||||
else -> throw SerializationException("ERROR: No Serializer found. Serialization failed.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,9 @@ import android.content.ContentValues
|
|||
import android.provider.Telephony
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MmsAddress(
|
||||
@SerializedName("address")
|
||||
val address: String,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import android.content.ContentValues
|
|||
import android.provider.Telephony
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MmsBackup(
|
||||
@SerializedName("creator")
|
||||
val creator: String?,
|
||||
|
|
@ -44,7 +46,9 @@ data class MmsBackup(
|
|||
val addresses: List<MmsAddress>,
|
||||
@SerializedName("parts")
|
||||
val parts: List<MmsPart>,
|
||||
) {
|
||||
|
||||
override val backupType: BackupType = BackupType.MMS,
|
||||
): MessagesBackup() {
|
||||
|
||||
fun toContentValues(): ContentValues {
|
||||
return contentValuesOf(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import android.content.ContentValues
|
|||
import android.provider.Telephony
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MmsPart(
|
||||
@SerializedName("cd")
|
||||
val contentDisposition: String?,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import android.content.ContentValues
|
|||
import android.provider.Telephony
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SmsBackup(
|
||||
@SerializedName("sub_id")
|
||||
val subscriptionId: Long,
|
||||
|
|
@ -28,8 +30,10 @@ data class SmsBackup(
|
|||
@SerializedName("type")
|
||||
val type: Int,
|
||||
@SerializedName("service_center")
|
||||
val serviceCenter: String?
|
||||
) {
|
||||
val serviceCenter: String?,
|
||||
|
||||
override val backupType: BackupType = BackupType.SMS,
|
||||
): MessagesBackup() {
|
||||
|
||||
fun toContentValues(): ContentValues {
|
||||
return contentValuesOf(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue