[App] Fix crashes while deserializing AppData and Config.

This commit is contained in:
Kuba Szczodrzyński 2022-10-22 12:19:19 +02:00
parent 5150467372
commit 40ed5a221f
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
4 changed files with 15 additions and 10 deletions

View File

@ -22,6 +22,7 @@
-keep class android.support.v7.widget.** { *; } -keep class android.support.v7.widget.** { *; }
-keep class pl.szczodrzynski.edziennik.utils.models.** { *; } -keep class pl.szczodrzynski.edziennik.utils.models.** { *; }
-keep class pl.szczodrzynski.edziennik.data.db.enums.* { *; }
-keep class pl.szczodrzynski.edziennik.data.db.entity.Event { *; } -keep class pl.szczodrzynski.edziennik.data.db.entity.Event { *; }
-keep class pl.szczodrzynski.edziennik.data.db.full.EventFull { *; } -keep class pl.szczodrzynski.edziennik.data.db.full.EventFull { *; }
-keep class pl.szczodrzynski.edziennik.data.db.entity.FeedbackMessage { *; } -keep class pl.szczodrzynski.edziennik.data.db.entity.FeedbackMessage { *; }
@ -31,6 +32,9 @@
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.timetable.WidgetTimetableProvider -keepnames class pl.szczodrzynski.edziennik.ui.widgets.timetable.WidgetTimetableProvider
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.notifications.WidgetNotificationsProvider -keepnames class pl.szczodrzynski.edziennik.ui.widgets.notifications.WidgetNotificationsProvider
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.luckynumber.WidgetLuckyNumberProvider -keepnames class pl.szczodrzynski.edziennik.ui.widgets.luckynumber.WidgetLuckyNumberProvider
-keep class pl.szczodrzynski.edziennik.config.AppData { *; }
-keep class pl.szczodrzynski.edziennik.config.AppData$** { *; }
-keep class pl.szczodrzynski.edziennik.utils.managers.TextStylingManager$HtmlMode { *; }
-keepnames class androidx.appcompat.view.menu.MenuBuilder { setHeaderTitleInt(java.lang.CharSequence); } -keepnames class androidx.appcompat.view.menu.MenuBuilder { setHeaderTitleInt(java.lang.CharSequence); }
-keepnames class androidx.appcompat.view.menu.MenuPopupHelper { showPopup(int, int, boolean, boolean); } -keepnames class androidx.appcompat.view.menu.MenuPopupHelper { showPopup(int, int, boolean, boolean); }

View File

@ -190,12 +190,6 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
Iconics.init(applicationContext) Iconics.init(applicationContext)
Iconics.respectFontBoundsDefault = true Iconics.respectFontBoundsDefault = true
if (devMode) {
HyperLog.initialize(this)
HyperLog.setLogLevel(Log.VERBOSE)
HyperLog.setLogFormat(DebugLogFormat(this))
}
// initialize companion object values // initialize companion object values
AppData.read(this) AppData.read(this)
App.db = AppDb(this) App.db = AppDb(this)
@ -204,6 +198,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
devMode = config.devMode ?: debugMode devMode = config.devMode ?: debugMode
enableChucker = config.enableChucker ?: devMode enableChucker = config.enableChucker ?: devMode
if (devMode) {
HyperLog.initialize(this)
HyperLog.setLogLevel(Log.VERBOSE)
HyperLog.setLogFormat(DebugLogFormat(this))
}
if (!profileLoadById(config.lastProfileId)) { if (!profileLoadById(config.lastProfileId)) {
val success = db.profileDao().firstId?.let { profileLoadById(it) } val success = db.profileDao().firstId?.let { profileLoadById(it) }
if (success != true) if (success != true)

View File

@ -50,13 +50,13 @@ inline fun <reified E : Enum<E>> Int.toEnum() = when (E::class.java) {
} as E } as E
fun <E : Enum<E>> Int.toEnum(type: Class<*>) = when (type) { fun <E : Enum<E>> Int.toEnum(type: Class<*>) = when (type) {
// enums commented out are not really used in Bundles // this is used for Config so all enums are here
FeatureType::class.java -> this.asFeatureType() FeatureType::class.java -> this.asFeatureType()
// LoginMethod::class.java -> this.asLoginMethod() LoginMethod::class.java -> this.asLoginMethod()
LoginMode::class.java -> this.asLoginMode() LoginMode::class.java -> this.asLoginMode()
LoginType::class.java -> this.asLoginType() LoginType::class.java -> this.asLoginType()
// MetadataType::class.java -> this.asMetadataType() MetadataType::class.java -> this.asMetadataType()
// NotificationType::class.java -> this.asNotificationType() NotificationType::class.java -> this.asNotificationType()
NavTarget::class.java -> this.asNavTarget() NavTarget::class.java -> this.asNavTarget()
else -> throw IllegalArgumentException("Unknown type $type") else -> throw IllegalArgumentException("Unknown type $type")
} as E } as E

View File

@ -82,6 +82,7 @@
}, },
"university": { "university": {
"configOverrides": { "configOverrides": {
"timetableTrimHourRange": true,
"timetableColorSubjectName": true "timetableColorSubjectName": true
}, },
"uiConfig": { "uiConfig": {