diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt index 3af7f77..b3eaa42 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt @@ -4,6 +4,7 @@ import android.content.Context import android.media.RingtoneManager import com.simplemobiletools.clock.extensions.gson.gson import com.simplemobiletools.clock.models.Alarm +import com.simplemobiletools.clock.models.ObfuscatedAlarm import com.simplemobiletools.clock.models.ObfuscatedTimer import com.simplemobiletools.clock.models.Timer import com.simplemobiletools.commons.extensions.getDefaultAlarmSound @@ -66,7 +67,15 @@ class Config(context: Context) : BaseConfig(context) { var alarmLastConfig: Alarm? get() = prefs.getString(ALARM_LAST_CONFIG, null)?.let { lastAlarm -> - gson.fromJson(lastAlarm, Alarm::class.java) + try { + if (lastAlarm.contains("\"b\"")) { + gson.fromJson(lastAlarm, ObfuscatedAlarm::class.java).toAlarm() + } else { + gson.fromJson(lastAlarm, Alarm::class.java) + } + } catch (e: Exception) { + null + } } set(alarm) = prefs.edit().putString(ALARM_LAST_CONFIG, gson.toJson(alarm)).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/models/Alarm.kt b/app/src/main/kotlin/com/simplemobiletools/clock/models/Alarm.kt index 75f8fd4..3a7a34b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/models/Alarm.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/models/Alarm.kt @@ -1,5 +1,8 @@ package com.simplemobiletools.clock.models +import androidx.annotation.Keep + +@Keep data class Alarm( var id: Int, var timeInMinutes: Int, @@ -11,3 +14,18 @@ data class Alarm( var label: String, var oneShot: Boolean = false ) + +@Keep +data class ObfuscatedAlarm( + var a: Int, + var b: Int, + var c: Int, + var d: Boolean, + var e: Boolean, + var f: String, + var g: String, + var h: String, + var i: Boolean = false +) { + fun toAlarm() = Alarm(a, b, c, d, e, f, g, h, i) +} diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/models/Timer.kt b/app/src/main/kotlin/com/simplemobiletools/clock/models/Timer.kt index a124234..0b5a5d4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/models/Timer.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/models/Timer.kt @@ -33,16 +33,5 @@ data class ObfuscatedTimer( var i: String? = null, var j: Boolean = false ) { - fun toTimer(): Timer = Timer( - a, - b, - TimerState.Idle, - d, - e, - f, - g, - h, - i, - j - ) + fun toTimer() = Timer(a, b, TimerState.Idle, d, e, f, g, h, i, j) }