From e1dbc2f050187747b6140c684168ddddc28b4793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 1 Jul 2024 22:35:11 +0200 Subject: [PATCH] [App] Refactor app core modules, use Timber for logging (#205) * [App] Fix config migration issues * Move .sync to .core * Move .firebase, .network, .managers, .receivers, .sync to .core * Replace HyperLog with Timber * Cleanup logs every 7 days * Rename NotificationChannelManager, reformat App * Create FirebaseManager, ShortcutManager --- app/build.gradle | 2 +- app/proguard-rules.pro | 2 +- .../101.json | 2348 +++++++++++++++++ app/src/main/AndroidManifest.xml | 6 +- .../java/pl/szczodrzynski/edziennik/App.kt | 343 +-- .../szczodrzynski/edziennik/MainActivity.kt | 54 +- .../firebase/FirebaseSendException.kt | 2 +- .../firebase/FirebaseService.kt | 18 +- .../firebase/MyFirebaseService.kt | 11 +- .../firebase/SzkolnyAppFirebase.kt | 2 +- .../firebase/SzkolnyLibrusFirebase.kt | 2 +- .../firebase/SzkolnyMobidziennikFirebase.kt | 2 +- .../firebase/SzkolnyVulcanFirebase.kt | 2 +- .../manager}/AttendanceManager.kt | 2 +- .../manager}/AvailabilityManager.kt | 2 +- .../managers => core/manager}/BuildManager.kt | 20 +- .../managers => core/manager}/EventManager.kt | 2 +- .../edziennik/core/manager/FirebaseManager.kt | 99 + .../manager}/GradesManager.kt | 2 +- .../edziennik/core/manager/LoggingManager.kt | 68 + .../manager}/MessageManager.kt | 6 +- .../managers => core/manager}/NoteManager.kt | 2 +- .../core/manager/NotificationManager.kt | 115 + .../manager}/PermissionManager.kt | 2 +- .../edziennik/core/manager/ShortcutManager.kt | 76 + .../manager}/TextStylingManager.kt | 4 +- .../manager}/TimetableManager.kt | 7 +- .../managers => core/manager}/UiManager.kt | 6 +- .../manager}/UpdateManager.kt | 2 +- .../manager}/UserActionManager.kt | 8 +- .../cookie => core/network}/DumbCookie.kt | 2 +- .../cookie => core/network}/DumbCookieJar.kt | 2 +- .../receiver}/SzkolnyReceiver.kt | 2 +- .../receiver}/UserPresentReceiver.java | 2 +- .../work}/AppManagerDetectedEvent.kt | 4 +- .../{sync => core/work}/SyncWorker.kt | 10 +- .../{sync => core/work}/UpdateStateEvent.kt | 2 +- .../{sync => core/work}/UpdateWorker.kt | 9 +- .../{sync => core/work}/WorkerUtils.kt | 17 +- .../edziennik/data/api/ApiService.kt | 36 +- .../data/api/EdziennikNotification.kt | 4 +- .../data/api/edziennik/EdziennikTask.kt | 12 +- .../data/api/edziennik/ProfileArchiver.kt | 10 +- .../data/api/edziennik/librus/Librus.kt | 16 +- .../api/edziennik/librus/data/LibrusApi.kt | 4 +- .../api/edziennik/librus/data/LibrusData.kt | 3 +- .../edziennik/librus/data/LibrusMessages.kt | 10 +- .../api/edziennik/librus/data/LibrusPortal.kt | 8 +- .../edziennik/librus/data/LibrusSynergia.kt | 6 +- .../librus/data/api/LibrusApiTimetables.kt | 4 +- .../api/edziennik/librus/login/LibrusLogin.kt | 3 +- .../edziennik/librus/login/LibrusLoginApi.kt | 10 +- .../librus/login/LibrusLoginMessages.kt | 6 +- .../librus/login/LibrusLoginPortal.kt | 8 +- .../librus/login/LibrusLoginSynergia.kt | 6 +- .../librus/login/SynergiaTokenExtractor.kt | 4 +- .../edziennik/mobidziennik/Mobidziennik.kt | 16 +- .../mobidziennik/data/MobidziennikData.kt | 3 +- .../mobidziennik/data/MobidziennikWeb.kt | 6 +- .../data/api/MobidziennikApiEvents.kt | 5 +- .../data/api2/MobidziennikApi2Main.kt | 3 +- .../data/web/MobidziennikWebAttendance.kt | 4 +- .../mobidziennik/login/MobidziennikLogin.kt | 3 +- .../login/MobidziennikLoginApi2.kt | 3 +- .../login/MobidziennikLoginWeb.kt | 4 +- .../data/api/edziennik/podlasie/Podlasie.kt | 7 +- .../edziennik/podlasie/data/PodlasieApi.kt | 3 +- .../edziennik/podlasie/data/PodlasieData.kt | 3 +- .../edziennik/podlasie/login/PodlasieLogin.kt | 3 +- .../data/api/edziennik/template/Template.kt | 8 +- .../edziennik/template/data/TemplateData.kt | 3 +- .../edziennik/template/login/TemplateLogin.kt | 3 +- .../edziennik/data/api/edziennik/usos/Usos.kt | 8 +- .../data/api/edziennik/usos/data/UsosApi.kt | 4 +- .../data/api/edziennik/usos/data/UsosData.kt | 5 +- .../api/edziennik/usos/login/UsosLogin.kt | 4 +- .../api/edziennik/usos/login/UsosLoginApi.kt | 4 +- .../data/api/edziennik/vulcan/Vulcan.kt | 16 +- .../api/edziennik/vulcan/data/VulcanData.kt | 3 +- .../api/edziennik/vulcan/data/VulcanHebe.kt | 4 +- .../edziennik/vulcan/data/VulcanWebMain.kt | 3 +- .../vulcan/data/hebe/VulcanHebeTimetable.kt | 5 +- .../api/edziennik/vulcan/login/VulcanLogin.kt | 3 +- .../edziennik/data/api/models/Data.kt | 26 +- .../data/api/szkolny/interceptor/Signing.kt | 3 +- .../data/api/task/ErrorReportTask.kt | 3 +- .../data/api/task/PostNotifications.kt | 12 +- .../edziennik/data/api/task/SzkolnyTask.kt | 6 +- .../edziennik/data/config/AppData.kt | 2 +- .../edziennik/data/config/BaseConfig.kt | 15 +- .../edziennik/data/config/Config.kt | 9 +- .../edziennik/data/config/Delegate.kt | 6 +- .../edziennik/data/config/ProfileConfig.kt | 4 +- ...figMigration13.kt => ConfigMigration14.kt} | 4 +- .../szczodrzynski/edziennik/data/db/AppDb.kt | 7 +- .../edziennik/data/db/dao/DebugLogDao.java | 16 - .../edziennik/data/db/dao/LogDao.kt | 27 + .../edziennik/data/db/entity/DebugLog.java | 23 - .../edziennik/data/db/entity/LogEntry.kt | 20 + .../edziennik/data/db/entity/Notification.kt | 5 +- .../data/db/migration/Migration101.kt | 27 + .../edziennik/ext/ProfileExtensions.kt | 3 +- .../edziennik/ui/agenda/DayDialog.kt | 2 +- .../ui/agenda/event/AgendaEventRenderer.kt | 2 +- .../lessonchanges/LessonChangesAdapter.kt | 4 +- .../ui/attendance/AttendanceDetailsDialog.kt | 2 +- .../edziennik/ui/attendance/AttendanceView.kt | 2 +- .../viewholder/AttendanceViewHolder.kt | 2 +- .../edziennik/ui/debug/DebugFragment.java | 3 +- .../edziennik/ui/debug/LabPageFragment.kt | 8 + .../ui/debug/LabPlaygroundFragment.kt | 4 +- .../edziennik/ui/dialogs/StyledTextDialog.kt | 5 +- .../ui/dialogs/settings/GradesConfigDialog.kt | 18 +- .../ui/dialogs/sync/UpdateProgressDialog.kt | 2 +- .../edziennik/ui/event/EventManualDialog.kt | 5 +- .../edziennik/ui/feedback/FeedbackFragment.kt | 3 +- .../edziennik/ui/grades/GradeDetailsDialog.kt | 2 +- .../edziennik/ui/grades/GradeView.kt | 2 +- .../edziennik/ui/grades/GradesListFragment.kt | 2 +- .../ui/grades/editor/GradesEditorFragment.kt | 11 +- .../ui/grades/viewholder/GradeViewHolder.kt | 2 +- .../edziennik/ui/home/cards/HomeDebugCard.kt | 14 - .../ui/login/LoginChooserFragment.kt | 2 +- .../ui/login/LoginProgressFragment.kt | 2 +- .../ui/login/oauth/OAuthLoginActivity.kt | 4 +- .../compose/MessagesComposeFragment.kt | 13 +- .../ui/messages/list/MessageViewHolder.kt | 2 +- .../edziennik/ui/notes/NoteEditorDialog.kt | 4 +- .../NotificationsListFragment.kt | 3 +- .../ui/settings/SettingsLicenseActivity.kt | 8 - .../ui/settings/cards/SettingsSyncCard.kt | 7 +- .../timetable/GenerateBlockTimetableDialog.kt | 3 +- .../ui/timetable/LessonDetailsDialog.kt | 2 +- .../ui/timetable/TimetableDayFragment.kt | 4 +- .../edziennik/ui/views/AttachmentsView.kt | 3 +- .../ui/widgets/WidgetConfigActivity.java | 3 +- .../WidgetNotificationsProvider.kt | 3 +- .../timetable/WidgetTimetableFactory.java | 5 +- .../timetable/WidgetTimetableProvider.kt | 9 +- .../edziennik/utils/DebugLogFormat.kt | 10 - .../edziennik/utils/DefaultTextStyles.kt | 2 +- .../edziennik/utils/PermissionChecker.java | 8 +- .../szczodrzynski/edziennik/utils/Utils.java | 44 +- .../managers/NotificationChannelsManager.kt | 125 - .../edziennik/utils/models/Time.java | 8 +- .../edziennik/utils/models/Week.java | 4 +- app/src/main/res/layout/card_home_debug.xml | 6 - app/src/main/res/layout/lab_fragment.xml | 16 + .../edziennik/network/SSLProviderInstaller.kt | 3 +- .../edziennik/sync/UpdateDownloaderService.kt | 10 +- .../edziennik/sync/UpdateDownloaderService.kt | 3 +- 151 files changed, 3324 insertions(+), 858 deletions(-) create mode 100644 app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/FirebaseSendException.kt (93%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/FirebaseService.kt (92%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/MyFirebaseService.kt (77%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/SzkolnyAppFirebase.kt (99%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/SzkolnyLibrusFirebase.kt (99%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/SzkolnyMobidziennikFirebase.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{data => core}/firebase/SzkolnyVulcanFirebase.kt (97%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/AttendanceManager.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/AvailabilityManager.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/BuildManager.kt (94%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/EventManager.kt (98%) create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/core/manager/FirebaseManager.kt rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/GradesManager.kt (99%) create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/core/manager/LoggingManager.kt rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/MessageManager.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/NoteManager.kt (99%) create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NotificationManager.kt rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/PermissionManager.kt (99%) create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/core/manager/ShortcutManager.kt rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/TextStylingManager.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/TimetableManager.kt (92%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/UiManager.kt (94%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/UpdateManager.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{utils/managers => core/manager}/UserActionManager.kt (96%) rename app/src/main/java/pl/szczodrzynski/edziennik/{network/cookie => core/network}/DumbCookie.kt (97%) rename app/src/main/java/pl/szczodrzynski/edziennik/{network/cookie => core/network}/DumbCookieJar.kt (98%) rename app/src/main/java/pl/szczodrzynski/edziennik/{receivers => core/receiver}/SzkolnyReceiver.kt (96%) rename app/src/main/java/pl/szczodrzynski/edziennik/{receivers => core/receiver}/UserPresentReceiver.java (96%) rename app/src/main/java/pl/szczodrzynski/edziennik/{sync => core/work}/AppManagerDetectedEvent.kt (57%) rename app/src/main/java/pl/szczodrzynski/edziennik/{sync => core/work}/SyncWorker.kt (90%) rename app/src/main/java/pl/szczodrzynski/edziennik/{sync => core/work}/UpdateStateEvent.kt (82%) rename app/src/main/java/pl/szczodrzynski/edziennik/{sync => core/work}/UpdateWorker.kt (91%) rename app/src/main/java/pl/szczodrzynski/edziennik/{sync => core/work}/WorkerUtils.kt (73%) rename app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/{ConfigMigration13.kt => ConfigMigration14.kt} (95%) delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/DebugLogDao.java create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/LogDao.kt delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/DebugLog.java create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/LogEntry.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/db/migration/Migration101.kt delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/utils/DebugLogFormat.kt delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NotificationChannelsManager.kt diff --git a/app/build.gradle b/app/build.gradle index 08e69799..1e80a563 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -240,11 +240,11 @@ dependencies { implementation "com.github.ChuckerTeam.Chucker:library:3.5.2" // https://github.com/ChuckerTeam/chucker implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2" // https://github.com/antonKozyriatskyi/CircularProgressIndicator implementation "com.github.bassaer:chatmessageview:2.0.1" // https://github.com/bassaer/ChatMessageView - implementation "com.github.hypertrack:hyperlog-android:0.0.10" // https://github.com/hypertrack/hyperlog-android implementation "com.github.smuyyh:JsonViewer:V1.0.6" // https://github.com/smuyyh/JsonViewer implementation "com.github.underwindfall.PowerPermission:powerpermission-coroutines:1.4.0" // https://github.com/underwindfall/PowerPermission implementation "com.github.underwindfall.PowerPermission:powerpermission:1.4.0" // https://github.com/underwindfall/PowerPermission implementation "com.github.wulkanowy.uonet-request-signer:hebe-jvm:a99ca50a31" // https://github.com/wulkanowy/uonet-request-signer + implementation 'com.jakewharton.timber:timber:5.0.1' implementation "com.jaredrummler:colorpicker:1.1.0" implementation "io.coil-kt:coil:1.1.1" implementation "me.dm7.barcodescanner:zxing:1.9.8" diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index c06827e5..c4b81a88 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -37,7 +37,7 @@ -keepnames class pl.szczodrzynski.edziennik.ui.widgets.luckynumber.WidgetLuckyNumberProvider -keep class pl.szczodrzynski.edziennik.data.config.AppData { *; } -keep class pl.szczodrzynski.edziennik.data.config.AppData$** { *; } --keep class pl.szczodrzynski.edziennik.utils.managers.TextStylingManager$HtmlMode { *; } +-keep class pl.szczodrzynski.edziennik.core.manager.TextStylingManager$HtmlMode { *; } -keepnames class androidx.appcompat.view.menu.MenuBuilder { setHeaderTitleInt(java.lang.CharSequence); } -keepnames class androidx.appcompat.view.menu.MenuPopupHelper { showPopup(int, int, boolean, boolean); } diff --git a/app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json b/app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json new file mode 100644 index 00000000..d01559a4 --- /dev/null +++ b/app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/101.json @@ -0,0 +1,2348 @@ +{ + "formatVersion": 1, + "database": { + "version": 101, + "identityHash": "14e4b0e50eedd9a1f55e7f08819a9da7", + "entities": [ + { + "tableName": "grades", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `gradeId` INTEGER NOT NULL, `gradeName` TEXT NOT NULL, `gradeType` INTEGER NOT NULL, `gradeValue` REAL NOT NULL, `gradeWeight` REAL NOT NULL, `gradeColor` INTEGER NOT NULL, `gradeCategory` TEXT, `gradeDescription` TEXT, `gradeComment` TEXT, `gradeSemester` INTEGER NOT NULL, `teacherId` INTEGER NOT NULL, `subjectId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `gradeValueMax` REAL, `gradeClassAverage` REAL, `gradeParentId` INTEGER, `gradeIsImprovement` INTEGER NOT NULL, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `gradeId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "gradeId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "gradeName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "gradeType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "value", + "columnName": "gradeValue", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "gradeWeight", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "gradeColor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "gradeCategory", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "gradeDescription", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "comment", + "columnName": "gradeComment", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "semester", + "columnName": "gradeSemester", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "valueMax", + "columnName": "gradeValueMax", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "classAverage", + "columnName": "gradeClassAverage", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "parentId", + "columnName": "gradeParentId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "isImprovement", + "columnName": "gradeIsImprovement", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "gradeId" + ] + }, + "indices": [ + { + "name": "index_grades_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_grades_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "teachers", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `teacherId` INTEGER NOT NULL, `teacherLoginId` TEXT, `teacherName` TEXT, `teacherSurname` TEXT, `teacherType` INTEGER NOT NULL, `teacherTypeDescription` TEXT, `teacherSubjects` TEXT NOT NULL, PRIMARY KEY(`profileId`, `teacherId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "loginId", + "columnName": "teacherLoginId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "teacherName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "surname", + "columnName": "teacherSurname", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "teacherType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "typeDescription", + "columnName": "teacherTypeDescription", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "subjects", + "columnName": "teacherSubjects", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "teacherId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "teacherAbsence", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `teacherAbsenceId` INTEGER NOT NULL, `teacherAbsenceType` INTEGER NOT NULL, `teacherAbsenceName` TEXT, `teacherAbsenceDateFrom` TEXT NOT NULL, `teacherAbsenceDateTo` TEXT NOT NULL, `teacherAbsenceTimeFrom` TEXT, `teacherAbsenceTimeTo` TEXT, `teacherId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `teacherAbsenceId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "teacherAbsenceId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "teacherAbsenceType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "teacherAbsenceName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "dateFrom", + "columnName": "teacherAbsenceDateFrom", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "dateTo", + "columnName": "teacherAbsenceDateTo", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "timeFrom", + "columnName": "teacherAbsenceTimeFrom", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "timeTo", + "columnName": "teacherAbsenceTimeTo", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "teacherAbsenceId" + ] + }, + "indices": [ + { + "name": "index_teacherAbsence_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_teacherAbsence_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "teacherAbsenceTypes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `teacherAbsenceTypeId` INTEGER NOT NULL, `teacherAbsenceTypeName` TEXT NOT NULL, PRIMARY KEY(`profileId`, `teacherAbsenceTypeId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "teacherAbsenceTypeId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "teacherAbsenceTypeName", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "teacherAbsenceTypeId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "subjects", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `subjectId` INTEGER NOT NULL, `subjectLongName` TEXT, `subjectShortName` TEXT, `subjectColor` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `subjectId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "longName", + "columnName": "subjectLongName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "shortName", + "columnName": "subjectShortName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "color", + "columnName": "subjectColor", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "subjectId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notices", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `noticeId` INTEGER NOT NULL, `noticeType` INTEGER NOT NULL, `noticeSemester` INTEGER NOT NULL, `noticeText` TEXT NOT NULL, `noticeCategory` TEXT, `noticePoints` REAL, `teacherId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `noticeId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "noticeId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "noticeType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "semester", + "columnName": "noticeSemester", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "noticeText", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "noticeCategory", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "points", + "columnName": "noticePoints", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "noticeId" + ] + }, + "indices": [ + { + "name": "index_notices_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notices_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "teams", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `teamId` INTEGER NOT NULL, `teamType` INTEGER NOT NULL, `teamName` TEXT, `teamCode` TEXT, `teamTeacherId` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `teamId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "teamId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "teamType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "teamName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "code", + "columnName": "teamCode", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teamTeacherId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "teamId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "attendances", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `attendanceId` INTEGER NOT NULL, `attendanceBaseType` INTEGER NOT NULL, `attendanceTypeName` TEXT NOT NULL, `attendanceTypeShort` TEXT NOT NULL, `attendanceTypeSymbol` TEXT NOT NULL, `attendanceTypeColor` INTEGER, `attendanceDate` TEXT NOT NULL, `attendanceTime` TEXT, `attendanceSemester` INTEGER NOT NULL, `teacherId` INTEGER NOT NULL, `subjectId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `attendanceLessonTopic` TEXT, `attendanceLessonNumber` INTEGER, `attendanceIsCounted` INTEGER NOT NULL, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `attendanceId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "attendanceId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "baseType", + "columnName": "attendanceBaseType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "typeName", + "columnName": "attendanceTypeName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeShort", + "columnName": "attendanceTypeShort", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeSymbol", + "columnName": "attendanceTypeSymbol", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeColor", + "columnName": "attendanceTypeColor", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "date", + "columnName": "attendanceDate", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "startTime", + "columnName": "attendanceTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "semester", + "columnName": "attendanceSemester", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lessonTopic", + "columnName": "attendanceLessonTopic", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lessonNumber", + "columnName": "attendanceLessonNumber", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "isCounted", + "columnName": "attendanceIsCounted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "attendanceId" + ] + }, + "indices": [ + { + "name": "index_attendances_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_attendances_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "events", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `eventId` INTEGER NOT NULL, `eventDate` TEXT NOT NULL, `eventTime` TEXT, `eventTopic` TEXT NOT NULL, `eventColor` INTEGER, `eventType` INTEGER NOT NULL, `teacherId` INTEGER NOT NULL, `subjectId` INTEGER NOT NULL, `teamId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `eventAddedManually` INTEGER NOT NULL, `eventSharedBy` TEXT, `eventSharedByName` TEXT, `eventBlacklisted` INTEGER NOT NULL, `eventIsDone` INTEGER NOT NULL, `eventIsDownloaded` INTEGER NOT NULL, `homeworkBody` TEXT, `attachmentIds` TEXT, `attachmentNames` TEXT, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `eventId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "eventId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "date", + "columnName": "eventDate", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "time", + "columnName": "eventTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "topic", + "columnName": "eventTopic", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "eventColor", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "eventType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teamId", + "columnName": "teamId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedManually", + "columnName": "eventAddedManually", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "sharedBy", + "columnName": "eventSharedBy", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sharedByName", + "columnName": "eventSharedByName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "blacklisted", + "columnName": "eventBlacklisted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDone", + "columnName": "eventIsDone", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDownloaded", + "columnName": "eventIsDownloaded", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "homeworkBody", + "columnName": "homeworkBody", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "attachmentIds", + "columnName": "attachmentIds", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "attachmentNames", + "columnName": "attachmentNames", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "eventId" + ] + }, + "indices": [ + { + "name": "index_events_profileId_eventDate_eventTime", + "unique": false, + "columnNames": [ + "profileId", + "eventDate", + "eventTime" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_events_profileId_eventDate_eventTime` ON `${TABLE_NAME}` (`profileId`, `eventDate`, `eventTime`)" + }, + { + "name": "index_events_profileId_eventType", + "unique": false, + "columnNames": [ + "profileId", + "eventType" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_events_profileId_eventType` ON `${TABLE_NAME}` (`profileId`, `eventType`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "eventTypes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `eventType` INTEGER NOT NULL, `eventTypeName` TEXT NOT NULL, `eventTypeColor` INTEGER NOT NULL, `eventTypeOrder` INTEGER NOT NULL, `eventTypeSource` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `eventType`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "eventType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "eventTypeName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "eventTypeColor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "order", + "columnName": "eventTypeOrder", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "source", + "columnName": "eventTypeSource", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "eventType" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "loginStores", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`loginStoreId` INTEGER NOT NULL, `loginStoreType` INTEGER NOT NULL, `loginStoreMode` INTEGER NOT NULL, `loginStoreData` TEXT NOT NULL, PRIMARY KEY(`loginStoreId`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "loginStoreId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "loginStoreType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "mode", + "columnName": "loginStoreMode", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "data", + "columnName": "loginStoreData", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "loginStoreId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "profiles", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `loginStoreId` INTEGER NOT NULL, `loginStoreType` INTEGER NOT NULL, `name` TEXT NOT NULL, `subname` TEXT, `studentNameLong` TEXT NOT NULL, `studentNameShort` TEXT NOT NULL, `accountName` TEXT, `studentData` TEXT NOT NULL, `image` TEXT, `empty` INTEGER NOT NULL, `archived` INTEGER NOT NULL, `syncEnabled` INTEGER NOT NULL, `enableSharedEvents` INTEGER NOT NULL, `registration` INTEGER NOT NULL, `userCode` TEXT NOT NULL, `archiveId` INTEGER, `studentNumber` INTEGER NOT NULL, `studentClassName` TEXT, `studentSchoolYearStart` INTEGER NOT NULL, `dateSemester1Start` TEXT NOT NULL, `dateSemester2Start` TEXT NOT NULL, `dateYearEnd` TEXT NOT NULL, `disabledNotifications` TEXT, `lastReceiversSync` INTEGER NOT NULL, PRIMARY KEY(`profileId`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "loginStoreId", + "columnName": "loginStoreId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "loginStoreType", + "columnName": "loginStoreType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "subname", + "columnName": "subname", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "studentNameLong", + "columnName": "studentNameLong", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "studentNameShort", + "columnName": "studentNameShort", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountName", + "columnName": "accountName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "studentData", + "columnName": "studentData", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "image", + "columnName": "image", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "empty", + "columnName": "empty", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "archived", + "columnName": "archived", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "syncEnabled", + "columnName": "syncEnabled", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "unused1", + "columnName": "enableSharedEvents", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "registration", + "columnName": "registration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userCode", + "columnName": "userCode", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "archiveId", + "columnName": "archiveId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "studentNumber", + "columnName": "studentNumber", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "studentClassName", + "columnName": "studentClassName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "studentSchoolYearStart", + "columnName": "studentSchoolYearStart", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateSemester1Start", + "columnName": "dateSemester1Start", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "dateSemester2Start", + "columnName": "dateSemester2Start", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "dateYearEnd", + "columnName": "dateYearEnd", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "disabledNotifications", + "columnName": "disabledNotifications", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lastReceiversSync", + "columnName": "lastReceiversSync", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "luckyNumbers", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `luckyNumberDate` INTEGER NOT NULL, `luckyNumber` INTEGER NOT NULL, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `luckyNumberDate`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "date", + "columnName": "luckyNumberDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "number", + "columnName": "luckyNumber", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "luckyNumberDate" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "announcements", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `announcementId` INTEGER NOT NULL, `announcementSubject` TEXT NOT NULL, `announcementText` TEXT, `announcementStartDate` TEXT, `announcementEndDate` TEXT, `teacherId` INTEGER NOT NULL, `addedDate` INTEGER NOT NULL, `announcementIdString` TEXT, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `announcementId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "announcementId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subject", + "columnName": "announcementSubject", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "announcementText", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "startDate", + "columnName": "announcementStartDate", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endDate", + "columnName": "announcementEndDate", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "idString", + "columnName": "announcementIdString", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "announcementId" + ] + }, + "indices": [ + { + "name": "index_announcements_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_announcements_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "gradeCategories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `categoryId` INTEGER NOT NULL, `weight` REAL NOT NULL, `color` INTEGER NOT NULL, `text` TEXT, `columns` TEXT, `valueFrom` REAL NOT NULL, `valueTo` REAL NOT NULL, `type` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `categoryId`, `type`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "categoryId", + "columnName": "categoryId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "weight", + "columnName": "weight", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "columns", + "columnName": "columns", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "valueFrom", + "columnName": "valueFrom", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "valueTo", + "columnName": "valueTo", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "categoryId", + "type" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "feedbackMessages", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `received` INTEGER NOT NULL, `text` TEXT NOT NULL, `senderName` TEXT NOT NULL, `deviceId` TEXT, `deviceName` TEXT, `devId` INTEGER, `devImage` TEXT, `sentTime` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "messageId", + "columnName": "messageId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "received", + "columnName": "received", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "senderName", + "columnName": "senderName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "deviceId", + "columnName": "deviceId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "deviceName", + "columnName": "deviceName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "devId", + "columnName": "devId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "devImage", + "columnName": "devImage", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sentTime", + "columnName": "sentTime", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "messageId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "messages", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `messageId` INTEGER NOT NULL, `messageType` INTEGER NOT NULL, `messageSubject` TEXT NOT NULL, `messageBody` TEXT, `senderId` INTEGER, `addedDate` INTEGER NOT NULL, `messageIsPinned` INTEGER NOT NULL, `hasAttachments` INTEGER NOT NULL, `attachmentIds` TEXT, `attachmentNames` TEXT, `attachmentSizes` TEXT, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `messageId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "messageId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "messageType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subject", + "columnName": "messageSubject", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "body", + "columnName": "messageBody", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "senderId", + "columnName": "senderId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isStarred", + "columnName": "messageIsPinned", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasAttachments", + "columnName": "hasAttachments", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "attachmentIds", + "columnName": "attachmentIds", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "attachmentNames", + "columnName": "attachmentNames", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "attachmentSizes", + "columnName": "attachmentSizes", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "messageId" + ] + }, + "indices": [ + { + "name": "index_messages_profileId_messageType", + "unique": false, + "columnNames": [ + "profileId", + "messageType" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_messages_profileId_messageType` ON `${TABLE_NAME}` (`profileId`, `messageType`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "messageRecipients", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `messageRecipientId` INTEGER NOT NULL, `messageRecipientReplyId` INTEGER NOT NULL, `messageRecipientReadDate` INTEGER NOT NULL, `messageId` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `messageRecipientId`, `messageId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "messageRecipientId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "replyId", + "columnName": "messageRecipientReplyId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "readDate", + "columnName": "messageRecipientReadDate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "messageId", + "columnName": "messageId", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "messageRecipientId", + "messageId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "logs", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `priority` INTEGER NOT NULL, `tag` TEXT, `message` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "priority", + "columnName": "priority", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "tag", + "columnName": "tag", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "message", + "columnName": "message", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_logs_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_logs_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "endpointTimers", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `endpointId` INTEGER NOT NULL, `endpointLastSync` INTEGER, `endpointNextSync` INTEGER NOT NULL, `endpointViewId` INTEGER, PRIMARY KEY(`profileId`, `endpointId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "endpointId", + "columnName": "endpointId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastSync", + "columnName": "endpointLastSync", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "nextSync", + "columnName": "endpointNextSync", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "featureType", + "columnName": "endpointViewId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "endpointId" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "lessonRanges", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `lessonRangeNumber` INTEGER NOT NULL, `lessonRangeStart` TEXT NOT NULL, `lessonRangeEnd` TEXT NOT NULL, PRIMARY KEY(`profileId`, `lessonRangeNumber`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lessonNumber", + "columnName": "lessonRangeNumber", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "startTime", + "columnName": "lessonRangeStart", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "endTime", + "columnName": "lessonRangeEnd", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "lessonRangeNumber" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `text` TEXT NOT NULL, `textLong` TEXT, `type` INTEGER NOT NULL, `profileId` INTEGER, `profileName` TEXT, `posted` INTEGER NOT NULL, `viewId` INTEGER, `extras` TEXT, `addedDate` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "textLong", + "columnName": "textLong", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "profileName", + "columnName": "profileName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "posted", + "columnName": "posted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "navTarget", + "columnName": "viewId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "extras", + "columnName": "extras", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "classrooms", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `name` TEXT NOT NULL, PRIMARY KEY(`profileId`, `id`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "noticeTypes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `name` TEXT NOT NULL, PRIMARY KEY(`profileId`, `id`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "attendanceTypes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `baseType` INTEGER NOT NULL, `typeName` TEXT NOT NULL, `typeShort` TEXT NOT NULL, `typeSymbol` TEXT NOT NULL, `typeColor` INTEGER, PRIMARY KEY(`profileId`, `id`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "baseType", + "columnName": "baseType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "typeName", + "columnName": "typeName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeShort", + "columnName": "typeShort", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeSymbol", + "columnName": "typeSymbol", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "typeColor", + "columnName": "typeColor", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "timetable", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `type` INTEGER NOT NULL, `date` TEXT, `lessonNumber` INTEGER, `startTime` TEXT, `endTime` TEXT, `subjectId` INTEGER, `teacherId` INTEGER, `teamId` INTEGER, `classroom` TEXT, `oldDate` TEXT, `oldLessonNumber` INTEGER, `oldStartTime` TEXT, `oldEndTime` TEXT, `oldSubjectId` INTEGER, `oldTeacherId` INTEGER, `oldTeamId` INTEGER, `oldClassroom` TEXT, `isExtra` INTEGER NOT NULL, `ownerId` INTEGER NOT NULL, `color` INTEGER, `keep` INTEGER NOT NULL, PRIMARY KEY(`profileId`, `id`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "date", + "columnName": "date", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lessonNumber", + "columnName": "lessonNumber", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "startTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endTime", + "columnName": "endTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "teamId", + "columnName": "teamId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "classroom", + "columnName": "classroom", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "oldDate", + "columnName": "oldDate", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "oldLessonNumber", + "columnName": "oldLessonNumber", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "oldStartTime", + "columnName": "oldStartTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "oldEndTime", + "columnName": "oldEndTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "oldSubjectId", + "columnName": "oldSubjectId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "oldTeacherId", + "columnName": "oldTeacherId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "oldTeamId", + "columnName": "oldTeamId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "oldClassroom", + "columnName": "oldClassroom", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isExtra", + "columnName": "isExtra", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "ownerId", + "columnName": "ownerId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "keep", + "columnName": "keep", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "id" + ] + }, + "indices": [ + { + "name": "index_timetable_profileId_type_date", + "unique": false, + "columnNames": [ + "profileId", + "type", + "date" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_timetable_profileId_type_date` ON `${TABLE_NAME}` (`profileId`, `type`, `date`)" + }, + { + "name": "index_timetable_profileId_type_oldDate", + "unique": false, + "columnNames": [ + "profileId", + "type", + "oldDate" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_timetable_profileId_type_oldDate` ON `${TABLE_NAME}` (`profileId`, `type`, `oldDate`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "config", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `key` TEXT NOT NULL, `value` TEXT, PRIMARY KEY(`profileId`, `key`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "key" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "librusLessons", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `lessonId` INTEGER NOT NULL, `teacherId` INTEGER NOT NULL, `subjectId` INTEGER NOT NULL, `teamId` INTEGER, PRIMARY KEY(`profileId`, `lessonId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lessonId", + "columnName": "lessonId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "teamId", + "columnName": "teamId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "profileId", + "lessonId" + ] + }, + "indices": [ + { + "name": "index_librusLessons_profileId", + "unique": false, + "columnNames": [ + "profileId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_librusLessons_profileId` ON `${TABLE_NAME}` (`profileId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "timetableManual", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `type` INTEGER NOT NULL, `repeatBy` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `date` INTEGER, `weekDay` INTEGER, `lessonNumber` INTEGER, `startTime` TEXT, `endTime` TEXT, `subjectId` INTEGER, `teacherId` INTEGER, `teamId` INTEGER, `classroom` TEXT)", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "repeatBy", + "columnName": "repeatBy", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "date", + "columnName": "date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "weekDay", + "columnName": "weekDay", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lessonNumber", + "columnName": "lessonNumber", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "startTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endTime", + "columnName": "endTime", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "subjectId", + "columnName": "subjectId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "teacherId", + "columnName": "teacherId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "teamId", + "columnName": "teamId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "classroom", + "columnName": "classroom", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_timetableManual_profileId_date", + "unique": false, + "columnNames": [ + "profileId", + "date" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_timetableManual_profileId_date` ON `${TABLE_NAME}` (`profileId`, `date`)" + }, + { + "name": "index_timetableManual_profileId_weekDay", + "unique": false, + "columnNames": [ + "profileId", + "weekDay" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_timetableManual_profileId_weekDay` ON `${TABLE_NAME}` (`profileId`, `weekDay`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "notes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `noteId` INTEGER NOT NULL, `noteOwnerType` TEXT, `noteOwnerId` INTEGER, `noteReplacesOriginal` INTEGER NOT NULL, `noteTopic` TEXT, `noteBody` TEXT NOT NULL, `noteColor` INTEGER, `noteSharedBy` TEXT, `noteSharedByName` TEXT, `addedDate` INTEGER NOT NULL, PRIMARY KEY(`noteId`))", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "noteId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "ownerType", + "columnName": "noteOwnerType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "ownerId", + "columnName": "noteOwnerId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "replacesOriginal", + "columnName": "noteReplacesOriginal", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "topic", + "columnName": "noteTopic", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "body", + "columnName": "noteBody", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "noteColor", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "sharedBy", + "columnName": "noteSharedBy", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sharedByName", + "columnName": "noteSharedByName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "addedDate", + "columnName": "addedDate", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "noteId" + ] + }, + "indices": [ + { + "name": "index_notes_profileId_noteOwnerType_noteOwnerId", + "unique": false, + "columnNames": [ + "profileId", + "noteOwnerType", + "noteOwnerId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notes_profileId_noteOwnerType_noteOwnerId` ON `${TABLE_NAME}` (`profileId`, `noteOwnerType`, `noteOwnerId`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "metadata", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`profileId` INTEGER NOT NULL, `metadataId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `thingType` INTEGER NOT NULL, `thingId` INTEGER NOT NULL, `seen` INTEGER NOT NULL, `notified` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "profileId", + "columnName": "profileId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "metadataId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "thingType", + "columnName": "thingType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "thingId", + "columnName": "thingId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "seen", + "columnName": "seen", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "notified", + "columnName": "notified", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "metadataId" + ] + }, + "indices": [ + { + "name": "index_metadata_profileId_thingType_thingId", + "unique": true, + "columnNames": [ + "profileId", + "thingType", + "thingId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_metadata_profileId_thingType_thingId` ON `${TABLE_NAME}` (`profileId`, `thingType`, `thingId`)" + } + ], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '14e4b0e50eedd9a1f55e7f08819a9da7')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0818551c..3f5cd18b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -173,7 +173,7 @@ | | \ \ __/ (_| __/ |\ V / __/ | \__ \ |_| \_\___|\___\___|_| \_/ \___|_| |___/ --> - @@ -186,7 +186,7 @@ - @@ -201,7 +201,7 @@ |_____/ \___|_| \_/ |_|\___\___||___/ --> - diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt index e558de53..f760e1af 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt @@ -4,12 +4,6 @@ package pl.szczodrzynski.edziennik -import android.content.Intent -import android.content.pm.PackageManager -import android.content.pm.ShortcutInfo -import android.content.pm.ShortcutManager -import android.graphics.drawable.Icon -import android.os.Build import android.provider.Settings import android.util.Log import android.widget.Toast @@ -20,12 +14,7 @@ import cat.ereza.customactivityoncrash.config.CaocConfig import com.chuckerteam.chucker.api.ChuckerCollector import com.chuckerteam.chucker.api.ChuckerInterceptor import com.chuckerteam.chucker.api.RetentionManager -import com.google.firebase.FirebaseApp -import com.google.firebase.FirebaseOptions -import com.google.firebase.iid.FirebaseInstanceId -import com.google.firebase.messaging.FirebaseMessaging import com.google.gson.Gson -import com.hypertrack.hyperlog.HyperLog import com.mikepenz.iconics.Iconics import im.wangchao.mhttp.MHttp import kotlinx.coroutines.CoroutineScope @@ -36,41 +25,39 @@ import kotlinx.coroutines.withContext import me.leolin.shortcutbadger.ShortcutBadger import okhttp3.OkHttpClient import org.greenrobot.eventbus.EventBus -import pl.szczodrzynski.edziennik.data.config.AppData -import pl.szczodrzynski.edziennik.data.config.Config +import pl.szczodrzynski.edziennik.core.manager.AttendanceManager +import pl.szczodrzynski.edziennik.core.manager.AvailabilityManager +import pl.szczodrzynski.edziennik.core.manager.BuildManager +import pl.szczodrzynski.edziennik.core.manager.EventManager +import pl.szczodrzynski.edziennik.core.manager.FirebaseManager +import pl.szczodrzynski.edziennik.core.manager.GradesManager +import pl.szczodrzynski.edziennik.core.manager.LoggingManager +import pl.szczodrzynski.edziennik.core.manager.MessageManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NotificationManager +import pl.szczodrzynski.edziennik.core.manager.PermissionManager +import pl.szczodrzynski.edziennik.core.manager.ShortcutManager +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager +import pl.szczodrzynski.edziennik.core.manager.TimetableManager +import pl.szczodrzynski.edziennik.core.manager.UiManager +import pl.szczodrzynski.edziennik.core.manager.UpdateManager +import pl.szczodrzynski.edziennik.core.manager.UserActionManager +import pl.szczodrzynski.edziennik.core.network.DumbCookieJar +import pl.szczodrzynski.edziennik.core.work.SyncWorker +import pl.szczodrzynski.edziennik.core.work.UpdateWorker import pl.szczodrzynski.edziennik.data.api.events.ProfileListEmptyEvent import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi import pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing +import pl.szczodrzynski.edziennik.data.config.AppData +import pl.szczodrzynski.edziennik.data.config.Config import pl.szczodrzynski.edziennik.data.db.AppDb import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.data.enums.LoginType -import pl.szczodrzynski.edziennik.ext.DAY -import pl.szczodrzynski.edziennik.ext.MS -import pl.szczodrzynski.edziennik.ext.putExtras import pl.szczodrzynski.edziennik.network.SSLProviderInstaller -import pl.szczodrzynski.edziennik.network.cookie.DumbCookieJar -import pl.szczodrzynski.edziennik.sync.SyncWorker -import pl.szczodrzynski.edziennik.sync.UpdateWorker import pl.szczodrzynski.edziennik.ui.base.CrashActivity -import pl.szczodrzynski.edziennik.data.enums.NavTarget -import pl.szczodrzynski.edziennik.utils.DebugLogFormat import pl.szczodrzynski.edziennik.utils.PermissionChecker import pl.szczodrzynski.edziennik.utils.Utils -import pl.szczodrzynski.edziennik.utils.Utils.d -import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager -import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager -import pl.szczodrzynski.edziennik.utils.managers.BuildManager -import pl.szczodrzynski.edziennik.utils.managers.EventManager -import pl.szczodrzynski.edziennik.utils.managers.GradesManager -import pl.szczodrzynski.edziennik.utils.managers.MessageManager -import pl.szczodrzynski.edziennik.utils.managers.NoteManager -import pl.szczodrzynski.edziennik.utils.managers.NotificationChannelsManager -import pl.szczodrzynski.edziennik.utils.managers.PermissionManager -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager -import pl.szczodrzynski.edziennik.utils.managers.UiManager -import pl.szczodrzynski.edziennik.utils.managers.TimetableManager -import pl.szczodrzynski.edziennik.utils.managers.UpdateManager -import pl.szczodrzynski.edziennik.utils.managers.UserActionManager +import timber.log.Timber import java.util.concurrent.TimeUnit import kotlin.coroutines.CoroutineContext import kotlin.system.exitProcess @@ -81,7 +68,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { lateinit var db: AppDb private set lateinit var config: Config - // private set // for LabFragment + + // private set // for LabFragment lateinit var profile: Profile private set lateinit var data: AppData @@ -98,11 +86,14 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { val availabilityManager by lazy { AvailabilityManager(this) } val buildManager by lazy { BuildManager(this) } val eventManager by lazy { EventManager(this) } + val firebaseManager by lazy { FirebaseManager(this) } val gradesManager by lazy { GradesManager(this) } + val loggingManager by lazy { LoggingManager(this) } val messageManager by lazy { MessageManager(this) } val noteManager by lazy { NoteManager(this) } - val notificationChannelsManager by lazy { NotificationChannelsManager(this) } + val notificationManager by lazy { NotificationManager(this) } val permissionManager by lazy { PermissionManager(this) } + val shortcutManager by lazy { ShortcutManager(this) } val textStylingManager by lazy { TextStylingManager(this) } val timetableManager by lazy { TimetableManager(this) } val uiManager by lazy { UiManager(this) } @@ -125,8 +116,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { get() = job + Dispatchers.Main override val workManagerConfiguration: Configuration = Configuration.Builder() - .setMinimumLoggingLevel(Log.VERBOSE) - .build() + .setMinimumLoggingLevel(Log.VERBOSE) + .build() val permissionChecker by lazy { PermissionChecker(this) } val gson by lazy { Gson() } @@ -155,7 +146,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { if (devMode) { if (enableChucker) { - val chuckerCollector = ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR) + val chuckerCollector = + ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR) val chuckerInterceptor = ChuckerInterceptor(this, chuckerCollector) builder.addInterceptor(chuckerInterceptor) } @@ -170,6 +162,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { MHttp.instance().customOkHttpClient(http) } + val cookieJar by lazy { DumbCookieJar(this) } /* _____ _ _ @@ -180,7 +173,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { |_____/|_|\__, |_| |_|\__,_|\__|\__,_|_| \___| __/ | |__*/ - val deviceId: String by lazy { Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) ?: "" } + val deviceId: String by lazy { + Settings.Secure.getString( + contentResolver, + Settings.Secure.ANDROID_ID + ) ?: "" + } private var unreadBadgesAvailable = true /* _____ _ @@ -191,225 +189,77 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { \___/|_| |_|\_____|_| \___|\__,_|\__\__*/ override fun onCreate() { super.onCreate() - AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) - CaocConfig.Builder.create() - .backgroundMode(CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM) - .enabled(true) - .showErrorDetails(true) - .showRestartButton(true) - .logErrorOnRestart(true) - .trackActivities(true) - .minTimeBetweenCrashesMs(60*1000) - .errorDrawable(R.drawable.ic_rip) - .restartActivity(MainActivity::class.java) - .errorActivity(CrashActivity::class.java) - .apply() - Iconics.init(applicationContext) - Iconics.respectFontBoundsDefault = true - // initialize companion object values + // initialize Timber to enable basic logging + Timber.plant(loggingManager.logcatTree) + Timber.i("Initializing Szkolny.eu app v${BuildConfig.VERSION_NAME}") + // initialize core objects AppData.read(this) App.db = AppDb(this) + // read and migrate global config App.config = Config(this) App.config.migrate() + // add database logging to Timber + Timber.plant(loggingManager.databaseTree) + Timber.i("Initialized Szkolny.eu app v${BuildConfig.VERSION_NAME}") devMode = config.devMode ?: BuildConfig.DEBUG if (config.devModePassword != null) checkDevModePassword() - enableChucker = config.enableChucker ?: devMode + + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) + CaocConfig.Builder.create() + .backgroundMode(CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM) + .enabled(true) + .showErrorDetails(true) + .showRestartButton(true) + .logErrorOnRestart(true) + .trackActivities(true) + .minTimeBetweenCrashesMs(60 * 1000) + .errorDrawable(R.drawable.ic_rip) + .restartActivity(MainActivity::class.java) + .errorActivity(CrashActivity::class.java) + .apply() + Iconics.init(applicationContext) + Iconics.respectFontBoundsDefault = true + Signing.getCert(this) + Utils.initializeStorageDir(this) + buildHttp() + uiManager.applyNightMode() uiManager.applyLanguage(this) - if (devMode) { - HyperLog.initialize(this) - HyperLog.setLogLevel(Log.VERBOSE) - HyperLog.setLogFormat(DebugLogFormat(this)) - } - if (!profileLoadById(config.lastProfileId)) { val success = db.profileDao().firstId?.let { profileLoadById(it) } if (success != true) profileLoad(Profile(0, 0, LoginType.TEMPLATE, "")) } - buildHttp() + launch(Dispatchers.Default) { + buildManager.fetchInstalledTime() + firebaseManager.initializeApps() + loggingManager.cleanupIfNeeded() + loggingManager.cleanupHyperLogDatabase() + notificationManager.registerAllChannels() + shortcutManager.createShortcuts() - Signing.getCert(this) - Utils.initializeStorageDir(this) + SSLProviderInstaller.install(applicationContext, this@App::buildHttp) - launch { - withContext(Dispatchers.Default) { - SSLProviderInstaller.install(applicationContext, this@App::buildHttp) + if (config.sync.enabled) + SyncWorker.scheduleNext(this@App, false) + else + SyncWorker.cancelNext(this@App) - if (config.sync.enabled) - SyncWorker.scheduleNext(this@App, false) - else - SyncWorker.cancelNext(this@App) + if (config.sync.notifyAboutUpdates) + UpdateWorker.scheduleNext(this@App, false) + else + UpdateWorker.cancelNext(this@App) + } - if (config.sync.notifyAboutUpdates) - UpdateWorker.scheduleNext(this@App, false) - else - UpdateWorker.cancelNext(this@App) - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - val shortcutManager = getSystemService(ShortcutManager::class.java) - - val shortcutTimetable = ShortcutInfo.Builder(this@App, "item_timetable") - .setShortLabel(getString(R.string.shortcut_timetable)).setLongLabel(getString(R.string.shortcut_timetable)) - .setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_timetable)) - .setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java) - .putExtras("fragmentId" to NavTarget.TIMETABLE)) - .build() - - val shortcutAgenda = ShortcutInfo.Builder(this@App, "item_agenda") - .setShortLabel(getString(R.string.shortcut_agenda)).setLongLabel(getString(R.string.shortcut_agenda)) - .setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_agenda)) - .setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java) - .putExtras("fragmentId" to NavTarget.AGENDA)) - .build() - - val shortcutGrades = ShortcutInfo.Builder(this@App, "item_grades") - .setShortLabel(getString(R.string.shortcut_grades)).setLongLabel(getString(R.string.shortcut_grades)) - .setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_grades)) - .setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java) - .putExtras("fragmentId" to NavTarget.GRADES)) - .build() - - val shortcutHomework = ShortcutInfo.Builder(this@App, "item_homeworks") - .setShortLabel(getString(R.string.shortcut_homework)).setLongLabel(getString(R.string.shortcut_homework)) - .setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_homework)) - .setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java) - .putExtras("fragmentId" to NavTarget.HOMEWORK)) - .build() - - val shortcutMessages = ShortcutInfo.Builder(this@App, "item_messages") - .setShortLabel(getString(R.string.shortcut_messages)).setLongLabel(getString(R.string.shortcut_messages)) - .setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_messages)) - .setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java) - .putExtras("fragmentId" to NavTarget.MESSAGES)) - .build() - - shortcutManager.dynamicShortcuts = listOf( - shortcutTimetable, - shortcutAgenda, - shortcutGrades, - shortcutHomework, - shortcutMessages - ) - } // shortcuts - end - - notificationChannelsManager.registerAllChannels() - - - if (config.appInstalledTime == 0L) - try { - config.appInstalledTime = packageManager.getPackageInfo(packageName, 0).firstInstallTime - config.appRateSnackbarTime = config.appInstalledTime + 7 * DAY * MS - } catch (e: PackageManager.NameNotFoundException) { - e.printStackTrace() - } - - val pushMobidziennikApp = FirebaseApp.initializeApp( - this@App, - FirebaseOptions.Builder() - .setProjectId("mobidziennik") - .setStorageBucket("mobidziennik.appspot.com") - .setDatabaseUrl("https://mobidziennik.firebaseio.com") - .setGcmSenderId("747285019373") - .setApiKey("AIzaSyCi5LmsZ5BBCQnGtrdvWnp1bWLCNP8OWQE") - .setApplicationId("1:747285019373:android:f6341bf7b158621d") - .build(), - "Mobidziennik2" - ) - - val pushLibrusApp = FirebaseApp.initializeApp( - this@App, - FirebaseOptions.Builder() - .setProjectId("synergiadru") - .setStorageBucket("synergiadru.appspot.com") - .setDatabaseUrl("https://synergiadru.firebaseio.com") - .setGcmSenderId("513056078587") - .setApiKey("AIzaSyDfTuEoYPKdv4aceEws1CO3n0-HvTndz-o") - .setApplicationId("1:513056078587:android:1e29083b760af544") - .build(), - "Librus" - ) - - val pushVulcanApp = FirebaseApp.initializeApp( - this@App, - FirebaseOptions.Builder() - .setProjectId("dzienniczekplus") - .setStorageBucket("dzienniczekplus.appspot.com") - .setDatabaseUrl("https://dzienniczekplus.firebaseio.com") - .setGcmSenderId("987828170337") - .setApiKey("AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA") - .setApplicationId("1:987828170337:android:ac97431a0a4578c3") - .build(), - "Vulcan" - ) - - val pushVulcanHebeApp = FirebaseApp.initializeApp( - this@App, - FirebaseOptions.Builder() - .setProjectId("dzienniczekplus") - .setStorageBucket("dzienniczekplus.appspot.com") - .setDatabaseUrl("https://dzienniczekplus.firebaseio.com") - .setGcmSenderId("987828170337") - .setApiKey("AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA") - .setApplicationId("1:987828170337:android:7e16404b9e5deaaa") - .build(), - "VulcanHebe" - ) - - try { - FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { instanceIdResult -> - val token = instanceIdResult.token - d("Firebase", "Got App token: $token") - config.sync.tokenApp = token - } - FirebaseInstanceId.getInstance(pushMobidziennikApp).instanceId.addOnSuccessListener { instanceIdResult -> - val token = instanceIdResult.token - d("Firebase", "Got Mobidziennik2 token: $token") - if (token != config.sync.tokenMobidziennik) { - config.sync.tokenMobidziennik = token - config.sync.tokenMobidziennikList = listOf() - } - } - FirebaseInstanceId.getInstance(pushLibrusApp).instanceId.addOnSuccessListener { instanceIdResult -> - val token = instanceIdResult.token - d("Firebase", "Got Librus token: $token") - if (token != config.sync.tokenLibrus) { - config.sync.tokenLibrus = token - config.sync.tokenLibrusList = listOf() - } - } - FirebaseInstanceId.getInstance(pushVulcanApp).instanceId.addOnSuccessListener { instanceIdResult -> - val token = instanceIdResult.token - d("Firebase", "Got Vulcan token: $token") - if (token != config.sync.tokenVulcan) { - config.sync.tokenVulcan = token - config.sync.tokenVulcanList = listOf() - } - } - FirebaseInstanceId.getInstance(pushVulcanHebeApp).instanceId.addOnSuccessListener { instanceIdResult -> - val token = instanceIdResult.token - d("Firebase", "Got VulcanHebe token: $token") - if (token != config.sync.tokenVulcanHebe) { - config.sync.tokenVulcanHebe = token - config.sync.tokenVulcanHebeList = listOf() - } - } - FirebaseMessaging.getInstance().subscribeToTopic(packageName) - } catch (e: IllegalStateException) { - e.printStackTrace() - } - } - - db.metadataDao().countUnseen().observeForever { count: Int -> - if (unreadBadgesAvailable) - unreadBadgesAvailable = ShortcutBadger.applyCount(this@App, count) - } + db.metadataDao().countUnseen().observeForever { count: Int -> + if (unreadBadgesAvailable) + unreadBadgesAvailable = ShortcutBadger.applyCount(this@App, count) } } @@ -418,7 +268,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { App.config.lastProfileId = profile.id try { App.data = AppData.get(profile.loginStoreType) - d("App", "Loaded AppData: ${App.data}") + Timber.d("Loaded AppData: ${App.data}") // apply newly-added config overrides, if not changed by the user yet for ((key, value) in App.data.configOverrides) { val config = App.profile.config @@ -426,7 +276,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { config[key] = value } } catch (e: Exception) { - Log.e("App", "Cannot load AppData", e) + Timber.e(e, "Cannot load AppData") Toast.makeText(this, R.string.app_cannot_load_data, Toast.LENGTH_LONG).show() exitProcess(0) } @@ -439,6 +289,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { } return false } + fun profileLoad(profileId: Int, onSuccess: (profile: Profile) -> Unit) { launch { val success = withContext(Dispatchers.Default) { @@ -450,6 +301,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { profileLoadLast(onSuccess) } } + fun profileLoadLast(onSuccess: (profile: Profile) -> Unit) { launch { val success = withContext(Dispatchers.Default) { @@ -457,12 +309,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { } if (!success) { EventBus.getDefault().post(ProfileListEmptyEvent()) - } - else { + } else { onSuccess(profile) } } } + fun profileSave() = profileSave(profile) fun profileSave(profile: Profile) { if (profile.id == profileId) @@ -474,9 +326,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { fun checkDevModePassword() { devMode = devMode || try { - Utils.AESCrypt.decrypt("nWFVxY65Pa8/aRrT7EylNAencmOD+IxUY2Gg/beiIWY=", config.devModePassword) == "ok here you go it's enabled now" + Utils.AESCrypt.decrypt( + "nWFVxY65Pa8/aRrT7EylNAencmOD+IxUY2Gg/beiIWY=", + config.devModePassword + ) == "ok here you go it's enabled now" } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) false } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt index 9e3ca0f3..250bdda1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt @@ -45,10 +45,10 @@ import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.data.enums.FeatureType import pl.szczodrzynski.edziennik.databinding.ActivitySzkolnyBinding import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.sync.AppManagerDetectedEvent -import pl.szczodrzynski.edziennik.sync.SyncWorker -import pl.szczodrzynski.edziennik.sync.UpdateStateEvent -import pl.szczodrzynski.edziennik.sync.UpdateWorker +import pl.szczodrzynski.edziennik.core.work.AppManagerDetectedEvent +import pl.szczodrzynski.edziennik.core.work.SyncWorker +import pl.szczodrzynski.edziennik.core.work.UpdateStateEvent +import pl.szczodrzynski.edziennik.core.work.UpdateWorker import pl.szczodrzynski.edziennik.ui.base.MainSnackbar import pl.szczodrzynski.edziennik.data.enums.NavTarget import pl.szczodrzynski.edziennik.data.enums.NavTargetLocation @@ -66,9 +66,8 @@ import pl.szczodrzynski.edziennik.ui.login.LoginActivity import pl.szczodrzynski.edziennik.ui.messages.list.MessagesFragment import pl.szczodrzynski.edziennik.ui.timetable.TimetableFragment import pl.szczodrzynski.edziennik.utils.* -import pl.szczodrzynski.edziennik.utils.Utils.d -import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager.Error.Type -import pl.szczodrzynski.edziennik.utils.managers.UserActionManager +import pl.szczodrzynski.edziennik.core.manager.AvailabilityManager.Error.Type +import pl.szczodrzynski.edziennik.core.manager.UserActionManager import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.navlib.* import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet @@ -76,6 +75,7 @@ import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem import pl.szczodrzynski.navlib.drawer.NavDrawer import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem +import timber.log.Timber import java.io.IOException import kotlin.coroutines.CoroutineContext import kotlin.math.roundToInt @@ -123,18 +123,19 @@ class MainActivity : AppCompatActivity(), CoroutineScope { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - d(TAG, "Activity created") + Timber.i("Activity created") app.uiManager.applyTheme(this) app.uiManager.applyLanguage(this) app.buildManager.validateBuild(this) if (App.profileId == 0) { + Timber.i("Profile is not loaded") onProfileListEmptyEvent(ProfileListEmptyEvent()) return } - d(TAG, "Profile is valid, inflating views") + Timber.i("Profile is valid, inflating views") setContentView(b.root) @@ -542,7 +543,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope { @Subscribe(threadMode = ThreadMode.MAIN) fun onProfileListEmptyEvent(event: ProfileListEmptyEvent) { - d(TAG, "Profile list is empty. Launch LoginActivity.") app.config.loginFinished = false startActivity(Intent(this, LoginActivity::class.java)) finish() @@ -617,7 +617,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { try { startActivity(Intent(Settings.ACTION_SETTINGS)) } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) Toast.makeText(this, R.string.app_manager_open_failed, Toast.LENGTH_SHORT) .show() } @@ -665,11 +665,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { } fun handleIntent(extras: Bundle?) { - d(TAG, "handleIntent() {") - extras?.keySet()?.forEach { key -> - d(TAG, " \"$key\": " + extras.get(key)) - } - d(TAG, "}") + Timber.d("handleIntent() ${extras?.keySet()}") val intentProfileId = extras.getIntOrNull("profileId").takePositive() var intentNavTarget = extras.getEnum("fragmentId") @@ -783,17 +779,17 @@ class MainActivity : AppCompatActivity(), CoroutineScope { } override fun onStart() { - d(TAG, "Activity started") + Timber.i("Activity started") super.onStart() } override fun onStop() { - d(TAG, "Activity stopped") + Timber.i("Activity stopped") super.onStop() } override fun onResume() { - d(TAG, "Activity resumed") + Timber.i("Activity resumed") val filter = IntentFilter() filter.addAction(Intent.ACTION_MAIN) ContextCompat.registerReceiver( @@ -807,14 +803,14 @@ class MainActivity : AppCompatActivity(), CoroutineScope { } override fun onPause() { - d(TAG, "Activity paused") + Timber.i("Activity paused") unregisterReceiver(intentReceiver) EventBus.getDefault().unregister(this) super.onPause() } override fun onDestroy() { - d(TAG, "Activity destroyed") + Timber.i("Activity destroyed") super.onDestroy() } @@ -868,7 +864,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { args: Bundle? = null, skipBeforeNavigate: Boolean = false, ): Boolean { - d(TAG, "navigate(profileId = ${profile?.id ?: profileId}, target = ${navTarget?.name}, args = $args)") + Timber.d("navigate(profileId = ${profile?.id ?: profileId}, target = ${navTarget?.name}, args = $args)") if (!(skipBeforeNavigate || navTarget == this.navTarget) && !canNavigate()) { bottomSheet.close() drawer.close() @@ -901,7 +897,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { args: Bundle?, profileChanged: Boolean, ) { - d(TAG, "navigateImpl(profileId = ${profile.id}, target = ${navTarget.name}, args = $args)") + Timber.d("navigateImpl(profileId = ${profile.id}, target = ${navTarget.name}, args = $args)") if (navTarget.featureType != null && !profile.hasUIFeature(navTarget.featureType)) { navigateImpl(profile, NavTarget.HOME, args, profileChanged) @@ -954,7 +950,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { navView.bottomBar.fabExtended = false navView.bottomBar.setFabOnClickListener(null) - d("NavDebug", "Navigating from ${this.navTarget.name} to ${navTarget.name}") + Timber.d("Navigating from ${this.navTarget.name} to ${navTarget.name}") val fragment = navTarget.fragmentClass?.getDeclaredConstructor()?.newInstance() ?: return fragment.arguments = arguments @@ -1014,9 +1010,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope { } } - d("NavDebug", "Current fragment ${navTarget.name}, back stack:") + Timber.d("Current fragment ${navTarget.name}, back stack:") navBackStack.forEachIndexed { index, item -> - d("NavDebug", " - $index: ${item.first.name}") + Timber.d(" - $index: ${item.first.name}") } transaction.replace(R.id.fragment, fragment) @@ -1099,8 +1095,8 @@ class MainActivity : AppCompatActivity(), CoroutineScope { else BitmapDrawable.createFromPath(it) } - } catch (e: IOException) { - e.printStackTrace() + } catch (e: Exception) { + Timber.e(e) } } @@ -1141,7 +1137,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { } fun setDrawerItems() { - d("NavDebug", "setDrawerItems() app.profile = ${app.profile}") + Timber.d("setDrawerItems() app.profile = ${app.profile}") val drawerItems = arrayListOf>() val drawerItemsMore = arrayListOf>() val drawerItemsBottom = arrayListOf>() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseSendException.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseSendException.kt similarity index 93% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseSendException.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseSendException.kt index 04cb7c23..917a795b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseSendException.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseSendException.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase class FirebaseSendException(reason: String?) : Exception(reason) { companion object { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseService.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseService.kt similarity index 92% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseService.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseService.kt index 80dcd4ea..7d39f38d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/FirebaseService.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/FirebaseService.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import android.annotation.SuppressLint import android.app.PendingIntent @@ -14,6 +14,7 @@ import com.google.firebase.iid.zzaz import com.google.firebase.messaging.zzc import com.google.gson.JsonObject import pl.szczodrzynski.edziennik.ext.* +import timber.log.Timber import java.util.* import com.google.firebase.messaging.zzo.zza as logNotificationOpen import com.google.firebase.messaging.zzo.zza as logNotificationReceived @@ -44,7 +45,7 @@ open class FirebaseService : zzc() { try { it.send() } catch (e: CanceledException) { - Log.e(TAG, "Notification pending intent canceled") + Timber.e("Notification pending intent canceled") } } @@ -59,7 +60,7 @@ open class FirebaseService : zzc() { final override fun zzc(intent: Intent?) { val action = intent?.action val json = intent?.toJsonObject() - Log.d(TAG, "zzc Intent(action=$action, extras=$json)") + Timber.d("zzc Intent(action=$action, extras=$json)") if (action == null || json == null) return @@ -73,12 +74,13 @@ open class FirebaseService : zzc() { onNewToken(json.getString("token")) } "com.google.android.c2dm.intent.RECEIVE", - "com.google.firebase.messaging.RECEIVE_DIRECT_BOOT" -> { + "com.google.firebase.messaging.RECEIVE_DIRECT_BOOT", + -> { val messageId = json.getString("google.message_id") if (messageId != null) { // send back an acknowledgement to Google Play Services val ackBundle = Bundle( - "google.message_id" to messageId + "google.message_id" to messageId ) zzad.zza(this).zza(2, ackBundle) } @@ -86,7 +88,7 @@ open class FirebaseService : zzc() { // and add it to queue if (messageId.isNotNullNorEmpty()) { if (messageQueue.contains(messageId)) { - Log.d(TAG, "Received duplicate message: $messageId") + Timber.d("Received duplicate message: $messageId") return } if (messageQueue.size >= 10) @@ -97,7 +99,7 @@ open class FirebaseService : zzc() { processMessage(messageId, json, intent) } else -> { - Log.d(TAG, "Unknown intent action: $action") + Timber.d("Unknown intent action: $action") } } } @@ -128,7 +130,7 @@ open class FirebaseService : zzc() { ) } else -> { - Log.w(TAG, "Received message with unknown type: $it") + Timber.w("Received message with unknown type: $it") return } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/MyFirebaseService.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/MyFirebaseService.kt similarity index 77% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/MyFirebaseService.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/MyFirebaseService.kt index 00d33812..b6bed72a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/MyFirebaseService.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/MyFirebaseService.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import android.content.Context import android.util.Log @@ -11,6 +11,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch import pl.szczodrzynski.edziennik.App +import timber.log.Timber import kotlin.coroutines.CoroutineContext class MyFirebaseService : FirebaseService(), CoroutineScope { @@ -25,17 +26,13 @@ class MyFirebaseService : FirebaseService(), CoroutineScope { get() = job + Dispatchers.Main override fun onNewToken(token: String?) { - Log.d(TAG, "Got new token: $token") + Timber.d("Got new token: $token") app.config.sync.tokenApp = token } override fun onMessageReceived(message: Message) { launch(Dispatchers.Default) { - Log.d(TAG, "Message received from ${message.from}: $message") - app.getSharedPreferences("firebase_service_log", Context.MODE_PRIVATE).edit().apply { - putString(System.currentTimeMillis().toString(), message.toString()) - apply() - } + Timber.d("Message received from ${message.from}: $message") val profiles = app.db.profileDao().profilesForFirebaseNow when (message.from) { "640759989760" -> SzkolnyAppFirebase(app, profiles, message) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyAppFirebase.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyAppFirebase.kt similarity index 99% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyAppFirebase.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyAppFirebase.kt index d80ef156..0d6226e5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyAppFirebase.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyAppFirebase.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import com.google.gson.JsonParser import com.google.gson.reflect.TypeToken diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyLibrusFirebase.kt similarity index 99% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyLibrusFirebase.kt index b8fd7d97..074457a3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyLibrusFirebase.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyMobidziennikFirebase.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyMobidziennikFirebase.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyMobidziennikFirebase.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyMobidziennikFirebase.kt index c209cb9d..73c59e1d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyMobidziennikFirebase.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyMobidziennikFirebase.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyVulcanFirebase.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyVulcanFirebase.kt similarity index 97% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyVulcanFirebase.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyVulcanFirebase.kt index 7c3359cd..2ab6defb 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyVulcanFirebase.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/firebase/SzkolnyVulcanFirebase.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-11. */ -package pl.szczodrzynski.edziennik.data.firebase +package pl.szczodrzynski.edziennik.core.firebase import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AttendanceManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AttendanceManager.kt index 5b112af9..accdfba3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AttendanceManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-4-28. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AvailabilityManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AvailabilityManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AvailabilityManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AvailabilityManager.kt index d254c065..eedbb6ad 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AvailabilityManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/AvailabilityManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2021-9-18. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.BuildConfig diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/BuildManager.kt similarity index 94% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/BuildManager.kt index 91778906..a60abe68 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/BuildManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2021-3-27. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.content.pm.PackageManager import android.text.TextUtils @@ -20,7 +20,9 @@ import pl.szczodrzynski.edziennik.BuildConfig import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update +import pl.szczodrzynski.edziennik.ext.DAY import pl.szczodrzynski.edziennik.ext.Intent +import pl.szczodrzynski.edziennik.ext.MS import pl.szczodrzynski.edziennik.ext.asBoldSpannable import pl.szczodrzynski.edziennik.ext.asColoredSpannable import pl.szczodrzynski.edziennik.ext.concat @@ -34,7 +36,7 @@ import pl.szczodrzynski.edziennik.ext.resolveColor import pl.szczodrzynski.edziennik.ext.toJsonObject import pl.szczodrzynski.edziennik.ui.base.BuildInvalidActivity import pl.szczodrzynski.edziennik.utils.Utils -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.time.Instant import java.time.ZoneId import java.time.ZonedDateTime @@ -101,6 +103,18 @@ class BuildManager(val app: App) : CoroutineScope { else -> Update.Type.RELEASE } + fun fetchInstalledTime() { + if (app.config.appInstalledTime != 0L) + return + try { + app.config.appInstalledTime = + app.packageManager.getPackageInfo(app.packageName, 0).firstInstallTime + app.config.appRateSnackbarTime = app.config.appInstalledTime + 7 * DAY * MS + } catch (e: PackageManager.NameNotFoundException) { + Timber.e(e) + } + } + fun showVersionDialog(activity: AppCompatActivity) { val yes = activity.getString(R.string.yes) val no = activity.getString(R.string.no) @@ -235,7 +249,7 @@ class BuildManager(val app: App) : CoroutineScope { fun validateBuild(activity: AppCompatActivity) { launch { gitRemote = getRemoteRepo() - d("BuildManager", "isSigned = $isSigned, buildType = $buildType, buildFlavor = $buildFlavor, remote = $gitRemote") + Timber.d("isSigned = $isSigned, buildType = $buildType, buildFlavor = $buildFlavor, remote = $gitRemote") // officially signed package if (isSigned) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/EventManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/EventManager.kt index 38a8fee3..450b6e6c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/EventManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-4-3. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.widget.TextView import androidx.core.view.isVisible diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/FirebaseManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/FirebaseManager.kt new file mode 100644 index 00000000..ba3dbe6a --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/FirebaseManager.kt @@ -0,0 +1,99 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2024-7-1. + */ + +package pl.szczodrzynski.edziennik.core.manager + +import com.google.firebase.FirebaseApp +import com.google.firebase.FirebaseOptions +import com.google.firebase.iid.FirebaseInstanceId +import com.google.firebase.messaging.FirebaseMessaging +import pl.szczodrzynski.edziennik.App +import timber.log.Timber + +class FirebaseManager(val app: App) { + data class Instance( + val name: String, + val projectId: String, + val projectNumber: String, + val apiKey: String, + val applicationId: String, + val onToken: (token: String) -> Unit, + ) + + private val instances = listOf( + Instance( + name = "Mobidziennik", + projectId = "mobidziennik", + projectNumber = "747285019373", + apiKey = "AIzaSyCi5LmsZ5BBCQnGtrdvWnp1bWLCNP8OWQE", + applicationId = "f6341bf7b158621d", + onToken = { + app.config.sync.tokenMobidziennik = it + app.config.sync.tokenMobidziennikList = listOf() + }, + ), + Instance( + name = "Librus", + projectId = "synergiadru", + projectNumber = "513056078587", + apiKey = "AIzaSyDfTuEoYPKdv4aceEws1CO3n0-HvTndz-o", + applicationId = "1e29083b760af544", + onToken = { + app.config.sync.tokenLibrus = it + app.config.sync.tokenLibrusList = listOf() + }, + ), + Instance( + name = "Vulcan", + projectId = "dzienniczekplus", + projectNumber = "987828170337", + apiKey = "AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA", + applicationId = "ac97431a0a4578c3", + onToken = { + app.config.sync.tokenVulcan = it + app.config.sync.tokenVulcanList = listOf() + }, + ), + Instance( + name = "VulcanHebe", + projectId = "dzienniczekplus", + projectNumber = "987828170337", + apiKey = "AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA", + applicationId = "7e16404b9e5deaaa", + onToken = { + app.config.sync.tokenVulcanHebe = it + app.config.sync.tokenVulcanHebeList = listOf() + }, + ), + ) + + fun initializeApps() { + FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { result -> + val token = result.token + Timber.i("Got App token: $token") + app.config.sync.tokenApp = token + } + FirebaseMessaging.getInstance().subscribeToTopic(app.packageName) + + instances.forEach { + val options = FirebaseOptions.Builder() + .setProjectId(it.projectId) + .setStorageBucket("${it.projectId}.appspot.com") + .setDatabaseUrl("https://${it.projectId}.firebaseio.com") + .setGcmSenderId(it.projectNumber) + .setApiKey(it.apiKey) + .setApplicationId("1:${it.projectNumber}:android:${it.applicationId}") + .build() + + val instance = FirebaseApp.initializeApp(app, options, it.name) + + FirebaseInstanceId.getInstance(instance).instanceId.addOnSuccessListener { result -> + val token = result.token + Timber.i("Got ${it.name} token: $token") + if (token != app.config["token${it.name}"]) + it.onToken(token) + } + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/GradesManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/GradesManager.kt similarity index 99% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/GradesManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/GradesManager.kt index 6ae0cb31..ca8f01a5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/GradesManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/GradesManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-3-1. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.content.Context import com.google.android.material.color.MaterialColors diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/LoggingManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/LoggingManager.kt new file mode 100644 index 00000000..d599c5fd --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/LoggingManager.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2024-7-1. + */ + +package pl.szczodrzynski.edziennik.core.manager + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import pl.szczodrzynski.edziennik.App +import pl.szczodrzynski.edziennik.data.db.entity.LogEntry +import pl.szczodrzynski.edziennik.ext.DAY +import pl.szczodrzynski.edziennik.ext.MS +import pl.szczodrzynski.edziennik.ext.ignore +import timber.log.Timber + +class LoggingManager(val app: App) : CoroutineScope { + companion object { + private const val CLEANUP_INTERVAL = 2 * DAY * MS + private const val CLEANUP_MAX_AGE = 7 * DAY * MS + } + + override val coroutineContext = Job() + Dispatchers.IO + + val logcatTree = object : Timber.DebugTree() { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + super.log( + priority = priority, + tag = tag?.substringBefore("$")?.let { "Szkolny/$it" }, + message = message, + t = t, + ) + } + } + + val databaseTree = object : Timber.DebugTree() { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) = launch { + val entry = LogEntry( + timestamp = System.currentTimeMillis(), + priority = priority, + tag = tag?.substringBefore("$"), + message = message, + ) + app.db.logDao().add(entry) + }.ignore() + } + + suspend fun cleanupIfNeeded(force: Boolean = false) { + if (!force && System.currentTimeMillis() - app.config.lastLogCleanupTime < CLEANUP_INTERVAL) + return + withContext(Dispatchers.IO) { + val timestamp = System.currentTimeMillis() - CLEANUP_MAX_AGE + Timber.i("Cleaning logs older than $timestamp") + app.db.logDao().clearBefore(timestamp) + } + app.config.lastLogCleanupTime = System.currentTimeMillis() + } + + fun cleanupHyperLogDatabase() { + try { + app.deleteDatabase("com.hypertrack.common.device_logs.db") + } catch (e: Exception) { + Timber.e(e) + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/MessageManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/MessageManager.kt index 8d81ac2d..ea969c20 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/MessageManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2021-10-7. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.content.Context import android.os.Bundle @@ -30,8 +30,8 @@ import pl.szczodrzynski.edziennik.ext.setText import pl.szczodrzynski.edziennik.ui.messages.MessagesUtils import pl.szczodrzynski.edziennik.utils.TextInputKeyboardEdit import pl.szczodrzynski.edziennik.utils.html.BetterHtml -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.ORIGINAL -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfig +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.ORIGINAL +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfig import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.span.BoldSpan diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NoteManager.kt similarity index 99% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NoteManager.kt index 50ac84cd..fc8b244d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NoteManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2021-10-17. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.annotation.SuppressLint import android.text.SpannableStringBuilder diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NotificationManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NotificationManager.kt new file mode 100644 index 00000000..f8e9d269 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/NotificationManager.kt @@ -0,0 +1,115 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2020-2-15. + */ + +package pl.szczodrzynski.edziennik.core.manager + +import android.app.NotificationChannel +import android.app.NotificationManager +import android.content.Context +import android.os.Build +import androidx.core.app.NotificationCompat.* +import androidx.core.app.NotificationManagerCompat.* +import pl.szczodrzynski.edziennik.R + +class NotificationManager(val c: Context) { + data class Channel( + val id: Int, + val key: String, + val name: String, + val description: String, + val importance: Int, + val priority: Int, + val quiet: Boolean = false, + val lightColor: Int? = null + ) + + fun registerAllChannels() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + return + val manager = c.getSystemService(NotificationManager::class.java) + + val registered = manager.notificationChannels.map { it.id }.toSet() + val all = all.map { it.key }.toSet() + + val toRegister = all - registered + val toDelete = registered - all + + for (key in toRegister) { + val channel = this.all.firstOrNull { it.key == key } ?: continue + manager.createNotificationChannel(NotificationChannel(key, channel.name, channel.importance).apply { + description = channel.description + if (channel.quiet) { + enableVibration(false) + setSound(null, null) + } + channel.lightColor?.let { + enableLights(true) + lightColor = it + } + }) + } + + for (key in toDelete) { + if (key.contains("chucker")) + continue + manager.deleteNotificationChannel(key) + } + } + + val sync = Channel( + 1, + "pl.szczodrzynski.edziennik.SYNC", + c.getString(R.string.notification_channel_get_data_name), + c.getString(R.string.notification_channel_get_data_desc), + IMPORTANCE_MIN, + PRIORITY_MIN, + quiet = true + ) + + val data = Channel( + 50, + "pl.szczodrzynski.edziennik.DATA", + c.getString(R.string.notification_channel_notifications_name), + c.getString(R.string.notification_channel_notifications_desc), + IMPORTANCE_HIGH, + PRIORITY_MAX, + lightColor = 0xff2196f3.toInt() + ) + + val dataQuiet = Channel( + 60, + "pl.szczodrzynski.edziennik.DATA_QUIET", + c.getString(R.string.notification_channel_notifications_quiet_name), + c.getString(R.string.notification_channel_notifications_quiet_desc), + IMPORTANCE_LOW, + PRIORITY_LOW, + quiet = true + ) + + val updates = Channel( + 100, + "pl.szczodrzynski.edziennik.UPDATES", + c.getString(R.string.notification_channel_updates_name), + c.getString(R.string.notification_channel_updates_desc), + IMPORTANCE_DEFAULT, + PRIORITY_DEFAULT + ) + + val userAttention = Channel( + 200, + "pl.szczodrzynski.edziennik.USER_ATTENTION", + c.getString(R.string.notification_channel_user_attention_name), + c.getString(R.string.notification_channel_user_attention_desc), + IMPORTANCE_DEFAULT, + PRIORITY_DEFAULT + ) + + val all by lazy { listOf( + sync, + data, + dataQuiet, + updates, + userAttention + ) } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/PermissionManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/PermissionManager.kt similarity index 99% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/PermissionManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/PermissionManager.kt index e99f9e3e..6091803e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/PermissionManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/PermissionManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-4-7. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.Manifest import android.content.Intent diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/ShortcutManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/ShortcutManager.kt new file mode 100644 index 00000000..9a561dd3 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/ShortcutManager.kt @@ -0,0 +1,76 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2024-7-1. + */ + +package pl.szczodrzynski.edziennik.core.manager + +import android.content.Intent +import android.content.pm.ShortcutInfo +import android.content.pm.ShortcutManager +import android.graphics.drawable.Icon +import android.os.Build +import androidx.core.content.getSystemService +import pl.szczodrzynski.edziennik.App +import pl.szczodrzynski.edziennik.MainActivity +import pl.szczodrzynski.edziennik.R +import pl.szczodrzynski.edziennik.data.enums.NavTarget +import pl.szczodrzynski.edziennik.ext.putExtras + +class ShortcutManager(val app: App) { + + data class Shortcut( + val id: String, + val label: Int, + val icon: Int, + val target: NavTarget, + ) + + private val shortcuts = listOf( + Shortcut( + id = "item_timetable", + label = R.string.shortcut_timetable, + icon = R.mipmap.ic_shortcut_timetable, + target = NavTarget.TIMETABLE, + ), + Shortcut( + id = "item_agenda", + label = R.string.shortcut_agenda, + icon = R.mipmap.ic_shortcut_agenda, + target = NavTarget.AGENDA, + ), + Shortcut( + id = "item_grades", + label = R.string.shortcut_grades, + icon = R.mipmap.ic_shortcut_grades, + target = NavTarget.GRADES, + ), + Shortcut( + id = "item_homeworks", + label = R.string.shortcut_homework, + icon = R.mipmap.ic_shortcut_homework, + target = NavTarget.HOMEWORK, + ), + Shortcut( + id = "item_messages", + label = R.string.shortcut_messages, + icon = R.mipmap.ic_shortcut_messages, + target = NavTarget.MESSAGES, + ), + ) + + fun createShortcuts() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + app.getSystemService()?.dynamicShortcuts = shortcuts.map { + ShortcutInfo.Builder(app, it.id) + .setShortLabel(app.getString(it.label)) + .setLongLabel(app.getString(it.label)) + .setIcon(Icon.createWithResource(app, it.icon)) + .setIntent( + Intent(Intent.ACTION_MAIN, null, app, MainActivity::class.java) + .putExtras("fragmentId" to it.target) + ) + .build() + } + } + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TextStylingManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TextStylingManager.kt index 7a96c270..86d1a72b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TextStylingManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TextStylingManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2021-10-7. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.text.SpannableStringBuilder import android.text.Spanned @@ -31,7 +31,7 @@ import pl.szczodrzynski.edziennik.ext.replaceSpan import pl.szczodrzynski.edziennik.ui.dialogs.StyledTextDialog import pl.szczodrzynski.edziennik.utils.TextInputKeyboardEdit import pl.szczodrzynski.edziennik.utils.html.BetterHtml -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.* +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.* import pl.szczodrzynski.edziennik.utils.span.BoldSpan import pl.szczodrzynski.edziennik.utils.span.ItalicSpan diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TimetableManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TimetableManager.kt similarity index 92% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TimetableManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TimetableManager.kt index 5448feb7..869dd26f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/TimetableManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/TimetableManager.kt @@ -2,11 +2,9 @@ * Copyright (c) Kuba Szczodrzyński 2020-3-10. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.content.Context -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter import android.widget.TextView import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -15,11 +13,8 @@ import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.db.entity.Lesson import pl.szczodrzynski.edziennik.data.db.full.LessonFull -import pl.szczodrzynski.edziennik.ext.resolveAttr import pl.szczodrzynski.edziennik.ext.setText -import pl.szczodrzynski.edziennik.ext.setTintColor import pl.szczodrzynski.edziennik.ext.startCoroutineTimer -import pl.szczodrzynski.navlib.getColorFromAttr import kotlin.coroutines.CoroutineContext class TimetableManager(val app: App) : CoroutineScope { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UiManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UiManager.kt similarity index 94% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UiManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UiManager.kt index 52df8158..cd99fd6b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UiManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UiManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2024-6-26. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.content.Context import android.os.Build @@ -17,7 +17,7 @@ import pl.szczodrzynski.edziennik.data.enums.Theme import pl.szczodrzynski.edziennik.data.enums.Theme.Mode import pl.szczodrzynski.edziennik.data.enums.Theme.Type import pl.szczodrzynski.edziennik.ext.isNightMode -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.util.Locale class UiManager(val app: App) { @@ -63,7 +63,7 @@ class UiManager(val app: App) { ) { color = Theme.BLUE } - d(TAG, "Applying theme $color($type, $mode)") + Timber.d("Applying theme $color($type, $mode)") color.styleRes[type to mode] ?: color.styleRes[Type.M3 to Mode.DAYNIGHT]!! } activity.setTheme(themeRes) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UpdateManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UpdateManager.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UpdateManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UpdateManager.kt index f2d1c131..67c75295 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UpdateManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UpdateManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2022-10-22. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UserActionManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UserActionManager.kt similarity index 96% rename from app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UserActionManager.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UserActionManager.kt index 9ca4c233..80fd7764 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/UserActionManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/manager/UserActionManager.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-2-15. */ -package pl.szczodrzynski.edziennik.utils.managers +package pl.szczodrzynski.edziennik.core.manager import android.app.NotificationManager import android.app.PendingIntent @@ -24,7 +24,7 @@ import pl.szczodrzynski.edziennik.ui.login.oauth.OAuthLoginActivity import pl.szczodrzynski.edziennik.ui.login.oauth.OAuthLoginResult import pl.szczodrzynski.edziennik.ui.login.recaptcha.RecaptchaActivity import pl.szczodrzynski.edziennik.ui.login.recaptcha.RecaptchaResult -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class UserActionManager(val app: App) { companion object { @@ -55,7 +55,7 @@ class UserActionManager(val app: App) { ) val notification = - NotificationCompat.Builder(app, app.notificationChannelsManager.userAttention.key) + NotificationCompat.Builder(app, app.notificationManager.userAttention.key) .setContentTitle(app.getString(R.string.notification_user_action_required_title)) .setContentText(text) .setSmallIcon(R.drawable.ic_error_outline) @@ -82,7 +82,7 @@ class UserActionManager(val app: App) { event: UserActionRequiredEvent, callback: UserActionCallback, ) { - d(TAG, "Running user action (${event.type}) with params: ${event.params}") + Timber.d("Running user action (${event.type}) with params: ${event.params}") val isSuccessful = when (event.type) { UserActionRequiredEvent.Type.RECAPTCHA -> executeRecaptcha(activity, event, callback) UserActionRequiredEvent.Type.OAUTH -> executeOauth(activity, event, callback) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookie.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookie.kt similarity index 97% rename from app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookie.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookie.kt index ecd513b0..24c096f7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookie.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookie.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-3-24. */ -package pl.szczodrzynski.edziennik.network.cookie +package pl.szczodrzynski.edziennik.core.network import okhttp3.Cookie import okhttp3.HttpUrl diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookieJar.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookieJar.kt similarity index 98% rename from app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookieJar.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookieJar.kt index 945e16ea..c9e88b0d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/network/cookie/DumbCookieJar.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/network/DumbCookieJar.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-3-24. */ -package pl.szczodrzynski.edziennik.network.cookie +package pl.szczodrzynski.edziennik.core.network import android.content.Context import androidx.core.content.edit diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/receivers/SzkolnyReceiver.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/SzkolnyReceiver.kt similarity index 96% rename from app/src/main/java/pl/szczodrzynski/edziennik/receivers/SzkolnyReceiver.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/SzkolnyReceiver.kt index f7819c43..6527ac12 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/receivers/SzkolnyReceiver.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/SzkolnyReceiver.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2019-10-1. */ -package pl.szczodrzynski.edziennik.receivers +package pl.szczodrzynski.edziennik.core.receiver import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/receivers/UserPresentReceiver.java b/app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/UserPresentReceiver.java similarity index 96% rename from app/src/main/java/pl/szczodrzynski/edziennik/receivers/UserPresentReceiver.java rename to app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/UserPresentReceiver.java index 82a31f11..e085d9ba 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/receivers/UserPresentReceiver.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/receiver/UserPresentReceiver.java @@ -1,4 +1,4 @@ -package pl.szczodrzynski.edziennik.receivers; +package pl.szczodrzynski.edziennik.core.receiver; import android.appwidget.AppWidgetManager; import android.content.BroadcastReceiver; diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/AppManagerDetectedEvent.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/AppManagerDetectedEvent.kt similarity index 57% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/AppManagerDetectedEvent.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/work/AppManagerDetectedEvent.kt index 10d93dfc..eea77e04 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/sync/AppManagerDetectedEvent.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/AppManagerDetectedEvent.kt @@ -1,3 +1,3 @@ -package pl.szczodrzynski.edziennik.sync +package pl.szczodrzynski.edziennik.core.work -class AppManagerDetectedEvent(val failedWorkTimestamps: List) \ No newline at end of file +class AppManagerDetectedEvent(val failedWorkTimestamps: List) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/SyncWorker.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/SyncWorker.kt similarity index 90% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/SyncWorker.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/work/SyncWorker.kt index 3a2a5f40..66f40314 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/sync/SyncWorker.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/SyncWorker.kt @@ -1,4 +1,4 @@ -package pl.szczodrzynski.edziennik.sync +package pl.szczodrzynski.edziennik.core.work import android.annotation.SuppressLint import android.content.Context @@ -6,7 +6,7 @@ import androidx.work.* import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask import pl.szczodrzynski.edziennik.ext.formatDate -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.util.concurrent.TimeUnit class SyncWorker(val context: Context, val params: WorkerParameters) : Worker(context, params) { @@ -38,7 +38,7 @@ class SyncWorker(val context: Context, val params: WorkerParameters) : Worker(co val syncInterval = app.config.sync.interval.toLong() val syncAt = System.currentTimeMillis() + syncInterval*1000 - d(TAG, "Scheduling work at ${syncAt.formatDate()}") + Timber.d("Scheduling work at ${syncAt.formatDate()}") val constraints = Constraints.Builder() .setRequiredNetworkType( @@ -61,14 +61,14 @@ class SyncWorker(val context: Context, val params: WorkerParameters) : Worker(co * Cancel any scheduled sync job. */ fun cancelNext(app: App) { - d(TAG, "Cancelling work by tag $TAG") + Timber.d("Cancelling work by tag $TAG") WorkManager.getInstance(app).cancelAllWorkByTag(TAG) //WorkManager.getInstance(app).pruneWork() // do not prune the work in order to look for failed tasks } } override fun doWork(): Result { - d(TAG, "Running worker ID ${params.id}") + Timber.d("Running worker ID ${params.id}") EdziennikTask.sync().enqueue(context) rescheduleNext(context as App) return Result.success() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateStateEvent.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateStateEvent.kt similarity index 82% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateStateEvent.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateStateEvent.kt index 878efdb8..dbae6b9e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateStateEvent.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateStateEvent.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2022-10-22. */ -package pl.szczodrzynski.edziennik.sync +package pl.szczodrzynski.edziennik.core.work import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateWorker.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateWorker.kt similarity index 91% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateWorker.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateWorker.kt index 3d22e044..11d586e5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateWorker.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/UpdateWorker.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-18. */ -package pl.szczodrzynski.edziennik.sync +package pl.szczodrzynski.edziennik.core.work import android.annotation.SuppressLint import android.content.Context @@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update import pl.szczodrzynski.edziennik.ext.DAY import pl.szczodrzynski.edziennik.ext.formatDate import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber import java.util.concurrent.TimeUnit import kotlin.coroutines.CoroutineContext @@ -43,7 +44,7 @@ class UpdateWorker(val context: Context, val params: WorkerParameters) : Worker( val syncInterval = 4 * DAY; val syncAt = System.currentTimeMillis() + syncInterval*1000 - Utils.d(TAG, "Scheduling work at ${syncAt.formatDate()}") + Timber.d("Scheduling work at ${syncAt.formatDate()}") val constraints = Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) @@ -62,7 +63,7 @@ class UpdateWorker(val context: Context, val params: WorkerParameters) : Worker( * Cancel any scheduled sync job. */ fun cancelNext(app: App) { - Utils.d(TAG, "Cancelling work by tag $TAG") + Timber.d("Cancelling work by tag $TAG") WorkManager.getInstance(app).cancelAllWorkByTag(TAG) } } @@ -72,7 +73,7 @@ class UpdateWorker(val context: Context, val params: WorkerParameters) : Worker( get() = job + Dispatchers.Main override fun doWork(): Result { - Utils.d(TAG, "Running worker ID ${params.id}") + Timber.d("Running worker ID ${params.id}") val app = context as App if (!app.config.sync.notifyAboutUpdates) { return Result.success() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/WorkerUtils.kt b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/WorkerUtils.kt similarity index 73% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/WorkerUtils.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/core/work/WorkerUtils.kt index a3250ed8..2e0a8b66 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/sync/WorkerUtils.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/core/work/WorkerUtils.kt @@ -2,7 +2,7 @@ * Copyright (c) Kuba Szczodrzyński 2020-1-18. */ -package pl.szczodrzynski.edziennik.sync +package pl.szczodrzynski.edziennik.core.work import android.annotation.SuppressLint import android.os.AsyncTask @@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.ext.MINUTE import pl.szczodrzynski.edziennik.ext.formatDate import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber object WorkerUtils { /** @@ -26,27 +27,27 @@ object WorkerUtils { val workManager = WorkManager.getInstance(app) as WorkManagerImpl val scheduledWork = workManager.workDatabase.workSpecDao().getScheduledWork().toMutableList() scheduledWork.forEach { - Utils.d("WorkerUtils", "Work: ${it.id} at ${it.calculateNextRunTime().formatDate()}. State = ${it.state} (finished = ${it.state.isFinished})") + Timber.d("Work: ${it.id} at ${it.calculateNextRunTime().formatDate()}. State = ${it.state} (finished = ${it.state.isFinished})") } // remove finished work and other than SyncWorker scheduledWork.removeAll { it.workerClassName != SyncWorker::class.java.canonicalName || it.isPeriodic || it.state.isFinished } - Utils.d("WorkerUtils", "Found ${scheduledWork.size} unfinished work") + Timber.d("Found ${scheduledWork.size} unfinished work") // remove all enqueued work that had to (but didn't) run at some point in the past (at least 1min ago) val failedWork = scheduledWork.filter { it.state == WorkInfo.State.ENQUEUED && it.calculateNextRunTime() < System.currentTimeMillis() - 1 * MINUTE * 1000 } - Utils.d("WorkerUtils", "${failedWork.size} work requests failed to start (out of ${scheduledWork.size} requests)") + Timber.d("${failedWork.size} work requests failed to start (out of ${scheduledWork.size} requests)") if (rescheduleIfFailedFound) { if (failedWork.isNotEmpty()) { - Utils.d("WorkerUtils", "App Manager detected!") + Timber.d("App Manager detected!") EventBus.getDefault().postSticky(AppManagerDetectedEvent(failedWork.map { it.calculateNextRunTime() })) } if (scheduledWork.size - failedWork.size < 1) { - Utils.d("WorkerUtils", "No pending work found, scheduling next:") + Timber.d("No pending work found, scheduling next:") onReschedule() } } else { - Utils.d("WorkerUtils", "NOT rescheduling: waiting to open the activity") + Timber.d("NOT rescheduling: waiting to open the activity") if (scheduledWork.size < 1) { - Utils.d("WorkerUtils", "No work found *at all*, scheduling next:") + Timber.d("No work found *at all*, scheduling next:") onReschedule() } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/ApiService.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/ApiService.kt index 0d9fe92c..c031b15e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/ApiService.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/ApiService.kt @@ -23,7 +23,7 @@ import pl.szczodrzynski.edziennik.data.api.task.IApiTask import pl.szczodrzynski.edziennik.data.api.task.SzkolnyTask import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.ext.toApiError -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import kotlin.math.min import kotlin.math.roundToInt @@ -76,7 +76,7 @@ class ApiService : Service() { private val taskCallback = object : EdziennikCallback { override fun onCompleted() { lastEventTime = System.currentTimeMillis() - d(TAG, "Task $taskRunningId (profile $taskProfileId) finished in ${System.currentTimeMillis()-taskStartTime}") + Timber.d("Task $taskRunningId (profile $taskProfileId) finished in ${System.currentTimeMillis()-taskStartTime}") EventBus.getDefault().postSticky(ApiTaskFinishedEvent(taskProfileId)) clearTask() @@ -93,12 +93,12 @@ class ApiService : Service() { override fun onError(apiError: ApiError) { lastEventTime = System.currentTimeMillis() - d(TAG, "Task $taskRunningId threw an error - $apiError") + Timber.d("Task $taskRunningId threw an error - $apiError") apiError.profileId = taskProfileId EventBus.getDefault().postSticky(ApiTaskErrorEvent(apiError)) errorList.add(apiError) - apiError.throwable?.printStackTrace() + Timber.e(apiError.throwable) if (apiError.isCritical) { taskRunning?.cancel() @@ -119,7 +119,7 @@ class ApiService : Service() { taskProgress = 0f taskProgress += step taskProgress = min(100f, taskProgress) - d(TAG, "Task $taskRunningId progress: ${taskProgress.roundToInt()}%") + Timber.d("Task $taskRunningId progress: ${taskProgress.roundToInt()}%") EventBus.getDefault().post(ApiTaskProgressEvent(taskProfileId, taskProgress, taskProgressText)) notification.setProgress(taskProgress).post() } @@ -127,7 +127,7 @@ class ApiService : Service() { override fun onStartProgress(stringRes: Int) { lastEventTime = System.currentTimeMillis() taskProgressText = getString(stringRes) - d(TAG, "Task $taskRunningId progress: $taskProgressText") + Timber.d("Task $taskRunningId progress: $taskProgressText") EventBus.getDefault().post(ApiTaskProgressEvent(taskProfileId, taskProgress, taskProgressText)) notification.setProgressText(taskProgressText).post() } @@ -166,7 +166,7 @@ class ApiService : Service() { taskProgress = -1f taskProgressText = task.taskName - d(TAG, "Executing task $taskRunningId - ${task::class.java.name}") + Timber.d("Executing task $taskRunningId - ${task::class.java.name}") // update the notification notification.setCurrentTask(taskRunningId, taskProgressText).post() @@ -200,7 +200,7 @@ class ApiService : Service() { if (System.currentTimeMillis() - lastEventTime > 30*1000 || taskCancelTries >= 3) { val time = System.currentTimeMillis() - lastEventTime - d(TAG, "!!! Task $taskRunningId froze for $time ms. $taskRunning") + Timber.d("!!! Task $taskRunningId froze for $time ms. $taskRunning") clearTask() return true } @@ -245,7 +245,7 @@ class ApiService : Service() { @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC) fun onApiTask(task: IApiTask) { EventBus.getDefault().removeStickyEvent(task) - d(TAG, task.toString()) + Timber.d(task.toString()) if (task is EdziennikTask) { // fix for duplicated tasks, thank you EventBus @@ -270,10 +270,10 @@ class ApiService : Service() { else { taskQueue += task } - d(TAG, "EventBus received an IApiTask: $task") - d(TAG, "Current queue:") + Timber.d("EventBus received an IApiTask: $task") + Timber.d("Current queue:") taskQueue.forEach { - d(TAG, " - $it") + Timber.d(" - $it") } runTask() } @@ -281,7 +281,7 @@ class ApiService : Service() { @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC) fun onTaskCancelRequest(request: TaskCancelRequest) { EventBus.getDefault().removeStickyEvent(request) - d(TAG, request.toString()) + Timber.d(request.toString()) taskCancelTries++ taskCancelled = true @@ -291,7 +291,7 @@ class ApiService : Service() { @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC) fun onServiceCloseRequest(request: ServiceCloseRequest) { EventBus.getDefault().removeStickyEvent(request) - d(TAG, request.toString()) + Timber.d(request.toString()) serviceClosed = true taskCancelled = true @@ -306,19 +306,19 @@ class ApiService : Service() { ____) | __/ | \ V /| | (_| __/ | (_) \ V / __/ | | | | | (_| | __/\__ \ |_____/ \___|_| \_/ |_|\___\___| \___/ \_/ \___|_| |_| |_|\__,_|\___||__*/ override fun onCreate() { - d(TAG, "Service created") + Timber.d("Service created") EventBus.getDefault().register(this) notification.setIdle().setCloseAction() } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - d(TAG, "Foreground service onStartCommand") - startForeground(app.notificationChannelsManager.sync.id, notification.notification) + Timber.d("Foreground service onStartCommand") + startForeground(app.notificationManager.sync.id, notification.notification) return START_NOT_STICKY } override fun onDestroy() { - d(TAG, "Service destroyed") + Timber.d("Service destroyed") serviceClosed = true EventBus.getDefault().unregister(this) } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/EdziennikNotification.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/EdziennikNotification.kt index 6b2b7533..4fbfa6b8 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/EdziennikNotification.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/EdziennikNotification.kt @@ -14,7 +14,7 @@ import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.ext.Bundle import pl.szczodrzynski.edziennik.ext.pendingIntentFlag -import pl.szczodrzynski.edziennik.receivers.SzkolnyReceiver +import pl.szczodrzynski.edziennik.core.receiver.SzkolnyReceiver import kotlin.math.roundToInt @@ -138,7 +138,7 @@ class EdziennikNotification(val app: App) { fun post() { if (serviceClosed) return - notificationManager.notify(app.notificationChannelsManager.sync.id, notification) + notificationManager.notify(app.notificationManager.sync.id, notification) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/EdziennikTask.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/EdziennikTask.kt index c4363301..97c42482 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/EdziennikTask.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/EdziennikTask.kt @@ -30,8 +30,8 @@ import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull import pl.szczodrzynski.edziennik.ext.isBeforeYear import pl.szczodrzynski.edziennik.ext.shouldArchive -import pl.szczodrzynski.edziennik.utils.Utils.d -import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager.Error.Type +import pl.szczodrzynski.edziennik.core.manager.AvailabilityManager.Error.Type +import timber.log.Timber open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTask(profileId) { companion object { @@ -80,16 +80,16 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa internal fun run(app: App, taskCallback: EdziennikCallback) { profile?.let { profile -> if (profile.archived) { - d(TAG, "The profile $profileId is archived") + Timber.d("The profile $profileId is archived") taskCallback.onError(ApiError(TAG, ERROR_PROFILE_ARCHIVED)) return } else if (profile.shouldArchive()) { - d(TAG, "The profile $profileId's year ended on ${profile.dateYearEnd}, archiving") + Timber.d("The profile $profileId's year ended on ${profile.dateYearEnd}, archiving") ProfileArchiver(app, profile) } if (profile.isBeforeYear()) { - d(TAG, "The profile $profileId's school year has not started yet; aborting sync") + Timber.d("The profile $profileId's school year has not started yet; aborting sync") cancel() taskCallback.onCompleted() return @@ -143,7 +143,7 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa } override fun cancel() { - d(TAG, "Task ${toString()} cancelling...") + Timber.d("Task ${toString()} cancelling...") edziennikInterface?.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/ProfileArchiver.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/ProfileArchiver.kt index 151c1859..66160198 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/ProfileArchiver.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/ProfileArchiver.kt @@ -9,8 +9,8 @@ import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.data.enums.LoginType import pl.szczodrzynski.edziennik.ext.Intent -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date +import timber.log.Timber class ProfileArchiver(val app: App, val profile: Profile) { companion object { @@ -20,14 +20,14 @@ class ProfileArchiver(val app: App, val profile: Profile) { init { if (profile.archiveId == null) profile.archiveId = profile.id - d(TAG, "Processing ${profile.name}#${profile.id}, archiveId = ${profile.archiveId}") + Timber.d("Processing ${profile.name}#${profile.id}, archiveId = ${profile.archiveId}") profile.archived = true app.db.profileDao().add(profile) //app.db.metadataDao().setAllSeen(profile.id, true) app.db.notificationDao().clear(profile.id) app.db.endpointTimerDao().clear(profile.id) - d(TAG, "Archived profile ${profile.id} saved") + Timber.d("Archived profile ${profile.id} saved") profile.archived = false // guess the nearest school year @@ -48,7 +48,7 @@ class ProfileArchiver(val app: App, val profile: Profile) { profile.subname = "Nowy rok szkolny - ${profile.studentSchoolYearStart}" profile.studentClassName = null - d(TAG, "New profile ID for ${profile.name}: ${profile.id}") + Timber.d("New profile ID for ${profile.name}: ${profile.id}") when (profile.loginStoreType) { LoginType.LIBRUS -> { @@ -79,7 +79,7 @@ class ProfileArchiver(val app: App, val profile: Profile) { LoginType.TEMPLATE -> {} } - d(TAG, "Processed student data: ${profile.studentData}") + Timber.d("Processed student data: ${profile.studentData}") app.db.profileDao().add(profile) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt index 337f30c2..d13067c3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt @@ -29,7 +29,7 @@ import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface { companion object { @@ -67,10 +67,10 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va } private fun login(loginMethod: LoginMethod? = null, afterLogin: (() -> Unit)? = null) { - d(TAG, "Trying to login with ${data.targetLoginMethods}") + Timber.d("Trying to login with ${data.targetLoginMethods}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } loginMethod?.let { data.prepareFor(it) } afterLogin?.let { this.afterLogin = it } @@ -80,10 +80,10 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va } private fun data() { - d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } afterLogin?.invoke() ?: LibrusData(data) { completed() @@ -158,7 +158,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va override fun firstLogin() { LibrusFirstLogin(data) { completed() } } override fun cancel() { - d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt index 2b736a0f..c5366783 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt @@ -12,7 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.* import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.getString -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection.* open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) { @@ -28,7 +28,7 @@ open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) { fun apiGet(tag: String, endpoint: String, method: Int = GET, payload: JsonObject? = null, ignoreErrors: List = emptyList(), onSuccess: (json: JsonObject) -> Unit) { - d(tag, "Request: Librus/Api - ${if (data.fakeLogin) FAKE_LIBRUS_API else LIBRUS_API_URL}/$endpoint") + Timber.tag(tag).d("Request: Librus/Api - ${if (data.fakeLogin) FAKE_LIBRUS_API else LIBRUS_API_URL}/$endpoint") val callback = object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt index a5d9256e..1b7adcd2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusData.kt @@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.synergia.Librus import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.synergia.LibrusSynergiaInfo import pl.szczodrzynski.edziennik.data.db.entity.Message import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { companion object { @@ -41,7 +42,7 @@ class LibrusData(val data: DataLibrus, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { /** * API diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusMessages.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusMessages.kt index dc8d8c47..0fc25c87 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusMessages.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusMessages.kt @@ -20,7 +20,7 @@ import org.jsoup.parser.Parser import pl.szczodrzynski.edziennik.data.api.* import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.api.models.ApiError -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.io.File import java.io.StringWriter import javax.xml.parsers.DocumentBuilderFactory @@ -43,7 +43,7 @@ open class LibrusMessages(open val data: DataLibrus, open val lastSync: Long?) { fun messagesGet(tag: String, module: String, method: Int = POST, parameters: Map? = null, onSuccess: (doc: Document) -> Unit) { - d(tag, "Request: Librus/Messages - $LIBRUS_MESSAGES_URL/$module") + Timber.tag(tag).d("Request: Librus/Messages - $LIBRUS_MESSAGES_URL/$module") val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response?) { @@ -127,7 +127,7 @@ open class LibrusMessages(open val data: DataLibrus, open val lastSync: Long?) { fun messagesGetJson(tag: String, module: String, method: Int = POST, parameters: Map? = null, onSuccess: (json: JsonObject?) -> Unit) { - d(tag, "Request: Librus/Messages - $LIBRUS_MESSAGES_URL/$module") + Timber.tag(tag).d("Request: Librus/Messages - $LIBRUS_MESSAGES_URL/$module") val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response?) { @@ -211,7 +211,7 @@ open class LibrusMessages(open val data: DataLibrus, open val lastSync: Long?) { fun sandboxGet(tag: String, action: String, parameters: Map? = null, onSuccess: (json: JsonObject) -> Unit) { - d(tag, "Request: Librus/Messages - $LIBRUS_SANDBOX_URL$action") + Timber.tag(tag).d("Request: Librus/Messages - $LIBRUS_SANDBOX_URL$action") val callback = object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response?) { @@ -256,7 +256,7 @@ open class LibrusMessages(open val data: DataLibrus, open val lastSync: Long?) { method: Int = GET, onProgress: (written: Long, total: Long) -> Unit) { - d(tag, "Request: Librus/Messages - $url") + Timber.tag(tag).d("Request: Librus/Messages - $url") val callback = object : FileCallbackHandler(targetFile) { override fun onSuccess(file: File?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusPortal.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusPortal.kt index d1d34226..d1d1083e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusPortal.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusPortal.kt @@ -8,7 +8,7 @@ import pl.szczodrzynski.edziennik.data.api.* import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.getString -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection open class LibrusPortal(open val data: DataLibrus) { @@ -24,7 +24,7 @@ open class LibrusPortal(open val data: DataLibrus) { fun portalGet(tag: String, endpoint: String, method: Int = GET, payload: JsonObject? = null, onSuccess: (json: JsonObject, response: Response?) -> Unit) { - d(tag, "Request: Librus/Portal - ${if (data.fakeLogin) FAKE_LIBRUS_PORTAL else LIBRUS_PORTAL_URL}$endpoint") + Timber.tag(tag).d("Request: Librus/Portal - ${if (data.fakeLogin) FAKE_LIBRUS_PORTAL else LIBRUS_PORTAL_URL}$endpoint") val callback = object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response?) { @@ -59,8 +59,8 @@ open class LibrusPortal(open val data: DataLibrus) { if (response?.code() == HttpURLConnection.HTTP_OK) { try { onSuccess(json, response) - } catch (e: NullPointerException) { - e.printStackTrace() + } catch (e: Exception) { + Timber.e(e) data.error(ApiError(tag, EXCEPTION_LIBRUS_PORTAL_SYNERGIA_TOKEN) .withResponse(response) .withThrowable(e) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusSynergia.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusSynergia.kt index 72faf801..26c1496d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusSynergia.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusSynergia.kt @@ -10,7 +10,7 @@ import im.wangchao.mhttp.callback.TextCallbackHandler import pl.szczodrzynski.edziennik.data.api.* import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.api.models.ApiError -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber open class LibrusSynergia(open val data: DataLibrus, open val lastSync: Long?) { companion object { @@ -25,7 +25,7 @@ open class LibrusSynergia(open val data: DataLibrus, open val lastSync: Long?) { fun synergiaGet(tag: String, endpoint: String, method: Int = GET, parameters: Map = emptyMap(), onSuccess: (text: String) -> Unit) { - d(tag, "Request: Librus/Synergia - $LIBRUS_SYNERGIA_URL/$endpoint") + Timber.tag(tag).d("Request: Librus/Synergia - $LIBRUS_SYNERGIA_URL/$endpoint") val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response?) { @@ -91,7 +91,7 @@ open class LibrusSynergia(open val data: DataLibrus, open val lastSync: Long?) { } fun redirectUrlGet(tag: String, url: String, onSuccess: (url: String) -> Unit) { - d(tag, "Request: Librus/Synergia - $url") + Timber.tag(tag).d("Request: Librus/Synergia - $url") val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTimetables.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTimetables.kt index 8ec3beae..af7f7add 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTimetables.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiTimetables.kt @@ -16,10 +16,10 @@ import pl.szczodrzynski.edziennik.data.db.entity.Metadata import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS import pl.szczodrzynski.edziennik.data.enums.MetadataType import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week +import timber.log.Timber class LibrusApiTimetables(override val data: DataLibrus, override val lastSync: Long?, @@ -71,7 +71,7 @@ class LibrusApiTimetables(override val data: DataLibrus, } } - d(TAG, "Clearing lessons between ${weekStart.stringY_m_d} and ${weekEnd.stringY_m_d} - timetable downloaded for $getDate") + Timber.d("Clearing lessons between ${weekStart.stringY_m_d} and ${weekEnd.stringY_m_d} - timetable downloaded for $getDate") if (data.timetableNotPublic) data.timetableNotPublic = false diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLogin.kt index bf4b2abb..c96001cc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLogin.kt @@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class LibrusLogin(val data: DataLibrus, val onSuccess: () -> Unit) { companion object { @@ -43,7 +44,7 @@ class LibrusLogin(val data: DataLibrus, val onSuccess: () -> Unit) { onSuccess(null) return } - Utils.d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.LIBRUS_PORTAL -> { data.startProgress(R.string.edziennik_progress_login_librus_portal) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginApi.kt index b0268b5c..300da4b2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginApi.kt @@ -17,7 +17,7 @@ import pl.szczodrzynski.edziennik.data.enums.LoginMode import pl.szczodrzynski.edziennik.ext.getInt import pl.szczodrzynski.edziennik.ext.getString import pl.szczodrzynski.edziennik.ext.getUnixDate -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection.* @Suppress("ConvertSecondaryConstructorToPrimary") @@ -171,7 +171,7 @@ class LibrusLoginApi { } private fun synergiaGetToken() { - d(TAG, "Request: Librus/Login/Api - $LIBRUS_API_TOKEN_URL") + Timber.d("Request: Librus/Login/Api - $LIBRUS_API_TOKEN_URL") Request.builder() .url(LIBRUS_API_TOKEN_URL) @@ -192,7 +192,7 @@ class LibrusLoginApi { .enqueue() } private fun synergiaRefreshToken() { - d(TAG, "Request: Librus/Login/Api - $LIBRUS_API_TOKEN_URL") + Timber.d("Request: Librus/Login/Api - $LIBRUS_API_TOKEN_URL") Request.builder() .url(LIBRUS_API_TOKEN_URL) @@ -211,7 +211,7 @@ class LibrusLoginApi { .enqueue() } private fun jstGetToken() { - d(TAG, "Request: Librus/Login/Api - $LIBRUS_API_TOKEN_JST_URL") + Timber.d("Request: Librus/Login/Api - $LIBRUS_API_TOKEN_JST_URL") Request.builder() .url(LIBRUS_API_TOKEN_JST_URL) @@ -233,7 +233,7 @@ class LibrusLoginApi { .enqueue() } private fun jstRefreshToken() { - d(TAG, "Request: Librus/Login/Api - $LIBRUS_API_TOKEN_JST_URL") + Timber.d("Request: Librus/Login/Api - $LIBRUS_API_TOKEN_JST_URL") Request.builder() .url(LIBRUS_API_TOKEN_JST_URL) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginMessages.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginMessages.kt index b2416365..b131904d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginMessages.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginMessages.kt @@ -14,7 +14,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.LibrusRecaptchaHelpe import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.ext.getUnixDate -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.io.StringWriter import javax.xml.parsers.DocumentBuilderFactory import javax.xml.transform.OutputKeys @@ -108,7 +108,7 @@ class LibrusLoginMessages(val data: DataLibrus, val onSuccess: () -> Unit) { * XML (Flash messages website) login method. Uses a Synergia login and password. */ private fun loginWithCredentials() { - d(TAG, "Request: Librus/Login/Messages - $LIBRUS_MESSAGES_URL/Login") + Timber.d("Request: Librus/Login/Messages - $LIBRUS_MESSAGES_URL/Login") val docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder() val doc = docBuilder.newDocument() @@ -152,7 +152,7 @@ class LibrusLoginMessages(val data: DataLibrus, val onSuccess: () -> Unit) { * A login method using the Synergia website (/wiadomosci2 Auto Login). */ private fun loginWithSynergia(url: String = "https://synergia.librus.pl/wiadomosci2") { - d(TAG, "Request: Librus/Login/Messages - $url") + Timber.d("Request: Librus/Login/Messages - $url") Request.builder() .url(url) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginPortal.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginPortal.kt index 8f20faff..2543d9c3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginPortal.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginPortal.kt @@ -14,7 +14,7 @@ import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.data.enums.LoginMode import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection.* import java.util.* import java.util.regex.Pattern @@ -63,7 +63,7 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) { }} private fun authorize(url: String, referer: String? = null) { - d(TAG, "Request: Librus/Login/Portal - $url") + Timber.d("Request: Librus/Login/Portal - $url") Request.builder() .url(url) @@ -176,7 +176,7 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) { return } - d(TAG, "Request: Librus/Login/Portal - $url") + Timber.d("Request: Librus/Login/Portal - $url") val recaptchaCode = data.arguments?.getString("recaptchaCode") ?: data.loginStore.getLoginData("recaptchaCode", null) val recaptchaTime = data.arguments?.getLong("recaptchaTime") ?: data.loginStore.getLoginData("recaptchaTime", 0L) @@ -239,7 +239,7 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) { } private fun accessToken(code: String?, refreshToken: String?) { - d(TAG, "Request: Librus/Login/Portal - ${if (data.fakeLogin) FAKE_LIBRUS_TOKEN else LIBRUS_TOKEN_URL}") + Timber.d("Request: Librus/Login/Portal - ${if (data.fakeLogin) FAKE_LIBRUS_TOKEN else LIBRUS_TOKEN_URL}") val onSuccess = { json: JsonObject, response: Response? -> data.portalAccessToken = json.getString("access_token") diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginSynergia.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginSynergia.kt index 62b9a7ba..aad97f2d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginSynergia.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/LibrusLoginSynergia.kt @@ -15,7 +15,7 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.ext.getString import pl.szczodrzynski.edziennik.ext.getUnixDate -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection class LibrusLoginSynergia(override val data: DataLibrus, val onSuccess: () -> Unit) : LibrusApi(data, null) { @@ -58,7 +58,7 @@ class LibrusLoginSynergia(override val data: DataLibrus, val onSuccess: () -> Un * A login method using the Synergia API (AutoLoginToken endpoint). */ private fun loginWithApi() { - d(TAG, "Request: Librus/Login/Synergia - $LIBRUS_API_URL/AutoLoginToken") + Timber.d("Request: Librus/Login/Synergia - $LIBRUS_API_URL/AutoLoginToken") val onSuccess = { json: JsonObject -> loginWithToken(json.getString("Token")) @@ -73,7 +73,7 @@ class LibrusLoginSynergia(override val data: DataLibrus, val onSuccess: () -> Un return } - d(TAG, "Request: Librus/Login/Synergia - " + LIBRUS_SYNERGIA_TOKEN_LOGIN_URL.replace("TOKEN", token) + "/uczen/widok/centrum_powiadomien") + Timber.d("Request: Librus/Login/Synergia - " + LIBRUS_SYNERGIA_TOKEN_LOGIN_URL.replace("TOKEN", token) + "/uczen/widok/centrum_powiadomien") val callback = object : TextCallbackHandler() { override fun onSuccess(json: String?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/SynergiaTokenExtractor.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/SynergiaTokenExtractor.kt index 54ec450e..d70b04bc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/SynergiaTokenExtractor.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/login/SynergiaTokenExtractor.kt @@ -9,7 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusPortal import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.data.enums.LoginMode import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class SynergiaTokenExtractor(override val data: DataLibrus, val onSuccess: () -> Unit) : LibrusPortal(data) { companion object { @@ -45,7 +45,7 @@ class SynergiaTokenExtractor(override val data: DataLibrus, val onSuccess: () -> val accountLogin = data.apiLogin ?: return false data.portalAccessToken ?: return false - d(TAG, "Request: Librus/SynergiaTokenExtractor - ${if (data.fakeLogin) FAKE_LIBRUS_ACCOUNT else LIBRUS_ACCOUNT_URL}$accountLogin") + Timber.d("Request: Librus/SynergiaTokenExtractor - ${if (data.fakeLogin) FAKE_LIBRUS_ACCOUNT else LIBRUS_ACCOUNT_URL}$accountLogin") val onSuccess = { json: JsonObject, response: Response? -> // synergiaAccount is executed when a synergia token needs a refresh diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/Mobidziennik.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/Mobidziennik.kt index 1e8a96da..65b9cd35 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/Mobidziennik.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/Mobidziennik.kt @@ -23,7 +23,7 @@ import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface { companion object { @@ -63,10 +63,10 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto } private fun login(loginMethod: LoginMethod? = null, afterLogin: (() -> Unit)? = null) { - d(TAG, "Trying to login with ${data.targetLoginMethods}") + Timber.d("Trying to login with ${data.targetLoginMethods}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } loginMethod?.let { data.prepareFor(it) } afterLogin?.let { this.afterLogin = it } @@ -76,10 +76,10 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto } private fun data() { - d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } afterLogin?.invoke() ?: MobidziennikData(data) { completed() @@ -138,7 +138,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto override fun firstLogin() { MobidziennikFirstLogin(data) { completed() } } override fun cancel() { - d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikData.kt index 4b58d203..d4180eae 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikData.kt @@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api.Mobid import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api2.MobidziennikApi2Main import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.* import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) { companion object { @@ -38,7 +39,7 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { ENDPOINT_MOBIDZIENNIK_API_MAIN -> { data.startProgress(R.string.edziennik_progress_endpoint_data) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikWeb.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikWeb.kt index cfb4ab49..236268e0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikWeb.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/MobidziennikWeb.kt @@ -11,7 +11,7 @@ import im.wangchao.mhttp.callback.TextCallbackHandler import pl.szczodrzynski.edziennik.data.api.* import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik import pl.szczodrzynski.edziennik.data.api.models.ApiError -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.io.File open class MobidziennikWeb(open val data: DataMobidziennik, open val lastSync: Long?) { @@ -52,7 +52,7 @@ open class MobidziennikWeb(open val data: DataMobidziennik, open val lastSync: L ) { val url = fullUrl ?: "https://${data.loginServerName}.mobidziennik.pl$endpoint" - d(tag, "Request: Mobidziennik/Web - $url") + Timber.tag(tag).d("Request: Mobidziennik/Web - $url") if (data.webSessionKey == null) { data.error(TAG, ERROR_MOBIDZIENNIK_WEB_NO_SESSION_KEY) @@ -128,7 +128,7 @@ open class MobidziennikWeb(open val data: DataMobidziennik, open val lastSync: L onProgress: (written: Long, total: Long) -> Unit) { val url = "https://${data.loginServerName}.mobidziennik.pl$action" - d(tag, "Request: Mobidziennik/Web - $url") + Timber.tag(tag).d("Request: Mobidziennik/Web - $url") if (data.webSessionKey == null) { data.error(TAG, ERROR_MOBIDZIENNIK_WEB_NO_SESSION_KEY) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api/MobidziennikApiEvents.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api/MobidziennikApiEvents.kt index 40a357d0..422dca35 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api/MobidziennikApiEvents.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api/MobidziennikApiEvents.kt @@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Metadata import pl.szczodrzynski.edziennik.data.enums.MetadataType import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time +import timber.log.Timber import java.text.ParseException import java.text.SimpleDateFormat import java.util.* @@ -45,8 +46,8 @@ class MobidziennikApiEvents(val data: DataMobidziennik, rows: List) { val format = SimpleDateFormat("yyyyMMddHHmmss", Locale.US) val addedDate = try { format.parse(cols[7]).time - } catch (e: ParseException) { - e.printStackTrace() + } catch (e: Exception) { + Timber.e(e) System.currentTimeMillis() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api2/MobidziennikApi2Main.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api2/MobidziennikApi2Main.kt index 9c231849..2edfcc2a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api2/MobidziennikApi2Main.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/api2/MobidziennikApi2Main.kt @@ -17,6 +17,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS import pl.szczodrzynski.edziennik.ext.getJsonObject import pl.szczodrzynski.edziennik.ext.getString import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class MobidziennikApi2Main(val data: DataMobidziennik, val lastSync: Long?, @@ -33,7 +34,7 @@ class MobidziennikApi2Main(val data: DataMobidziennik, get() = data.profile init { - Utils.d(TAG, "Request: Mobidziennik/Api2/Main - https://${data.loginServerName}.mobidziennik.pl/api2/logowanie") + Timber.d("Request: Mobidziennik/Api2/Main - https://${data.loginServerName}.mobidziennik.pl/api2/logowanie") val callback = object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebAttendance.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebAttendance.kt index 3fe26720..0672ea8d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebAttendance.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/data/web/MobidziennikWebAttendance.kt @@ -25,10 +25,10 @@ import pl.szczodrzynski.edziennik.ext.dateToSemester import pl.szczodrzynski.edziennik.ext.fixName import pl.szczodrzynski.edziennik.ext.get import pl.szczodrzynski.edziennik.ext.singleOrNull -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week +import timber.log.Timber class MobidziennikWebAttendance(override val data: DataMobidziennik, override val lastSync: Long?, @@ -156,7 +156,7 @@ class MobidziennikWebAttendance(override val data: DataMobidziennik, } } - d(TAG, "Done in ${System.currentTimeMillis()-start} ms (request ${start-requestTime} ms)") + Timber.d("Done in ${System.currentTimeMillis()-start} ms (request ${start-requestTime} ms)") onSuccess() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLogin.kt index 373e10e2..ee539df0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLogin.kt @@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class MobidziennikLogin(val data: DataMobidziennik, val onSuccess: () -> Unit) { companion object { @@ -43,7 +44,7 @@ class MobidziennikLogin(val data: DataMobidziennik, val onSuccess: () -> Unit) { onSuccess(null) return } - Utils.d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.MOBIDZIENNIK_WEB -> { data.startProgress(R.string.edziennik_progress_login_mobidziennik_web) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginApi2.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginApi2.kt index 01d7b9b7..2f6690f1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginApi2.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginApi2.kt @@ -19,6 +19,7 @@ import pl.szczodrzynski.edziennik.ext.getString import pl.szczodrzynski.edziennik.ext.isNotNullNorBlank import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class MobidziennikLoginApi2(val data: DataMobidziennik, val onSuccess: () -> Unit) { companion object { @@ -54,7 +55,7 @@ class MobidziennikLoginApi2(val data: DataMobidziennik, val onSuccess: () -> Uni }} private fun loginWithCredentials() { - Utils.d(TAG, "Request: Mobidziennik/Login/Api2 - https://mobidziennik.pl/logowanie") + Timber.d("Request: Mobidziennik/Login/Api2 - https://mobidziennik.pl/logowanie") val callback = object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginWeb.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginWeb.kt index ce801a73..5ea92107 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginWeb.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/mobidziennik/login/MobidziennikLoginWeb.kt @@ -13,7 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.Mobidziennik import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.getUnixDate import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class MobidziennikLoginWeb(val data: DataMobidziennik, val onSuccess: () -> Unit) { companion object { @@ -36,7 +36,7 @@ class MobidziennikLoginWeb(val data: DataMobidziennik, val onSuccess: () -> Unit }} private fun loginWithCredentials() { - d(TAG, "Request: Mobidziennik/Login/Web - https://${data.loginServerName}.mobidziennik.pl/api/") + Timber.d("Request: Mobidziennik/Login/Web - https://${data.loginServerName}.mobidziennik.pl/api/") val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response?) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/Podlasie.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/Podlasie.kt index 3b08b7af..0ee556a6 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/Podlasie.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/Podlasie.kt @@ -25,6 +25,7 @@ import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber import java.io.File class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface { @@ -58,8 +59,8 @@ class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore, override fun sync(featureTypes: Set?, onlyEndpoints: Set?, arguments: JsonObject?) { data.arguments = arguments data.prepare(PodlasieFeatures, featureTypes, onlyEndpoints) - Utils.d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}") - Utils.d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("LoginMethod IDs: ${data.targetLoginMethods}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") PodlasieLogin(data) { PodlasieData(data) { completed() @@ -133,7 +134,7 @@ class Podlasie(val app: App, val profile: Profile?, val loginStore: LoginStore, } override fun cancel() { - Utils.d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieApi.kt index 726b851a..4258cf0a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieApi.kt @@ -16,6 +16,7 @@ import pl.szczodrzynski.edziennik.ext.getInt import pl.szczodrzynski.edziennik.ext.getJsonObject import pl.szczodrzynski.edziennik.ext.toHexString import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber import java.security.MessageDigest import java.text.SimpleDateFormat import java.util.* @@ -34,7 +35,7 @@ open class PodlasieApi(open val data: DataPodlasie, open val lastSync: Long?) { fun apiGet(tag: String, endpoint: String, onSuccess: (json: JsonObject) -> Unit) { val url = PODLASIE_API_URL + endpoint - Utils.d(tag, "Request: Podlasie/Api - $url") + Timber.tag(tag).d("Request: Podlasie/Api - $url") if (data.apiToken == null) { data.error(tag, ERROR_PODLASIE_API_NO_TOKEN) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieData.kt index f1117537..ee229af3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/data/PodlasieData.kt @@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.ENDPOINT_PODLASIE_API_MAIN import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api.PodlasieApiMain import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class PodlasieData(val data: DataPodlasie, val onSuccess: () -> Unit) { companion object { @@ -37,7 +38,7 @@ class PodlasieData(val data: DataPodlasie, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { ENDPOINT_PODLASIE_API_MAIN -> { data.startProgress(R.string.edziennik_progress_endpoint_data) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/login/PodlasieLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/login/PodlasieLogin.kt index 8850f0db..bcb89f98 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/login/PodlasieLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/podlasie/login/PodlasieLogin.kt @@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) { companion object { @@ -43,7 +44,7 @@ class PodlasieLogin(val data: DataPodlasie, val onSuccess: () -> Unit) { onSuccess(null) return } - Utils.d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.PODLASIE_API -> { data.startProgress(R.string.edziennik_progress_login_podlasie_api) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/Template.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/Template.kt index 9a6c3405..6dbbee45 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/Template.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/Template.kt @@ -22,7 +22,7 @@ import pl.szczodrzynski.edziennik.data.enums.FeatureType import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class Template(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface { companion object { @@ -55,8 +55,8 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore, override fun sync(featureTypes: Set?, onlyEndpoints: Set?, arguments: JsonObject?) { data.arguments = arguments data.prepare(TemplateFeatures, featureTypes, onlyEndpoints) - d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}") - d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("LoginMethod IDs: ${data.targetLoginMethods}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") TemplateLogin(data) { TemplateData(data) { completed() @@ -99,7 +99,7 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore, } override fun cancel() { - d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/data/TemplateData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/data/TemplateData.kt index 4b759e34..57242f72 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/data/TemplateData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/data/TemplateData.kt @@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.api.TemplateA import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.web.TemplateWebSample import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.web.TemplateWebSample2 import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class TemplateData(val data: DataTemplate, val onSuccess: () -> Unit) { companion object { @@ -41,7 +42,7 @@ class TemplateData(val data: DataTemplate, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { ENDPOINT_TEMPLATE_WEB_SAMPLE -> { data.startProgress(R.string.edziennik_progress_endpoint_student_info) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/login/TemplateLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/login/TemplateLogin.kt index 214164c8..62d28c6b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/login/TemplateLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/template/login/TemplateLogin.kt @@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.template.DataTemplate import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class TemplateLogin(val data: DataTemplate, val onSuccess: () -> Unit) { companion object { @@ -43,7 +44,7 @@ class TemplateLogin(val data: DataTemplate, val onSuccess: () -> Unit) { onSuccess(null) return } - Utils.d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.TEMPLATE_WEB -> { data.startProgress(R.string.edziennik_progress_login_template_web) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/Usos.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/Usos.kt index 64be9a83..66baee4a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/Usos.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/Usos.kt @@ -21,7 +21,7 @@ import pl.szczodrzynski.edziennik.data.enums.FeatureType import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class Usos( val app: App, @@ -55,8 +55,8 @@ class Usos( ) { data.arguments = arguments data.prepare(UsosFeatures, featureTypes, onlyEndpoints) - d(TAG, "LoginMethod IDs: ${data.targetLoginMethods}") - d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("LoginMethod IDs: ${data.targetLoginMethods}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") UsosLogin(data) { UsosData(data) { completed() @@ -79,7 +79,7 @@ class Usos( } override fun cancel() { - d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosApi.kt index 9f716d50..50eebbbd 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosApi.kt @@ -19,7 +19,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.usos.DataUsos import pl.szczodrzynski.edziennik.data.api.edziennik.usos.login.UsosLoginApi import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.net.HttpURLConnection.* import java.util.UUID @@ -89,7 +89,7 @@ open class UsosApi(open val data: DataUsos, open val lastSync: Long?) { onSuccess: (data: T, response: Response?) -> Unit, ) { val url = "${data.instanceUrl}services/$service" - d(tag, "Request: Usos/Api - $url") + Timber.tag(tag).d("Request: Usos/Api - $url") val formData = mutableMapOf() if (params != null) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosData.kt index dbccb16b..240907cb 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/data/UsosData.kt @@ -5,13 +5,12 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.usos.data import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.data.api.edziennik.template.data.web.TemplateWebSample import pl.szczodrzynski.edziennik.data.api.edziennik.usos.* import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.api.UsosApiCourses import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.api.UsosApiTerms import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.api.UsosApiTimetable import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.api.UsosApiUser -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class UsosData(val data: DataUsos, val onSuccess: () -> Unit) { companion object { @@ -40,7 +39,7 @@ class UsosData(val data: DataUsos, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { ENDPOINT_USOS_API_USER -> { data.startProgress(R.string.edziennik_progress_endpoint_student_info) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLogin.kt index 85a04258..167994cf 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLogin.kt @@ -7,7 +7,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.usos.login import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.usos.DataUsos import pl.szczodrzynski.edziennik.data.enums.LoginMethod -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class UsosLogin(val data: DataUsos, val onSuccess: () -> Unit) { companion object { @@ -43,7 +43,7 @@ class UsosLogin(val data: DataUsos, val onSuccess: () -> Unit) { onSuccess(null) return } - d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.USOS_API -> { data.startProgress(R.string.edziennik_progress_login_usos_api) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLoginApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLoginApi.kt index 06651477..5db6ab32 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLoginApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/usos/login/UsosLoginApi.kt @@ -11,7 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.usos.data.UsosApi import pl.szczodrzynski.edziennik.data.api.events.UserActionRequiredEvent import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) { companion object { @@ -71,7 +71,7 @@ class UsosLoginApi(val data: DataUsos, val onSuccess: () -> Unit) { } private fun login() { - d(TAG, "Login to ${data.schoolId} with ${data.oauthLoginResponse}") + Timber.d("Login to ${data.schoolId} with ${data.oauthLoginResponse}") val authorizeResponse = data.oauthLoginResponse?.fromQueryString() ?: return // checked in init {} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/Vulcan.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/Vulcan.kt index 77f0eb48..4ecf308b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/Vulcan.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/Vulcan.kt @@ -34,7 +34,7 @@ import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.full.EventFull import pl.szczodrzynski.edziennik.data.db.full.MessageFull import pl.szczodrzynski.edziennik.utils.Utils -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import java.io.File class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface { @@ -78,10 +78,10 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va return } - d(TAG, "Trying to login with ${data.targetLoginMethods}") + Timber.d("Trying to login with ${data.targetLoginMethods}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } loginMethod?.let { data.prepareFor(it) } afterLogin?.let { this.afterLogin = it } @@ -91,10 +91,10 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va } private fun data() { - d(TAG, "Endpoint IDs: ${data.targetEndpoints}") + Timber.d("Endpoint IDs: ${data.targetEndpoints}") if (internalErrorList.isNotEmpty()) { - d(TAG, " - Internal errors:") - internalErrorList.forEach { d(TAG, " - code $it") } + Timber.d(" - Internal errors:") + internalErrorList.forEach { Timber.d(" - code $it") } } afterLogin?.invoke() ?: VulcanData(data) { completed() @@ -179,7 +179,7 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va override fun firstLogin() { VulcanFirstLogin(data) { completed() } } override fun cancel() { - d(TAG, "Cancelled") + Timber.d("Cancelled") data.cancel() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanData.kt index 41014919..5f420ec5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanData.kt @@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.hebe.* import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.web.VulcanWebLuckyNumber import pl.szczodrzynski.edziennik.data.db.entity.Message import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) { companion object { @@ -82,7 +83,7 @@ class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) { } private fun useEndpoint(endpointId: Int, lastSync: Long?, onSuccess: (endpointId: Int) -> Unit) { - Utils.d(TAG, "Using endpoint $endpointId. Last sync time = $lastSync") + Timber.d("Using endpoint $endpointId. Last sync time = $lastSync") when (endpointId) { ENDPOINT_VULCAN_WEB_LUCKY_NUMBERS -> { data.startProgress(R.string.edziennik_progress_endpoint_lucky_number) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt index 5031393f..b182d693 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt @@ -22,9 +22,9 @@ import pl.szczodrzynski.edziennik.data.db.entity.LessonRange import pl.szczodrzynski.edziennik.data.db.entity.Subject import pl.szczodrzynski.edziennik.data.db.entity.Teacher import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time +import timber.log.Timber import java.net.HttpURLConnection import java.net.HttpURLConnection.HTTP_NOT_FOUND import java.net.URLEncoder @@ -189,7 +189,7 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) { ) { val url = "${if (baseUrl) data.apiUrl else data.fullApiUrl}$endpoint" - d(tag, "Request: Vulcan/Hebe - $url") + Timber.tag(tag).d("Request: Vulcan/Hebe - $url") val privateKey = data.hebePrivateKey val publicHash = data.hebePublicHash diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanWebMain.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanWebMain.kt index e1cc52e6..03466a86 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanWebMain.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanWebMain.kt @@ -18,6 +18,7 @@ import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.ext.* import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.models.Date +import timber.log.Timber import java.io.File import java.net.HttpURLConnection @@ -269,7 +270,7 @@ open class VulcanWebMain(open val data: DataVulcan, open val lastSync: Long?) { else -> "uonetplus" } + ".${data.webHost}/${data.symbol}/$endpoint" - Utils.d(tag, "Request: Vulcan/WebMain - $url") + Timber.tag(tag).d("Request: Vulcan/WebMain - $url") val payload = JsonObject() parameters.map { (name, value) -> diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeTimetable.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeTimetable.kt index 392590de..c772272f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeTimetable.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeTimetable.kt @@ -25,9 +25,9 @@ import pl.szczodrzynski.edziennik.ext.getBoolean import pl.szczodrzynski.edziennik.ext.getInt import pl.szczodrzynski.edziennik.ext.getJsonObject import pl.szczodrzynski.edziennik.ext.getString -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Week +import timber.log.Timber class VulcanHebeTimetable( override val data: DataVulcan, @@ -107,8 +107,7 @@ class VulcanHebeTimetable( date.stepForward(0, 0, 1) } - d( - TAG, + Timber.d( "Clearing lessons between ${dateFrom.stringY_m_d} and ${dateTo.stringY_m_d}" ) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/login/VulcanLogin.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/login/VulcanLogin.kt index e91e166c..ca6df1b7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/login/VulcanLogin.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/login/VulcanLogin.kt @@ -8,6 +8,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class VulcanLogin(val data: DataVulcan, val onSuccess: () -> Unit) { companion object { @@ -43,7 +44,7 @@ class VulcanLogin(val data: DataVulcan, val onSuccess: () -> Unit) { onSuccess(null) return } - Utils.d(TAG, "Using login method $loginMethod") + Timber.d("Using login method $loginMethod") when (loginMethod) { LoginMethod.VULCAN_WEB_MAIN -> { data.startProgress(R.string.edziennik_progress_login_vulcan_web_main) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/Data.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/Data.kt index 6e16443b..90151043 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/Data.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/models/Data.kt @@ -22,6 +22,7 @@ import pl.szczodrzynski.edziennik.data.enums.LoginMethod import pl.szczodrzynski.edziennik.ext.* import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.models.Date +import timber.log.Timber abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginStore) { companion object { @@ -159,11 +160,6 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt } } - private fun d(message: String) { - if (DEBUG) - Utils.d(TAG, message) - } - fun clear() { loginMethods.clear() @@ -201,7 +197,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt return // return on first login val totalStart = System.currentTimeMillis() var startTime = System.currentTimeMillis() - d("Saving data to DB") + Timber.d("Saving data to DB") profile.userCode = generateUserCode() @@ -233,7 +229,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt } } - d("Profiles saved in ${System.currentTimeMillis()-startTime} ms") + Timber.d("Profiles saved in ${System.currentTimeMillis()-startTime} ms") startTime = System.currentTimeMillis() // always present and not empty, during every sync @@ -250,7 +246,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt db.gradeCategoryDao().clear(profileId) db.gradeCategoryDao().addAll(gradeCategories.values()) - d("Maps saved in ${System.currentTimeMillis()-startTime} ms") + Timber.d("Maps saved in ${System.currentTimeMillis()-startTime} ms") startTime = System.currentTimeMillis() // may be empty - extracted from DB on demand, by an endpoint @@ -267,12 +263,12 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt if (librusLessons.size > 0) db.librusLessonDao().addAll(librusLessons.values()) - d("On-demand maps saved in ${System.currentTimeMillis()-startTime} ms") + Timber.d("On-demand maps saved in ${System.currentTimeMillis()-startTime} ms") startTime = System.currentTimeMillis() // clear DB with DataRemoveModels added by endpoints for (model in toRemove) { - d("Clearing DB with $model") + Timber.d("Clearing DB with $model") when (model) { is DataRemoveModel.Timetable -> model.commit(profileId, db.timetableDao()) is DataRemoveModel.Grades -> model.commit(profileId, db.gradeDao()) @@ -281,7 +277,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt } } - d("DB cleared in ${System.currentTimeMillis()-startTime} ms") + Timber.d("DB cleared in ${System.currentTimeMillis()-startTime} ms") startTime = System.currentTimeMillis() if (metadataList.isNotEmpty()) @@ -289,7 +285,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt if (setSeenMetadataList.isNotEmpty()) db.metadataDao().setSeen(setSeenMetadataList) - d("Metadata saved in ${System.currentTimeMillis()-startTime} ms") + Timber.d("Metadata saved in ${System.currentTimeMillis()-startTime} ms") startTime = System.currentTimeMillis() db.timetableDao().putAll(lessonList, removeNotKept = true) @@ -310,9 +306,9 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt if (messageRecipientIgnoreList.isNotEmpty()) db.messageRecipientDao().addAllIgnore(messageRecipientIgnoreList) - d("Other data saved in ${System.currentTimeMillis()-startTime} ms") + Timber.d("Other data saved in ${System.currentTimeMillis()-startTime} ms") - d("Total save time: ${System.currentTimeMillis()-totalStart} ms") + Timber.d("Total save time: ${System.currentTimeMillis()-totalStart} ms") } fun setSyncNext(endpointId: Int, syncIn: Long? = null, forceFeatureType: FeatureType? = null, syncAt: Long? = null) { @@ -339,7 +335,7 @@ abstract class Data(val app: App, val profile: Profile?, val loginStore: LoginSt abstract fun generateUserCode(): String fun cancel() { - d("Cancelled") + Timber.d("Cancelled") cancelled = true saveData() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt index f520ac62..0d1fed43 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt @@ -10,6 +10,7 @@ import android.content.pm.PackageManager import android.util.Base64 import pl.szczodrzynski.edziennik.BuildConfig import pl.szczodrzynski.edziennik.ext.sha256 +import timber.log.Timber import java.security.MessageDigest object Signing { @@ -32,7 +33,7 @@ object Signing { appCertificate = Base64.encodeToString(md.digest(), Base64.NO_WRAP) } } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) } }} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/ErrorReportTask.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/ErrorReportTask.kt index 230be5c0..46872d76 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/ErrorReportTask.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/ErrorReportTask.kt @@ -11,6 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.EdziennikNotification import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback import pl.szczodrzynski.edziennik.data.api.models.ApiError import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber class ErrorReportTask : IApiTask(-1) { override fun prepare(app: App) { @@ -23,7 +24,7 @@ class ErrorReportTask : IApiTask(-1) { fun run(app: App, taskCallback: EdziennikCallback, notification: EdziennikNotification, errorList: MutableList) { errorList.forEach { error -> - Utils.d(ApiService.TAG, "Error ${error.tag} profile ${error.profileId}: code ${error.errorCode}") + Timber.d("Error ${error.tag} profile ${error.profileId}: code ${error.errorCode}") } errorList.clear() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt index a27e4174..b7633343 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/PostNotifications.kt @@ -51,7 +51,7 @@ class PostNotifications(val app: App, nList: List) { else it.setDefaults(NotificationCompat.DEFAULT_ALL) } - .setGroup(if (quiet) app.notificationChannelsManager.dataQuiet.key else app.notificationChannelsManager.data.key) + .setGroup(if (quiet) app.notificationManager.dataQuiet.key else app.notificationManager.data.key) } private fun buildSummaryText(summaryCounts: Map): CharSequence { @@ -79,7 +79,7 @@ class PostNotifications(val app: App, nList: List) { MainActivity::class.java, "fragmentId" to NavTarget.NOTIFICATIONS ) - val summaryIntent = PendingIntent.getActivity(app, app.notificationChannelsManager.data.id, intent, PendingIntent.FLAG_ONE_SHOT or pendingIntentFlag()) + val summaryIntent = PendingIntent.getActivity(app, app.notificationManager.data.id, intent, PendingIntent.FLAG_ONE_SHOT or pendingIntentFlag()) // On Nougat or newer - show maximum 8 notifications // On Marshmallow or older - show maximum 4 notifications @@ -95,7 +95,7 @@ class PostNotifications(val app: App, nList: List) { } // Create a summary to show *instead* of notifications - val combined = NotificationCompat.Builder(app, app.notificationChannelsManager.data.key) + val combined = NotificationCompat.Builder(app, app.notificationManager.data.key) .setContentTitle(app.getString(R.string.app_name)) .setContentText(buildSummaryText(summaryCounts)) .setTicker(newNotificationsText) @@ -128,7 +128,7 @@ class PostNotifications(val app: App, nList: List) { // Less than 8 notifications val notifications = nList.map { summaryCounts[it.type] = summaryCounts.getOrDefault(it.type, 0) + 1 - NotificationCompat.Builder(app, app.notificationChannelsManager.data.key) + NotificationCompat.Builder(app, app.notificationManager.data.key) .setContentTitle(it.profileName ?: app.getString(R.string.app_name)) .setContentText(it.text) .setSubText(if (it.type == NotificationType.SERVER_MESSAGE) null else it.title) @@ -155,7 +155,7 @@ class PostNotifications(val app: App, nList: List) { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - val summary = NotificationCompat.Builder(app, app.notificationChannelsManager.data.key) + val summary = NotificationCompat.Builder(app, app.notificationManager.data.key) .setContentTitle(newNotificationsText) .setContentText(buildSummaryText(summaryCounts)) .setTicker(newNotificationsText) @@ -170,7 +170,7 @@ class PostNotifications(val app: App, nList: List) { .setAutoCancel(true) .build() - notificationManager.notify(app.notificationChannelsManager.data.id, summary) + notificationManager.notify(app.notificationManager.data.id, summary) } } }} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/SzkolnyTask.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/SzkolnyTask.kt index 64f647e9..70238b36 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/SzkolnyTask.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/SzkolnyTask.kt @@ -11,7 +11,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi import pl.szczodrzynski.edziennik.data.db.entity.Notification import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.ext.HOUR -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class SzkolnyTask(val app: App, val syncingProfiles: List) : IApiTask(-1) { companion object { @@ -49,7 +49,7 @@ class SzkolnyTask(val app: App, val syncingProfiles: List) : IApiTask(- notifications.sharedEventNotifications() } } - d(TAG, "Created ${notificationList.count()} notifications.") + Timber.d("Created ${notificationList.count()} notifications.") // filter notifications notificationList @@ -70,7 +70,7 @@ class SzkolnyTask(val app: App, val syncingProfiles: List) : IApiTask(- // post all notifications PostNotifications(app, notificationList) - d(TAG, "SzkolnyTask: finished in ${System.currentTimeMillis()-startTime} ms.") + Timber.d("SzkolnyTask: finished in ${System.currentTimeMillis()-startTime} ms.") taskCallback.onCompleted() } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/AppData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/AppData.kt index e2ab6b10..5cfd2aff 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/AppData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/AppData.kt @@ -13,7 +13,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.enums.LoginType import pl.szczodrzynski.edziennik.ext.getJsonObject import pl.szczodrzynski.edziennik.ext.mergeWith -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode data class AppData( val configOverrides: Map, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/BaseConfig.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/BaseConfig.kt index ce2a2ebc..6b345b55 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/BaseConfig.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/BaseConfig.kt @@ -4,14 +4,14 @@ package pl.szczodrzynski.edziennik.data.config +import android.util.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.data.db.entity.ConfigEntry -import pl.szczodrzynski.edziennik.ext.takePositive -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import kotlin.coroutines.CoroutineContext abstract class BaseConfig( @@ -32,6 +32,7 @@ abstract class BaseConfig( val values = hashMapOf() private var currentDataVersion: Int by config("dataVersion") { + Timber.d("Initializing ${this::class.java.simpleName} version $dataVersion") currentDataVersion = dataVersion dataVersion } @@ -45,15 +46,19 @@ abstract class BaseConfig( entries = app.db.configDao().getAllNow() values.clear() for ((profileId, key, value) in entries!!) { - if (profileId.takePositive() != this.profileId) + if (profileId != (this.profileId ?: -1)) continue values[key] = value + Timber.v("Loaded ${this::class.java.simpleName} profile $profileId key $key value $value") } } fun migrate() { - if (this.dataVersion == this.currentDataVersion) + if (this.dataVersion == this.currentDataVersion) { + Timber.d("Config ${this::class.java.simpleName} is up to date (${this.currentDataVersion})") return + } + Timber.i("Migrating ${this::class.java.simpleName} ${this.currentDataVersion} -> ${this.dataVersion}") var dataVersion = this.currentDataVersion while (dataVersion < this.dataVersion) { @Suppress("UNCHECKED_CAST") @@ -70,7 +75,7 @@ abstract class BaseConfig( operator fun set(key: String, value: String?) { values[key] = value launch(Dispatchers.IO) { - d(TAG, "Setting config value ($profileId): $key = $value") + Timber.i("Setting config value ($profileId): $key = $value") app.db.configDao().add(ConfigEntry(profileId ?: -1, key, value)) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Config.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Config.kt index 4063fe4d..bad730a0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Config.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Config.kt @@ -10,20 +10,20 @@ import pl.szczodrzynski.edziennik.BuildConfig import pl.szczodrzynski.edziennik.data.config.migration.ConfigMigration11 import pl.szczodrzynski.edziennik.data.api.szkolny.response.RegisterAvailabilityStatus import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update -import pl.szczodrzynski.edziennik.data.config.migration.ConfigMigration13 +import pl.szczodrzynski.edziennik.data.config.migration.ConfigMigration14 import pl.szczodrzynski.edziennik.data.enums.NavTarget import pl.szczodrzynski.edziennik.data.enums.Theme import pl.szczodrzynski.edziennik.ext.HOUR -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.ORDER_BY_DATE_DESC +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.ORDER_BY_DATE_DESC import pl.szczodrzynski.edziennik.utils.models.Time class Config(app: App) : BaseConfig(app, profileId = null) { - override val dataVersion = 13 + override val dataVersion = 14 override val migrations get() = mapOf( 11 to ConfigMigration11(), - 13 to ConfigMigration13(), + 14 to ConfigMigration14(), ) private val profileConfigs: HashMap = hashMapOf() @@ -58,6 +58,7 @@ class Config(app: App) : BaseConfig(app, profileId = null) { var apiKeyCustom by config(null) var appInstalledTime by config(0L) var appRateSnackbarTime by config(0L) + var lastLogCleanupTime by config(0L) var appVersion by config(BuildConfig.VERSION_CODE) var validation by config(null, "buildValidation") diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Delegate.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Delegate.kt index bb8da410..3756bfde 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Delegate.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/Delegate.kt @@ -4,15 +4,14 @@ package pl.szczodrzynski.edziennik.data.config -import android.util.Log import com.google.gson.Gson import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time +import timber.log.Timber import java.lang.reflect.ParameterizedType import java.lang.reflect.WildcardType import kotlin.reflect.KProperty @@ -108,8 +107,7 @@ class ConfigDelegate( value = config[key]?.let(::deserialize) } catch (e: Exception) { value = getDefault() - d(TAG, "Couldn't deserialize '$key'") - e.printStackTrace() + Timber.e(e, "Couldn't deserialize '$key'") } if (value == null && !nullable) value = getDefault() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/ProfileConfig.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/ProfileConfig.kt index f5c2bb8f..99183417 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/ProfileConfig.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/ProfileConfig.kt @@ -14,8 +14,8 @@ import pl.szczodrzynski.edziennik.data.db.entity.ConfigEntry import pl.szczodrzynski.edziennik.data.db.entity.Profile.Companion.AGENDA_DEFAULT import pl.szczodrzynski.edziennik.data.enums.NotificationType import pl.szczodrzynski.edziennik.ui.home.HomeCardModel -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_WEIGHTED -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_ALL_GRADES +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.COLOR_MODE_WEIGHTED +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_ALL_GRADES class ProfileConfig( app: App, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration13.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration14.kt similarity index 95% rename from app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration13.kt rename to app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration14.kt index 92fa86ec..1d76859b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration13.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/config/migration/ConfigMigration14.kt @@ -19,7 +19,7 @@ import pl.szczodrzynski.edziennik.data.enums.Theme.TEAL import pl.szczodrzynski.edziennik.data.enums.Theme.Type.M3 import pl.szczodrzynski.edziennik.ext.toJsonArray -class ConfigMigration13 : BaseMigration() { +class ConfigMigration14 : BaseMigration() { override fun migrate(config: Config) = config.apply { get("theme")?.toIntOrNull()?.let { @@ -65,7 +65,7 @@ class ConfigMigration13 : BaseMigration() { try { ui.miniMenuButtons = it.map { id -> NavTarget.getById(id.asInt) }.toSet() } catch (e: Exception) { - ui.miniMenuButtons = NavTarget.getDefaultConfig() + ui.miniMenuButtons = ui.miniMenuButtons } } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/AppDb.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/AppDb.kt index e50e5fc2..293cf609 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/AppDb.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/AppDb.kt @@ -29,7 +29,7 @@ import pl.szczodrzynski.edziennik.data.db.migration.* FeedbackMessage::class, Message::class, MessageRecipient::class, - DebugLog::class, + LogEntry::class, EndpointTimer::class, LessonRange::class, Notification::class, @@ -42,7 +42,7 @@ import pl.szczodrzynski.edziennik.data.db.migration.* TimetableManual::class, Note::class, Metadata::class -], version = 100) +], version = 101) @TypeConverters( ConverterTime::class, ConverterDate::class, @@ -71,7 +71,7 @@ abstract class AppDb : RoomDatabase() { abstract fun feedbackMessageDao(): FeedbackMessageDao abstract fun messageDao(): MessageDao abstract fun messageRecipientDao(): MessageRecipientDao - abstract fun debugLogDao(): DebugLogDao + abstract fun logDao(): LogDao abstract fun endpointTimerDao(): EndpointTimerDao abstract fun lessonRangeDao(): LessonRangeDao abstract fun notificationDao(): NotificationDao @@ -187,6 +187,7 @@ abstract class AppDb : RoomDatabase() { Migration98(), Migration99(), Migration100(), + Migration101(), ).allowMainThreadQueries().build() } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/DebugLogDao.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/DebugLogDao.java deleted file mode 100644 index 8da52a2a..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/DebugLogDao.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Kacper Ziubryniewicz 2020-1-6 - */ - -package pl.szczodrzynski.edziennik.data.db.dao; - -import androidx.room.Dao; -import androidx.room.Insert; - -import pl.szczodrzynski.edziennik.data.db.entity.DebugLog; - -@Dao -public interface DebugLogDao { - @Insert - void add(DebugLog debugLog); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/LogDao.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/LogDao.kt new file mode 100644 index 00000000..8e47cc62 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/LogDao.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2024-7-1. + */ + +package pl.szczodrzynski.edziennik.data.db.dao + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import pl.szczodrzynski.edziennik.data.db.entity.LogEntry + +@Dao +interface LogDao { + + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun add(entry: LogEntry) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun addAll(list: List) + + @Query("DELETE FROM logs") + suspend fun clear() + + @Query("DELETE FROM logs WHERE timestamp < :timestamp") + suspend fun clearBefore(timestamp: Long) +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/DebugLog.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/DebugLog.java deleted file mode 100644 index 6fff3cce..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/DebugLog.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Kacper Ziubryniewicz 2020-1-6 - */ - -package pl.szczodrzynski.edziennik.data.db.entity; - -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -import static pl.szczodrzynski.edziennik.utils.Utils.d; - -@Entity(tableName = "debugLogs") -public class DebugLog { - @PrimaryKey(autoGenerate = true) - public int id; - - public String text; - - public DebugLog(String text) { - d("DebugLog", text); - this.text = text; - } -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/LogEntry.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/LogEntry.kt new file mode 100644 index 00000000..a8a06338 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/LogEntry.kt @@ -0,0 +1,20 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2024-7-1. + */ + +package pl.szczodrzynski.edziennik.data.db.entity + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = "logs") +data class LogEntry( + @PrimaryKey(autoGenerate = true) + val id: Int = 0, + @ColumnInfo(index = true) + val timestamp: Long, + val priority: Int, + val tag: String?, + val message: String, +) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/Notification.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/Notification.kt index 4e001a0d..22fddc72 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/Notification.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/Notification.kt @@ -18,6 +18,7 @@ import pl.szczodrzynski.edziennik.data.enums.NotificationType import pl.szczodrzynski.edziennik.ext.pendingIntentFlag import pl.szczodrzynski.edziennik.ext.putExtras import pl.szczodrzynski.edziennik.data.enums.NavTarget +import timber.log.Timber @Entity(tableName = "notifications") data class Notification( @@ -74,8 +75,8 @@ data class Notification( intent.putExtra(key, primitive.asString) } } - } catch (e: NullPointerException) { - e.printStackTrace() + } catch (e: Exception) { + Timber.e(e) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/migration/Migration101.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/migration/Migration101.kt new file mode 100644 index 00000000..e0daafca --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/migration/Migration101.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2022-10-25. + */ + +package pl.szczodrzynski.edziennik.data.db.migration + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +class Migration101 : Migration(100, 101) { + + override fun migrate(db: SupportSQLiteDatabase) { + // remove old debugLogs table + db.execSQL("DROP TABLE debugLogs") + // add new logs table + db.execSQL( + "CREATE TABLE logs (" + + "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + + "timestamp INTEGER NOT NULL, " + + "priority INTEGER NOT NULL, " + + "tag TEXT, " + + "message TEXT NOT NULL)" + ) + // create index for logs table + db.execSQL("CREATE INDEX IF NOT EXISTS index_logs_timestamp ON logs (timestamp)") + } +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ext/ProfileExtensions.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ext/ProfileExtensions.kt index 9bb70195..715ddb24 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ext/ProfileExtensions.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ext/ProfileExtensions.kt @@ -21,6 +21,7 @@ import pl.szczodrzynski.edziennik.utils.ProfileImageHolder import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.navlib.ImageHolder import pl.szczodrzynski.navlib.getDrawableFromRes +import timber.log.Timber // TODO refactor Data* fields and make the receiver non-nullable operator fun Profile?.set(key: String, value: JsonElement) = this?.studentData?.add(key, value) @@ -101,7 +102,7 @@ fun Profile.getDrawable(context: Context): Drawable { RoundedBitmapDrawableFactory.create(context.resources, image ?: "") } } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/DayDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/DayDialog.kt index cacd51a1..4d239003 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/DayDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/DayDialog.kt @@ -28,7 +28,7 @@ import pl.szczodrzynski.edziennik.ui.event.EventListAdapter import pl.szczodrzynski.edziennik.ui.event.EventManualDialog import pl.szczodrzynski.edziennik.ui.notes.setupNotesButton import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/event/AgendaEventRenderer.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/event/AgendaEventRenderer.kt index a51cfe43..722ca670 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/event/AgendaEventRenderer.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/event/AgendaEventRenderer.kt @@ -20,7 +20,7 @@ import pl.szczodrzynski.edziennik.ext.join import pl.szczodrzynski.edziennik.ext.resolveAttr import pl.szczodrzynski.edziennik.ext.setTintColor import pl.szczodrzynski.edziennik.utils.Colors -import pl.szczodrzynski.edziennik.utils.managers.EventManager +import pl.szczodrzynski.edziennik.core.manager.EventManager class AgendaEventRenderer( val manager: EventManager, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/lessonchanges/LessonChangesAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/lessonchanges/LessonChangesAdapter.kt index 38a5aa34..05f1ec44 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/lessonchanges/LessonChangesAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/lessonchanges/LessonChangesAdapter.kt @@ -5,8 +5,6 @@ package pl.szczodrzynski.edziennik.ui.agenda.lessonchanges import android.content.Context -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.view.updateLayoutParams @@ -16,7 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Lesson import pl.szczodrzynski.edziennik.data.db.full.LessonFull import pl.szczodrzynski.edziennik.databinding.TimetableLessonBinding import pl.szczodrzynski.edziennik.ext.* -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager class LessonChangesAdapter( val context: Context, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceDetailsDialog.kt index b0c67241..7ab4901a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceDetailsDialog.kt @@ -16,7 +16,7 @@ import pl.szczodrzynski.edziennik.ext.setTintColor import pl.szczodrzynski.edziennik.ui.dialogs.base.BindingDialog import pl.szczodrzynski.edziennik.ui.notes.setupNotesButton import pl.szczodrzynski.edziennik.utils.BetterLink -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager class AttendanceDetailsDialog( activity: AppCompatActivity, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceView.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceView.kt index 02be63ad..d7acd3e4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceView.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceView.kt @@ -19,7 +19,7 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.db.entity.Attendance import pl.szczodrzynski.edziennik.ext.dp import pl.szczodrzynski.edziennik.ext.setTintColor -import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager +import pl.szczodrzynski.edziennik.core.manager.AttendanceManager class AttendanceView : AppCompatTextView { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/viewholder/AttendanceViewHolder.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/viewholder/AttendanceViewHolder.kt index ab6a0b92..247bac82 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/viewholder/AttendanceViewHolder.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/viewholder/AttendanceViewHolder.kt @@ -19,7 +19,7 @@ import pl.szczodrzynski.edziennik.ui.attendance.models.AttendanceDayRange import pl.szczodrzynski.edziennik.ui.attendance.models.AttendanceMonth import pl.szczodrzynski.edziennik.ui.grades.models.ExpandableItemModel import pl.szczodrzynski.edziennik.ui.grades.viewholder.BindableViewHolder -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Week class AttendanceViewHolder( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/DebugFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/DebugFragment.java index 66d46762..bcb1f553 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/DebugFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/DebugFragment.java @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import pl.szczodrzynski.edziennik.App; import pl.szczodrzynski.edziennik.R; import pl.szczodrzynski.edziennik.utils.Themes; +import timber.log.Timber; public class DebugFragment extends Fragment { App app; @@ -193,7 +194,7 @@ public class DebugFragment extends Fragment { temp = target; } } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); return Log.getStackTraceString(e); } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt index 2c96aff8..909c9eed 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPageFragment.kt @@ -69,6 +69,7 @@ class LabPageFragment : LazyFragment(), CoroutineScope { b.resetEventTypes.isVisible = false b.unarchive.isVisible = false b.profile.isVisible = false + b.clearConfigProfile.isVisible = false } b.last10unseen.onClick { @@ -165,8 +166,15 @@ class LabPageFragment : LazyFragment(), CoroutineScope { } } + b.clearConfigProfile.onClick { + app.db.configDao().clear(app.profileId) + } + b.clearConfigGlobal.onClick { + app.db.configDao().clear(-1) + } b.rebuildConfig.onClick { App.config = Config(app) + App.config.migrate() } val profiles = app.db.profileDao().allNow diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPlaygroundFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPlaygroundFragment.kt index 76df7996..4b4beb52 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPlaygroundFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/debug/LabPlaygroundFragment.kt @@ -18,7 +18,7 @@ import pl.szczodrzynski.edziennik.ext.asColoredSpannable import pl.szczodrzynski.edziennik.ext.concat import pl.szczodrzynski.edziennik.ext.resolveAttr import pl.szczodrzynski.edziennik.ui.base.lazypager.LazyFragment -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber import kotlin.coroutines.CoroutineContext class LabPlaygroundFragment : LazyFragment(), CoroutineScope { @@ -50,7 +50,7 @@ class LabPlaygroundFragment : LazyFragment(), CoroutineScope { override fun onPageCreated(): Boolean { - d(TAG, "textColorSecondary: ${android.R.attr.textColorSecondary.resolveAttr(activity)}") + Timber.d("textColorSecondary: ${android.R.attr.textColorSecondary.resolveAttr(activity)}") b.spanTest1.text = listOf( "Text:", "android:textColorSecondary spannable (activity)".asColoredSpannable( android.R.attr.textColorSecondary.resolveAttr(activity) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/StyledTextDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/StyledTextDialog.kt index e1be0d99..f8e720fb 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/StyledTextDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/StyledTextDialog.kt @@ -15,9 +15,8 @@ import pl.szczodrzynski.edziennik.databinding.StyledTextDialogBinding import pl.szczodrzynski.edziennik.ext.isNightMode import pl.szczodrzynski.edziennik.ui.dialogs.base.BindingDialog import pl.szczodrzynski.edziennik.utils.DefaultTextStyles -import pl.szczodrzynski.edziennik.utils.Themes -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.SIMPLE -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfig +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.SIMPLE +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfig class StyledTextDialog( activity: AppCompatActivity, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/GradesConfigDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/GradesConfigDialog.kt index b1c0c86f..2d946083 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/GradesConfigDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/GradesConfigDialog.kt @@ -17,15 +17,15 @@ import pl.szczodrzynski.edziennik.ext.onChange import pl.szczodrzynski.edziennik.ext.onClick import pl.szczodrzynski.edziennik.ext.setOnSelectedListener import pl.szczodrzynski.edziennik.ui.dialogs.base.ConfigDialog -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_DEFAULT -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_WEIGHTED -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.ORDER_BY_DATE_DESC -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.ORDER_BY_SUBJECT_ASC -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_AVG_2_AVG -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_AVG_2_SEM -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_SEM_2_AVG -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_SEM_2_SEM -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_ALL_GRADES +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.COLOR_MODE_DEFAULT +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.COLOR_MODE_WEIGHTED +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.ORDER_BY_DATE_DESC +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.ORDER_BY_SUBJECT_ASC +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_AVG_2_AVG +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_AVG_2_SEM +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_SEM_2_AVG +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_SEM_2_SEM +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_ALL_GRADES class GradesConfigDialog( activity: AppCompatActivity, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/sync/UpdateProgressDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/sync/UpdateProgressDialog.kt index 68bd8d54..cfd1ba79 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/sync/UpdateProgressDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/sync/UpdateProgressDialog.kt @@ -18,7 +18,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.response.Update import pl.szczodrzynski.edziennik.databinding.UpdateProgressDialogBinding import pl.szczodrzynski.edziennik.ext.getInt import pl.szczodrzynski.edziennik.ext.startCoroutineTimer -import pl.szczodrzynski.edziennik.sync.UpdateStateEvent +import pl.szczodrzynski.edziennik.core.work.UpdateStateEvent import pl.szczodrzynski.edziennik.ui.dialogs.base.BindingDialog import pl.szczodrzynski.edziennik.utils.Utils diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventManualDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventManualDialog.kt index 22260ad3..a9a054c7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventManualDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventManualDialog.kt @@ -20,7 +20,6 @@ import kotlinx.coroutines.withContext import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode -import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.data.config.AppData import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask @@ -50,8 +49,8 @@ import pl.szczodrzynski.edziennik.ui.dialogs.settings.RegistrationConfigDialog import pl.szczodrzynski.edziennik.ui.views.TimeDropdown.Companion.DISPLAY_LESSONS import pl.szczodrzynski.edziennik.utils.Anim import pl.szczodrzynski.edziennik.utils.html.BetterHtml -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.SIMPLE -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfigBase +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.SIMPLE +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfigBase import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/feedback/FeedbackFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/feedback/FeedbackFragment.kt index 3004b35d..793aedb1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/feedback/FeedbackFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/feedback/FeedbackFragment.kt @@ -33,6 +33,7 @@ import pl.szczodrzynski.edziennik.ext.crc16 import pl.szczodrzynski.edziennik.ext.onClick import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.Utils.openUrl +import timber.log.Timber import java.util.* import kotlin.collections.set import kotlin.coroutines.CoroutineContext @@ -212,7 +213,7 @@ class FeedbackFragment : Fragment(), CoroutineScope { else Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888).also { bmp -> launch { - Log.d(TAG, "Created image for $userName") + Timber.d("Created image for " + userName) val request = ImageRequest.Builder(activity) .data(image) .target { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeDetailsDialog.kt index d1ac9915..c474b5b4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeDetailsDialog.kt @@ -18,7 +18,7 @@ import pl.szczodrzynski.edziennik.ui.dialogs.settings.GradesConfigDialog import pl.szczodrzynski.edziennik.ui.notes.setupNotesButton import pl.szczodrzynski.edziennik.utils.BetterLink import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager class GradeDetailsDialog( activity: AppCompatActivity, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeView.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeView.kt index 04deebd7..be57e72f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeView.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradeView.kt @@ -26,7 +26,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPO import pl.szczodrzynski.edziennik.ext.dp import pl.szczodrzynski.edziennik.ext.resolveAttr import pl.szczodrzynski.edziennik.ext.setTintColor -import pl.szczodrzynski.edziennik.utils.managers.GradesManager +import pl.szczodrzynski.edziennik.core.manager.GradesManager class GradeView : AppCompatTextView { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradesListFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradesListFragment.kt index d95bc477..a4ceb6d9 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradesListFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/GradesListFragment.kt @@ -28,7 +28,7 @@ import pl.szczodrzynski.edziennik.ui.grades.models.GradesAverages import pl.szczodrzynski.edziennik.ui.grades.models.GradesSemester import pl.szczodrzynski.edziennik.ui.grades.models.GradesStats import pl.szczodrzynski.edziennik.ui.grades.models.GradesSubject -import pl.szczodrzynski.edziennik.utils.managers.GradesManager +import pl.szczodrzynski.edziennik.core.manager.GradesManager import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem import kotlin.coroutines.CoroutineContext diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/editor/GradesEditorFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/editor/GradesEditorFragment.kt index 154a42bf..c2ec00d4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/editor/GradesEditorFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/editor/GradesEditorFragment.kt @@ -22,10 +22,11 @@ import pl.szczodrzynski.edziennik.ext.getInt import pl.szczodrzynski.edziennik.ext.getLong import pl.szczodrzynski.edziennik.ext.input import pl.szczodrzynski.edziennik.utils.Colors -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_AVG_2_AVG -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_AVG_2_SEM -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_1_SEM_2_AVG -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_ALL_GRADES +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_AVG_2_AVG +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_AVG_2_SEM +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_1_SEM_2_AVG +import pl.szczodrzynski.edziennik.core.manager.GradesManager.Companion.YEAR_ALL_GRADES +import timber.log.Timber import java.text.DecimalFormat import java.util.* import kotlin.math.floor @@ -344,7 +345,7 @@ class GradesEditorFragment : Fragment() { editorGrade.weight = input.toFloat() callback() } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) } true } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/viewholder/GradeViewHolder.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/viewholder/GradeViewHolder.kt index 85684886..4d552722 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/viewholder/GradeViewHolder.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/grades/viewholder/GradeViewHolder.kt @@ -15,7 +15,7 @@ import pl.szczodrzynski.edziennik.data.db.full.GradeFull import pl.szczodrzynski.edziennik.databinding.GradesItemGradeBinding import pl.szczodrzynski.edziennik.ui.grades.GradesAdapter import pl.szczodrzynski.edziennik.ui.grades.models.GradesSubject -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Date class GradeViewHolder( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeDebugCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeDebugCard.kt index 6947b74b..c148b40f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeDebugCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeDebugCard.kt @@ -15,7 +15,6 @@ import androidx.core.view.plusAssign import androidx.core.view.setMargins import androidx.work.WorkManager import com.chuckerteam.chucker.api.Chucker -import com.hypertrack.hyperlog.HyperLog import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -85,19 +84,6 @@ class HomeDebugCard( app.startActivity(Chucker.getLaunchIntent(activity, 1)); } - b.getLogs.onClick { - val logs = HyperLog.getDeviceLogsInFile(activity, true) - val intent = Intent(Intent.ACTION_SEND) - - if (logs.exists()) { - intent.type = "text/plain" - intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + logs.absolutePath)) - intent.putExtra(Intent.EXTRA_SUBJECT, "Share debug logs") - intent.putExtra(Intent.EXTRA_TEXT, "Share debug logs") - app.startActivity(Intent.createChooser(intent, "Share debug logs")) - } - } - b.refreshWidget.onClick { for (widgetType in 0..2) { val theClass = when (widgetType) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt index d3898e19..21254c3c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginChooserFragment.kt @@ -34,7 +34,7 @@ import pl.szczodrzynski.edziennik.ui.feedback.FeedbackActivity import pl.szczodrzynski.edziennik.utils.BetterLinkMovementMethod import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration import pl.szczodrzynski.edziennik.utils.html.BetterHtml -import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager.Error.Type +import pl.szczodrzynski.edziennik.core.manager.AvailabilityManager.Error.Type import pl.szczodrzynski.edziennik.utils.models.Date import kotlin.coroutines.CoroutineContext diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginProgressFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginProgressFragment.kt index dea6b426..59b330ad 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginProgressFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/LoginProgressFragment.kt @@ -32,7 +32,7 @@ import pl.szczodrzynski.edziennik.data.enums.LoginType import pl.szczodrzynski.edziennik.databinding.LoginProgressFragmentBinding import pl.szczodrzynski.edziennik.ext.getEnum import pl.szczodrzynski.edziennik.ext.joinNotNullStrings -import pl.szczodrzynski.edziennik.utils.managers.UserActionManager +import pl.szczodrzynski.edziennik.core.manager.UserActionManager import kotlin.coroutines.CoroutineContext import kotlin.math.max diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/oauth/OAuthLoginActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/oauth/OAuthLoginActivity.kt index c80c3d82..4831371c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/oauth/OAuthLoginActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/login/oauth/OAuthLoginActivity.kt @@ -14,7 +14,7 @@ import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity import org.greenrobot.eventbus.EventBus import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.utils.Utils.d +import timber.log.Timber class OAuthLoginActivity : AppCompatActivity() { companion object { @@ -35,7 +35,7 @@ class OAuthLoginActivity : AppCompatActivity() { val webView = WebView(this) webView.webViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { - d(TAG, "Navigating to $url") + Timber.d("Navigating to $url") if (url.startsWith(redirectUrl)) { isSuccessful = true EventBus.getDefault().post(OAuthLoginResult( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/compose/MessagesComposeFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/compose/MessagesComposeFragment.kt index 3052219f..d6726578 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/compose/MessagesComposeFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/compose/MessagesComposeFragment.kt @@ -6,9 +6,6 @@ package pl.szczodrzynski.edziennik.ui.messages.compose import android.annotation.SuppressLint import android.os.Bundle -import android.text.* -import android.text.Spanned.* -import android.text.style.* import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -40,12 +37,10 @@ import pl.szczodrzynski.edziennik.data.enums.NavTarget import pl.szczodrzynski.edziennik.ui.dialogs.settings.MessagesConfigDialog import pl.szczodrzynski.edziennik.ui.messages.list.MessagesFragment import pl.szczodrzynski.edziennik.utils.DefaultTextStyles -import pl.szczodrzynski.edziennik.utils.Themes -import pl.szczodrzynski.edziennik.utils.managers.MessageManager.UIConfig -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.COMPATIBLE -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode.ORIGINAL -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfig -import pl.szczodrzynski.edziennik.utils.span.* +import pl.szczodrzynski.edziennik.core.manager.MessageManager.UIConfig +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.COMPATIBLE +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode.ORIGINAL +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfig import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem import kotlin.coroutines.CoroutineContext diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/list/MessageViewHolder.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/list/MessageViewHolder.kt index 1c3d6aeb..baa6c723 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/list/MessageViewHolder.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/messages/list/MessageViewHolder.kt @@ -19,7 +19,7 @@ import pl.szczodrzynski.edziennik.ext.onClick import pl.szczodrzynski.edziennik.ext.resolveAttr import pl.szczodrzynski.edziennik.ui.grades.viewholder.BindableViewHolder import pl.szczodrzynski.edziennik.ui.messages.MessagesUtils -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.navlib.getColorFromAttr diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/notes/NoteEditorDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/notes/NoteEditorDialog.kt index 8114a6db..b26a6158 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/notes/NoteEditorDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/notes/NoteEditorDialog.kt @@ -24,8 +24,8 @@ import pl.szczodrzynski.edziennik.ext.resolveString import pl.szczodrzynski.edziennik.ui.dialogs.base.BindingDialog import pl.szczodrzynski.edziennik.ui.dialogs.settings.RegistrationConfigDialog import pl.szczodrzynski.edziennik.utils.TextInputDropDown -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.HtmlMode -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfigBase +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.HtmlMode +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfigBase import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/notifications/NotificationsListFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/notifications/NotificationsListFragment.kt index f2a98f11..373ea7de 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/notifications/NotificationsListFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/notifications/NotificationsListFragment.kt @@ -27,6 +27,7 @@ import pl.szczodrzynski.edziennik.ext.startCoroutineTimer import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem +import timber.log.Timber import kotlin.coroutines.CoroutineContext class NotificationsListFragment : Fragment(), CoroutineScope { @@ -67,7 +68,7 @@ class NotificationsListFragment : Fragment(), CoroutineScope { val intent = Intent("android.intent.action.MAIN") notification.fillIntent(intent) - Utils.d(TAG, "notification with item " + notification.navTarget + " extras " + if (intent.extras == null) "null" else intent.extras!!.toString()) + Timber.d("notification with item " + notification.navTarget + " extras " + if (intent.extras == null) "null" else intent.extras!!.toString()) if (notification.profileId != null && notification.profileId != -1 && notification.profileId != app.profile.id && context is Activity) { Toast.makeText(app, app.getString(R.string.toast_changing_profile), Toast.LENGTH_LONG).show() } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/SettingsLicenseActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/SettingsLicenseActivity.kt index 7ec8c3f7..69d834d0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/SettingsLicenseActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/SettingsLicenseActivity.kt @@ -276,14 +276,6 @@ class SettingsLicenseActivity : MaterialAboutActivity() { "https://github.com/heinrichreimer/material-intro" ), - license( - "HyperLog Android", - "2018", - "HyperTrack", - OpenSourceLicense.MIT, - "https://github.com/hypertrack/hyperlog-android" - ), - license( "Color Picker", "2016 Jared Rummler,", diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsSyncCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsSyncCard.kt index 701a295e..dca0de98 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsSyncCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsSyncCard.kt @@ -12,12 +12,11 @@ import android.os.Build.VERSION_CODES import android.provider.Settings import com.danielstone.materialaboutlibrary.model.MaterialAboutCard import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial -import pl.szczodrzynski.edziennik.MainActivity import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.ext.after import pl.szczodrzynski.edziennik.ext.getSyncInterval -import pl.szczodrzynski.edziennik.sync.SyncWorker -import pl.szczodrzynski.edziennik.sync.UpdateWorker +import pl.szczodrzynski.edziennik.core.work.SyncWorker +import pl.szczodrzynski.edziennik.core.work.UpdateWorker import pl.szczodrzynski.edziennik.data.enums.NavTarget import pl.szczodrzynski.edziennik.ui.dialogs.settings.NotificationFilterDialog import pl.szczodrzynski.edziennik.ui.dialogs.settings.QuietHoursConfigDialog @@ -173,7 +172,7 @@ class SettingsSyncCard(util: SettingsUtil) : SettingsCard(util) { subText = R.string.settings_sync_notifications_settings_subtext, icon = CommunityMaterial.Icon.cmd_cog_outline ) { - val channel = app.notificationChannelsManager.data.key + val channel = app.notificationManager.data.key val intent = Intent().apply { when { SDK_INT >= VERSION_CODES.O -> { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/GenerateBlockTimetableDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/GenerateBlockTimetableDialog.kt index 29d8d935..22ce5dc4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/GenerateBlockTimetableDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/GenerateBlockTimetableDialog.kt @@ -38,6 +38,7 @@ import pl.szczodrzynski.edziennik.ext.* import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week +import timber.log.Timber import java.io.File import kotlin.coroutines.CoroutineContext import kotlin.math.roundToInt @@ -394,7 +395,7 @@ class GenerateBlockTimetableDialog( } uri } catch (e: Exception) { - Log.e("SAVE_IMAGE", e.message, e) + Timber.e(e) return@withContext null } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/LessonDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/LessonDetailsDialog.kt index 31d738dd..bedcd750 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/LessonDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/LessonDetailsDialog.kt @@ -29,7 +29,7 @@ import pl.szczodrzynski.edziennik.ui.event.EventManualDialog import pl.szczodrzynski.edziennik.ui.notes.setupNotesButton import pl.szczodrzynski.edziennik.utils.BetterLink import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Week diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt index 734710e9..8420c003 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt @@ -10,7 +10,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.FrameLayout -import android.widget.LinearLayout import android.widget.TextView import androidx.asynclayoutinflater.view.AsyncLayoutInflater import androidx.core.graphics.ColorUtils @@ -18,7 +17,6 @@ import androidx.core.view.isVisible import androidx.core.view.marginTop import androidx.core.view.setPadding import androidx.core.view.updateLayoutParams -import androidx.core.view.updateMargins import com.linkedin.android.tachyon.DayView import com.linkedin.android.tachyon.DayViewConfig import com.mikepenz.iconics.IconicsDrawable @@ -61,7 +59,7 @@ import pl.szczodrzynski.edziennik.ui.base.lazypager.LazyFragment import pl.szczodrzynski.edziennik.ui.timetable.TimetableFragment.Companion.DEFAULT_END_HOUR import pl.szczodrzynski.edziennik.ui.timetable.TimetableFragment.Companion.DEFAULT_START_HOUR import pl.szczodrzynski.edziennik.utils.Colors -import pl.szczodrzynski.edziennik.utils.managers.NoteManager +import pl.szczodrzynski.edziennik.core.manager.NoteManager import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/AttachmentsView.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/AttachmentsView.kt index 81240d62..03f52b12 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/AttachmentsView.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/AttachmentsView.kt @@ -23,6 +23,7 @@ import pl.szczodrzynski.edziennik.ext.get import pl.szczodrzynski.edziennik.ext.isNotNullNorEmpty import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration import pl.szczodrzynski.edziennik.utils.Utils +import timber.log.Timber import java.io.File class AttachmentsView @JvmOverloads constructor( @@ -121,7 +122,7 @@ class AttachmentsView @JvmOverloads constructor( } else false } catch (e: Exception) { - e.printStackTrace() + Timber.e(e) false } } else false diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/WidgetConfigActivity.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/WidgetConfigActivity.java index 4909c196..6d2d0b5b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/WidgetConfigActivity.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/WidgetConfigActivity.java @@ -35,6 +35,7 @@ import pl.szczodrzynski.edziennik.databinding.WidgetProfileDialogItemBinding; import pl.szczodrzynski.edziennik.ui.widgets.luckynumber.WidgetLuckyNumberProvider; import pl.szczodrzynski.edziennik.ui.widgets.notifications.WidgetNotificationsProvider; import pl.szczodrzynski.edziennik.ui.widgets.timetable.WidgetTimetableProvider; +import timber.log.Timber; public class WidgetConfigActivity extends Activity { @@ -217,7 +218,7 @@ public class WidgetConfigActivity extends Activity { b.wallpaper.setImageDrawable(wallpaperManager.getDrawable()); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); } b.theme.check(R.id.themeLight); diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/notifications/WidgetNotificationsProvider.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/notifications/WidgetNotificationsProvider.kt index c66ca92c..053bfc0d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/notifications/WidgetNotificationsProvider.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/notifications/WidgetNotificationsProvider.kt @@ -22,10 +22,9 @@ import pl.szczodrzynski.edziennik.MainActivity import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.ext.Bundle import pl.szczodrzynski.edziennik.ext.getJsonObject -import pl.szczodrzynski.edziennik.ext.pendingIntentFlag import pl.szczodrzynski.edziennik.ext.pendingIntentMutable import pl.szczodrzynski.edziennik.ext.putExtras -import pl.szczodrzynski.edziennik.receivers.SzkolnyReceiver +import pl.szczodrzynski.edziennik.core.receiver.SzkolnyReceiver import pl.szczodrzynski.edziennik.data.enums.NavTarget import pl.szczodrzynski.edziennik.ui.widgets.WidgetConfig diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java index 960daef7..37b7d37d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableFactory.java @@ -39,6 +39,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date; import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel; import pl.szczodrzynski.edziennik.utils.models.Time; import pl.szczodrzynski.edziennik.utils.models.Week; +import timber.log.Timber; public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFactory { @@ -53,7 +54,7 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac this.context = context; this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0); // executed only ONCE - Log.d(TAG, "appWidgetId: "+appWidgetId); + Timber.d("appWidgetId: %s", appWidgetId); //App app = (App) context.getApplicationContext(); //this.lessons = widgetsLessons.get(appWidgetId); /*this.lessons = new ArrayList<>(); @@ -69,7 +70,7 @@ public class WidgetTimetableFactory implements RemoteViewsService.RemoteViewsFac @Override public void onDataSetChanged() { // executed EVERY TIME - Log.d(TAG, "onDataSetChanged for appWidgetId: "+appWidgetId); + Timber.d("onDataSetChanged for appWidgetId: %s", appWidgetId); lessons = WidgetTimetableProvider.Companion.getTimetables() == null ? null : WidgetTimetableProvider.Companion.getTimetables().get(appWidgetId); } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt index fff58cad..799e623c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt @@ -43,6 +43,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Week +import timber.log.Timber import java.lang.reflect.InvocationTargetException @@ -168,13 +169,13 @@ class WidgetTimetableProvider : AppWidgetProvider() { } } } catch (e: ClassNotFoundException) { - e.printStackTrace() + Timber.e(e) } catch (e: InvocationTargetException) { - e.printStackTrace() + Timber.e(e) } catch (e: IllegalAccessException) { - e.printStackTrace() + Timber.e(e) } catch (e: IllegalArgumentException) { - e.printStackTrace() + Timber.e(e) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/DebugLogFormat.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/DebugLogFormat.kt deleted file mode 100644 index fbcd6498..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/DebugLogFormat.kt +++ /dev/null @@ -1,10 +0,0 @@ -package pl.szczodrzynski.edziennik.utils - -import android.content.Context -import com.hypertrack.hyperlog.LogFormat - -class DebugLogFormat(context: Context) : LogFormat(context) { - override fun getFormattedLogMessage(logLevelName: String?, tag: String?, message: String?, timeStamp: String?, senderName: String?, osVersion: String?, deviceUUID: String?): String { - return "${timeStamp?.replace("[TZ]".toRegex(), " ")}D/$tag: $message" - } -} \ No newline at end of file diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/DefaultTextStyles.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/DefaultTextStyles.kt index 7f1fa02a..a5cd9c23 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/DefaultTextStyles.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/DefaultTextStyles.kt @@ -8,7 +8,7 @@ import android.text.style.StrikethroughSpan import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.databinding.StyledTextButtonsBinding -import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager.StylingConfig +import pl.szczodrzynski.edziennik.core.manager.TextStylingManager.StylingConfig import pl.szczodrzynski.edziennik.utils.span.* object DefaultTextStyles { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/PermissionChecker.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/PermissionChecker.java index 3e4c43e6..398fc0e5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/PermissionChecker.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/PermissionChecker.java @@ -16,6 +16,8 @@ import android.view.accessibility.AccessibilityManager; import java.util.List; +import timber.log.Timber; + public class PermissionChecker { private Context mContext; @@ -53,8 +55,8 @@ public class PermissionChecker { try { mode = appOps.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, android.os.Process.myUid(), mContext.getPackageName()); - } catch (java.lang.IllegalArgumentException e) { - e.printStackTrace(); + } catch (Exception e) { + Timber.e(e); } boolean granted = false; if (mode == AppOpsManager.MODE_DEFAULT) { @@ -165,4 +167,4 @@ public class PermissionChecker { return null; } -} \ No newline at end of file +} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/Utils.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/Utils.java index f039952d..010e8fc9 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/Utils.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/Utils.java @@ -26,8 +26,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.FileProvider; -import com.hypertrack.hyperlog.HyperLog; - import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -70,6 +68,7 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import pl.szczodrzynski.edziennik.App; +import timber.log.Timber; public class Utils { private static final String TAG = "Utils"; @@ -105,21 +104,6 @@ public class Utils { return false;*/ } - public static List debugLog = new ArrayList<>(); - - public static void d(String TAG, String message) { - if (App.Companion.getDevMode()) { - HyperLog.d("Szkolny/"+TAG, message); - //debugLog.add(TAG+": "+message); - } - } - public static void c(String TAG, String message) { - /*if (App.devMode) { - Log.d(TAG, "// " + message); - ///debugLog.add(TAG+": // "+message); - }*/ - } - /** * Returns the first set (high) bit position, from right to left. * @param n the number @@ -247,7 +231,7 @@ public class Utils { cursor.close(); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); } return result; } @@ -258,7 +242,7 @@ public class Utils { return Integer.parseInt(s); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); return defaultValue; } } @@ -336,8 +320,8 @@ public class Utils { PackageInfo packageInfo; packageInfo = context.getPackageManager().getPackageInfo(packageName, 0); if (packageInfo != null) { - Log.d(TAG, packageInfo.toString()); - Log.d(TAG, packageInfo.packageName+" "+packageInfo.versionName+" "+packageInfo.versionCode); + Timber.d(packageInfo.toString()); + Timber.d("%s %s %d", packageInfo.packageName, packageInfo.versionName, packageInfo.versionCode); return packageInfo.versionName; } else { @@ -345,7 +329,7 @@ public class Utils { } } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); return null; } } @@ -471,10 +455,8 @@ public class Utils { sha_HMAC.init(secret_key); return Base64UrlSafe(sha_HMAC.doFinal(message.getBytes())); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); + } catch (NoSuchAlgorithmException | InvalidKeyException e) { + Timber.e(e); } return null; } @@ -487,10 +469,8 @@ public class Utils { sha_HMAC.init(secret_key); return bytesToHex(sha_HMAC.doFinal(message.getBytes())); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); + } catch (NoSuchAlgorithmException | InvalidKeyException e) { + Timber.e(e); } return null; } @@ -504,7 +484,7 @@ public class Utils { MessageDigest md = java.security.MessageDigest.getInstance("MD5"); return Base64UrlSafe(md.digest(message.getBytes())); }catch (NoSuchAlgorithmException e) { - e.printStackTrace(); + Timber.e(e); } return null; } @@ -626,7 +606,7 @@ public class Utils { } out.close(); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); return false; } return true; diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NotificationChannelsManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NotificationChannelsManager.kt deleted file mode 100644 index 5989a35b..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NotificationChannelsManager.kt +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) Kuba Szczodrzyński 2020-2-15. - */ - -package pl.szczodrzynski.edziennik.utils.managers - -import android.app.NotificationChannel -import android.app.NotificationManager -import android.content.Context -import android.os.Build -import androidx.core.app.NotificationCompat.* -import androidx.core.app.NotificationManagerCompat.* -import pl.szczodrzynski.edziennik.R - -class NotificationChannelsManager(val c: Context) { - data class Channel( - val id: Int, - val key: String, - val name: String, - val description: String, - val importance: Int, - val priority: Int, - val quiet: Boolean = false, - val lightColor: Int? = null - ) - - fun registerAllChannels() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) - return - val manager = c.getSystemService(NotificationManager::class.java) - - val registered = manager.notificationChannels.map { it.id } - val all = all.map { it.key } - - val toRegister = all - registered - val toDelete = registered - all - - for (key in toRegister) { - val channel = this.all.firstOrNull { it.key == key } ?: continue - manager.createNotificationChannel(NotificationChannel(key, channel.name, channel.importance).apply { - description = channel.description - if (channel.quiet) { - enableVibration(false) - setSound(null, null) - } - channel.lightColor?.let { - enableLights(true) - lightColor = it - } - }) - } - - for (key in toDelete) { - if (key.contains("chucker")) - continue - manager.deleteNotificationChannel(key) - } - } - - val sync by lazy { - Channel( - 1, - "pl.szczodrzynski.edziennik.SYNC", - c.getString(R.string.notification_channel_get_data_name), - c.getString(R.string.notification_channel_get_data_desc), - IMPORTANCE_MIN, - PRIORITY_MIN, - quiet = true - ) - } - - val data by lazy { - Channel( - 50, - "pl.szczodrzynski.edziennik.DATA", - c.getString(R.string.notification_channel_notifications_name), - c.getString(R.string.notification_channel_notifications_desc), - IMPORTANCE_HIGH, - PRIORITY_MAX, - lightColor = 0xff2196f3.toInt() - ) - } - - val dataQuiet by lazy { - Channel( - 60, - "pl.szczodrzynski.edziennik.DATA_QUIET", - c.getString(R.string.notification_channel_notifications_quiet_name), - c.getString(R.string.notification_channel_notifications_quiet_desc), - IMPORTANCE_LOW, - PRIORITY_LOW, - quiet = true - ) - } - - val updates by lazy { - Channel( - 100, - "pl.szczodrzynski.edziennik.UPDATES", - c.getString(R.string.notification_channel_updates_name), - c.getString(R.string.notification_channel_updates_desc), - IMPORTANCE_DEFAULT, - PRIORITY_DEFAULT - ) - } - - val userAttention by lazy { - Channel( - 200, - "pl.szczodrzynski.edziennik.USER_ATTENTION", - c.getString(R.string.notification_channel_user_attention_name), - c.getString(R.string.notification_channel_user_attention_desc), - IMPORTANCE_DEFAULT, - PRIORITY_DEFAULT - ) - } - - val all by lazy { listOf( - sync, - data, - dataQuiet, - updates, - userAttention - ) } -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/Time.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/Time.java index 04b0c8a3..3b5bd02f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/Time.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/Time.java @@ -7,6 +7,8 @@ import org.jetbrains.annotations.NotNull; import java.util.Calendar; +import timber.log.Timber; + public class Time implements Comparable