From 63c5720f63667aaa4acc601b0f74568e56bb7ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Fri, 21 Oct 2022 23:59:53 +0200 Subject: [PATCH] [App] Move per-register settings to JSON resource. Rewrite Config to use delegates. (#150) * [App] Add base for AppData loading. * [UI] Fix timetable widget date navigation. * [UI] Migrate register-specific behavior to use AppData. * [App] Implement new delegate-based config base. * [Config] Migrate config and profile config. * [Config] Remove defaults from migrations. * [App] Apply event types and config overrides from AppData. * [Events] Change default event types for university type school. --- .idea/codeStyles/Project.xml | 7 + .idea/dictionaries/Kuba.xml | 1 + .../java/pl/szczodrzynski/edziennik/App.kt | 46 ++++- .../szczodrzynski/edziennik/MainActivity.kt | 15 +- .../edziennik/config/AbstractConfig.kt | 9 - .../szczodrzynski/edziennik/config/AppData.kt | 69 +++++++ .../edziennik/config/BaseConfig.kt | 45 +++++ .../szczodrzynski/edziennik/config/Config.kt | 142 +++----------- .../edziennik/config/ConfigGrades.kt | 13 +- .../edziennik/config/ConfigSync.kt | 150 ++++----------- .../edziennik/config/ConfigTimetable.kt | 23 +-- .../edziennik/config/ConfigUI.kt | 72 +++---- .../edziennik/config/DelegateConfig.kt | 175 +++++++++++++++++ .../edziennik/config/ProfileConfig.kt | 42 +---- .../config/ProfileConfigAttendance.kt | 28 +-- .../edziennik/config/ProfileConfigGrades.kt | 57 ++---- .../edziennik/config/ProfileConfigSync.kt | 16 +- .../edziennik/config/ProfileConfigUI.kt | 96 ++-------- .../edziennik/config/db/ConfigDao.kt | 4 +- .../config/utils/ConfigExtensions.kt | 113 ----------- .../edziennik/config/utils/ConfigGsonUtils.kt | 45 ----- .../edziennik/config/utils/ConfigMigration.kt | 68 +------ .../config/utils/ProfileConfigMigration.kt | 34 ++-- .../edziennik/data/db/dao/EventTypeDao.kt | 21 ++- .../edziennik/data/db/enums/LoginType.kt | 3 +- .../edziennik/data/db/enums/SchoolType.kt | 10 + .../edziennik/ext/DataExtensions.kt | 5 + .../edziennik/ext/JsonExtensions.kt | 22 ++- .../edziennik/ext/MiscExtensions.kt | 5 + .../edziennik/ui/agenda/AgendaFragment.kt | 4 +- .../announcements/AnnouncementsFragment.java | 6 +- .../ui/behaviour/BehaviourFragment.java | 4 +- .../edziennik/ui/behaviour/NoticesAdapter.kt | 3 +- .../edziennik/ui/home/HomeFragment.kt | 3 +- .../edziennik/ui/login/LoginSyncFragment.kt | 38 ++-- .../compose/MessagesComposeFragment.kt | 13 +- .../ui/messages/single/MessageFragment.kt | 2 +- .../ui/timetable/TimetableDayFragment.kt | 2 +- .../edziennik/ui/views/EventTypeDropdown.kt | 3 +- .../ui/widgets/WidgetConfigActivity.java | 2 +- .../timetable/WidgetTimetableProvider.kt | 6 +- app/src/main/res/raw/app_data.json | 176 ++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 43 files changed, 781 insertions(+), 818 deletions(-) delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/AbstractConfig.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/AppData.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/BaseConfig.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/DelegateConfig.kt delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ConfigExtensions.kt delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ConfigGsonUtils.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/enums/SchoolType.kt create mode 100644 app/src/main/res/raw/app_data.json diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index ab75be24..f7a03145 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -4,6 +4,13 @@