From 97fe4f88c568b70a053d50f508bf3b86997d5d89 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 14 Feb 2022 19:20:15 +0100 Subject: [PATCH] fix crash in drafts caused by minification of DraftAttachment (#2337) * fix crash in drafts caused by minification of DraftAttachment * fix formatting --- app/proguard-rules.pro | 5 +++-- .../java/com/keylesspalace/tusky/db/DraftEntity.kt | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index ef750ac8c..b7de4270e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -47,12 +47,13 @@ public *; } +-keepclassmembers class com.keylesspalace.tusky.components.conversation.ConversationAccountEntity { *; } +-keepclassmembers class com.keylesspalace.tusky.db.DraftAttachment { *; } + -keep enum com.keylesspalace.tusky.db.DraftAttachment$Type { public *; } --keepclassmembers class com.keylesspalace.tusky.components.conversation.ConversationAccountEntity { *; } - # https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg # Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, diff --git a/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt index 0df30040e..a1e19c75c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt @@ -21,6 +21,7 @@ import androidx.core.net.toUri import androidx.room.Entity import androidx.room.PrimaryKey import androidx.room.TypeConverters +import com.google.gson.annotations.SerializedName import com.keylesspalace.tusky.entity.NewPoll import com.keylesspalace.tusky.entity.Status import kotlinx.parcelize.Parcelize @@ -40,11 +41,16 @@ data class DraftEntity( val failedToSend: Boolean ) +/** + * The alternate names are here because we accidentally published versions were DraftAttachment was minified + * Tusky 15: uriString = e, description = f, type = g + * Tusky 16 beta: uriString = i, description = j, type = k + */ @Parcelize data class DraftAttachment( - val uriString: String, - val description: String?, - val type: Type + @SerializedName(value = "uriString", alternate = ["e", "i"]) val uriString: String, + @SerializedName(value = "description", alternate = ["f", "j"]) val description: String?, + @SerializedName(value = "type", alternate = ["g", "k"]) val type: Type ) : Parcelable { val uri: Uri get() = uriString.toUri()