Migrate last alarm to unobfuscated storage as well
This commit is contained in:
parent
97388477d9
commit
ab9d5edc31
3 changed files with 29 additions and 13 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue