Remove parcelable interface

Because proper proguard rules weren't added for Attendee and Gson, we can not make changes to the Attendee data class without affecting it's obfuscated Json member names. When serialized using Gson, the resulting json still uses the obfuscated member names
This commit is contained in:
Naveen 2023-09-30 00:01:34 +05:30
parent 950feba0bc
commit b655b8be52
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
5 changed files with 6 additions and 9 deletions

View file

@ -6,7 +6,6 @@ plugins {
alias(libs.plugins.android)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.parcelize)
base
}

View file

@ -24,6 +24,8 @@ import android.widget.RelativeLayout
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.MaterialTimePicker.INPUT_MODE_CLOCK
import com.google.android.material.timepicker.TimeFormat
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.AutoCompleteTextViewAdapter
import com.simplemobiletools.calendar.pro.databinding.ActivityEventBinding
@ -169,7 +171,7 @@ class EventActivity : SimpleActivity() {
putInt(REPEAT_RULE, mRepeatRule)
putLong(REPEAT_LIMIT, mRepeatLimit)
putParcelableArrayList(ATTENDEES, getAllAttendees(false))
putString(ATTENDEES, Gson().toJson(getAllAttendees(false)))
putInt(AVAILABILITY, mAvailability)
putInt(EVENT_COLOR, mEventColor)
@ -211,7 +213,8 @@ class EventActivity : SimpleActivity() {
mRepeatRule = getInt(REPEAT_RULE)
mRepeatLimit = getLong(REPEAT_LIMIT)
mAttendees = getParcelableArrayList(ATTENDEES) ?: arrayListOf()
val token = object : TypeToken<List<Attendee>>() {}.type
mAttendees = Gson().fromJson<ArrayList<Attendee>>(getString(ATTENDEES), token) ?: ArrayList()
mEventTypeId = getLong(EVENT_TYPE_ID)
mEventCalendarId = getInt(EVENT_CALENDAR_ID)

View file

@ -2,16 +2,13 @@ package com.simplemobiletools.calendar.pro.models
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Parcelable
import android.provider.CalendarContract
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import kotlinx.parcelize.Parcelize
@Parcelize
data class Attendee(
val contactId: Int,
var name: String,
@ -20,7 +17,7 @@ data class Attendee(
var photoUri: String,
var isMe: Boolean,
var relationship: Int
) : Parcelable {
) {
fun getPublicName() = name.ifEmpty { email }
fun updateImage(context: Context, imageView: ImageView, placeholder: Drawable) {

View file

@ -2,7 +2,6 @@ plugins {
alias(libs.plugins.android).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.parcelize).apply(false)
}
tasks.register<Delete>("clean") {

View file

@ -45,5 +45,4 @@ room = [
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }