From dfd1083e41fcf24683a95b292094b56371792584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 30 Nov 2022 10:41:43 +0100 Subject: [PATCH 1/8] [UI/Timetable] Show lesson replacing notes in all places. --- .../pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt | 7 +++++-- .../edziennik/ui/home/cards/HomeTimetableCard.kt | 2 ++ .../ui/widgets/timetable/WidgetTimetableProvider.kt | 5 ++++- .../edziennik/utils/models/ItemWidgetTimetableModel.java | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt index c63311e1..dc7144bc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt @@ -61,6 +61,7 @@ class CounterActivity : AppCompatActivity(), CoroutineScope { it.type != Lesson.TYPE_SHIFTED_SOURCE }) } + lessonList.onEach { it.filterNotes() } } b.bellSync.setImageDrawable( @@ -101,13 +102,15 @@ class CounterActivity : AppCompatActivity(), CoroutineScope { when { actual != null -> { - b.lessonName.text = actual.displaySubjectName + b.lessonName.text = actual.getNoteSubstituteText(showNotes = true) + ?: actual.displaySubjectName val left = actual.displayEndTime!! - now b.timeLeft.text = timeLeft(left.toInt(), "\n", countInSeconds) } next != null -> { - b.lessonName.text = next.displaySubjectName + b.lessonName.text = next.getNoteSubstituteText(showNotes = true) + ?: next.displaySubjectName val till = next.displayStartTime!! - now b.timeLeft.text = timeTill(till.toInt(), "\n", countInSeconds) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt index f5523eec..39959121 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeTimetableCard.kt @@ -232,6 +232,7 @@ class HomeTimetableCard( } lessons = lessons.filter { it.type != Lesson.TYPE_NO_LESSONS } + lessons.onEach { it.filterNotes() } b.timetableLayout.visibility = View.VISIBLE b.noTimetableLayout.visibility = View.GONE @@ -344,6 +345,7 @@ class HomeTimetableCard( private val LessonFull?.subjectSpannable: CharSequence get() = if (this == null) "?" else when { + hasReplacingNotes() -> getNoteSubstituteText(showNotes = true) ?: "?" isCancelled -> displaySubjectName?.asStrikethroughSpannable() ?: "?" isChange -> displaySubjectName?.asItalicSpannable() ?: "?" else -> displaySubjectName ?: "?" 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 2ac510f5..10df27c3 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 @@ -337,8 +337,11 @@ class WidgetTimetableProvider : AppWidgetProvider() { scrollPos = pos + 1 } + // remove notes from other profiles + lesson.filterNotes() // set the subject and classroom name - model.subjectName = lesson.displaySubjectName + model.subjectName = lesson.getNoteSubstituteText(showNotes = true) + ?: lesson.displaySubjectName model.classroomName = lesson.displayClassroom // set the bell sync to calculate progress in ListProvider diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java index 05c41e3b..964bee93 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java @@ -19,7 +19,7 @@ public class ItemWidgetTimetableModel { public Time endTime; public boolean lessonPassed; public boolean lessonCurrent; - public String subjectName = ""; + public CharSequence subjectName = ""; public String classroomName = ""; public boolean lessonChange = false; public boolean lessonChangeNoClassroom = false; From 5007587192695e84aff6c1269c98d72ffaf9adae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 30 Nov 2022 11:29:43 +0100 Subject: [PATCH 2/8] [UI/Agenda] Allow prioritizing event subject over event type. --- .../main/java/pl/szczodrzynski/edziennik/App.kt | 6 ++++++ .../szczodrzynski/edziennik/config/BaseConfig.kt | 2 ++ .../edziennik/config/ProfileConfigUI.kt | 1 + .../ui/agenda/event/AgendaEventRenderer.kt | 13 +++++++++++-- .../edziennik/ui/event/EventDetailsDialog.kt | 15 +++++++++++++-- .../edziennik/ui/event/EventListAdapter.kt | 1 + .../edziennik/ui/event/EventViewHolder.kt | 2 +- .../edziennik/ui/home/cards/HomeEventsCard.kt | 5 +++-- .../edziennik/utils/managers/EventManager.kt | 2 ++ .../edziennik/utils/managers/NoteManager.kt | 2 +- app/src/main/res/layout/dialog_config_agenda.xml | 8 ++++++++ app/src/main/res/layout/dialog_event_details.xml | 3 ++- app/src/main/res/raw/app_data.json | 1 + app/src/main/res/values/strings.xml | 1 + 14 files changed, 53 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt index 30225982..cf688b03 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt @@ -422,6 +422,12 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { try { App.data = AppData.get(profile.loginStoreType) d("App", "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 + if (!config.has(key)) + config.set(key, value) + } } catch (e: Exception) { Log.e("App", "Cannot load AppData", e) Toast.makeText(this, R.string.app_cannot_load_data, Toast.LENGTH_LONG).show() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/BaseConfig.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/BaseConfig.kt index 69d232c5..76d95b0b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/BaseConfig.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/BaseConfig.kt @@ -43,4 +43,6 @@ abstract class BaseConfig( db.configDao().add(ConfigEntry(profileId ?: -1, key, value)) } } + + fun has(key: String) = values.containsKey(key) } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigUI.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigUI.kt index 4bfaf047..35951082 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigUI.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigUI.kt @@ -15,6 +15,7 @@ class ProfileConfigUI(base: ProfileConfig) { var agendaGroupByType by base.config(false) var agendaLessonChanges by base.config(true) var agendaTeacherAbsence by base.config(true) + var agendaSubjectImportant by base.config(false) var agendaElearningMark by base.config(false) var agendaElearningGroup by base.config(true) 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 31eb6730..a1b9ead4 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 @@ -11,6 +11,7 @@ import android.widget.TextView import androidx.core.view.isVisible import com.github.tibolte.agendacalendarview.render.EventRenderer import com.mikepenz.iconics.view.IconicsTextView +import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding @@ -53,16 +54,24 @@ class AgendaEventRenderer( else event.time!!.stringHM + val agendaSubjectImportant = App.profile.config.ui.agendaSubjectImportant val eventSubtitle = listOfNotNull( timeText, - event.subjectLongName, + event.subjectLongName.takeIf { !agendaSubjectImportant }, + event.typeName.takeIf { agendaSubjectImportant }, event.teacherName, event.teamName ).join(", ") card.foreground.setTintColor(event.eventColor) card.background.setTintColor(event.eventColor) - manager.setEventTopic(title, event, doneIconColor = textColor) + manager.setEventTopic( + title = title, + event = event, + doneIconColor = textColor, + showType = !agendaSubjectImportant, + showSubject = agendaSubjectImportant, + ) title.setTextColor(textColor) subtitle?.text = eventSubtitle subtitle?.setTextColor(textColor) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventDetailsDialog.kt index efd8f700..30701f9c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventDetailsDialog.kt @@ -113,9 +113,20 @@ class EventDetailsDialog( b.typeColor.background?.setTintColor(event.eventColor) - b.details = mutableListOf( + val agendaSubjectImportant = event.subjectLongName != null + && App.config[event.profileId].ui.agendaSubjectImportant + + b.name = if (agendaSubjectImportant) + event.subjectLongName + else + event.typeName + + b.details = listOfNotNull( + if (agendaSubjectImportant) + event.typeName + else event.subjectLongName, - event.teamName?.asColoredSpannable(colorSecondary) + event.teamName?.asColoredSpannable(colorSecondary) ).concat(bullet) b.addedBy.setText( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventListAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventListAdapter.kt index f991eeef..5c2f4eef 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventListAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventListAdapter.kt @@ -24,6 +24,7 @@ class EventListAdapter( val showDate: Boolean = false, val showColor: Boolean = true, val showType: Boolean = true, + val showTypeColor: Boolean = showType, val showTime: Boolean = true, val showSubject: Boolean = true, val markAsSeen: Boolean = true, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventViewHolder.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventViewHolder.kt index bee5e305..f22be345 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventViewHolder.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/event/EventViewHolder.kt @@ -113,7 +113,7 @@ class EventViewHolder( b.attachmentIcon.isVisible = item.hasAttachments b.typeColor.background?.setTintColor(item.eventColor) - b.typeColor.isVisible = adapter.showType && adapter.showColor + b.typeColor.isVisible = adapter.showTypeColor b.editButton.isVisible = !adapter.simpleMode && item.addedManually diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeEventsCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeEventsCard.kt index db26d8e9..acf99b2c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeEventsCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/cards/HomeEventsCard.kt @@ -63,9 +63,10 @@ class HomeEventsCard( simpleMode = true, showWeekDay = true, showDate = true, - showType = true, + showType = !profile.config.ui.agendaSubjectImportant, + showTypeColor = true, showTime = false, - showSubject = false, + showSubject = profile.config.ui.agendaSubjectImportant, markAsSeen = false, onEventClick = { EventDetailsDialog( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt index cedf3122..38a8fee3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/EventManager.kt @@ -48,6 +48,7 @@ class EventManager(val app: App) : CoroutineScope { title: TextView, event: EventFull, showType: Boolean = true, + showSubject: Boolean = false, showNotes: Boolean = true, doneIconColor: Int? = null ) { @@ -60,6 +61,7 @@ class EventManager(val app: App) : CoroutineScope { if (event.hasNotes() && hasReplacingNotes && showNotes) "{cmd-swap-horizontal} " else null, if (event.hasNotes() && !hasReplacingNotes && showNotes) "{cmd-playlist-edit} " else null, if (showType) "${event.typeName ?: "wydarzenie"} - " else null, + if (showSubject) event.subjectLongName?.plus(" - ") else null, topicSpan, ).concat() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt index 866555bd..50ac84cd 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/NoteManager.kt @@ -171,7 +171,7 @@ class NoteManager(private val app: App) { activity = activity, simpleMode = true, showDate = true, - showColor = false, + showTypeColor = false, showTime = false, markAsSeen = false, showNotes = false, diff --git a/app/src/main/res/layout/dialog_config_agenda.xml b/app/src/main/res/layout/dialog_config_agenda.xml index 3258f656..effe23fe 100644 --- a/app/src/main/res/layout/dialog_config_agenda.xml +++ b/app/src/main/res/layout/dialog_config_agenda.xml @@ -50,6 +50,14 @@ android:minHeight="32dp" android:text="@string/agenda_config_teacher_absence" /> + + + @@ -55,7 +56,7 @@ Ustaw tworzone wydarzenia domyślnie jako udostępnione Rejestracja Wszystkie lekcje: + Wyświetl nazwę przedmiotu zamiast rodzaju From 5f8016061d8727a5e7e53c111102b6c88bbb3261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 6 Dec 2022 10:22:47 +0100 Subject: [PATCH 3/8] [API/Vulcan] Fix wrong serializing of null in JSON causing API error. --- .../main/java/pl/szczodrzynski/edziennik/ext/JsonExtensions.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ext/JsonExtensions.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ext/JsonExtensions.kt index b91399a6..fb261e0e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ext/JsonExtensions.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ext/JsonExtensions.kt @@ -73,7 +73,8 @@ fun JsonObject(vararg properties: Pair): JsonObject { is Number -> addProperty(key, value) is Boolean -> addProperty(key, value) is Enum<*> -> addProperty(key, value.toInt()) - else -> add(key, property.toJsonElement()) + null -> add(key, null) + else -> add(key, value.toJsonElement()) } } } From 81d4801d2735d6d87c346c66e467b5857eccef8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 6 Dec 2022 10:34:12 +0100 Subject: [PATCH 4/8] [UI] Add snowfall to CounterActivity. Enable in February as well. --- .../szczodrzynski/edziennik/MainActivity.kt | 2 +- .../edziennik/ui/home/CounterActivity.kt | 24 +++++++++++++++++++ app/src/main/res/layout/activity_counter.xml | 9 ++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt index ce39bc77..7965d17a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt @@ -322,7 +322,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope { // IT'S WINTER MY DUDES val today = Date.getToday() - if ((today.month % 11 == 1) && app.config.ui.snowfall) { + if ((today.month / 3 % 4 == 0) && app.config.ui.snowfall) { b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false)) } else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) { val eggfall = layoutInflater.inflate( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt index dc7144bc..b1f10d3b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/CounterActivity.kt @@ -4,8 +4,10 @@ package pl.szczodrzynski.edziennik.ui.home +import android.graphics.BitmapFactory import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import com.jetradarmobile.snowfall.SnowfallView import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.utils.colorInt import com.mikepenz.iconics.utils.sizeDp @@ -20,6 +22,7 @@ import pl.szczodrzynski.edziennik.ext.startCoroutineTimer import pl.szczodrzynski.edziennik.ext.timeLeft import pl.szczodrzynski.edziennik.ext.timeTill import pl.szczodrzynski.edziennik.ui.dialogs.BellSyncTimeChooseDialog +import pl.szczodrzynski.edziennik.utils.BigNightUtil import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time import kotlin.coroutines.CoroutineContext @@ -82,6 +85,27 @@ class CounterActivity : AppCompatActivity(), CoroutineScope { counterJob = startCoroutineTimer(repeatMillis = 500) { update() } + + // IT'S WINTER MY DUDES + val today = Date.getToday() + if ((today.month / 3 % 4 == 0) && app.config.ui.snowfall) { + b.rootFrame.addView(layoutInflater.inflate(R.layout.snowfall, b.rootFrame, false)) + } else if (app.config.ui.eggfall && BigNightUtil().isDataWielkanocyNearDzisiaj()) { + val eggfall = layoutInflater.inflate( + R.layout.eggfall, + b.rootFrame, + false + ) as SnowfallView + eggfall.setSnowflakeBitmaps(listOf( + BitmapFactory.decodeResource(resources, R.drawable.egg1), + BitmapFactory.decodeResource(resources, R.drawable.egg2), + BitmapFactory.decodeResource(resources, R.drawable.egg3), + BitmapFactory.decodeResource(resources, R.drawable.egg4), + BitmapFactory.decodeResource(resources, R.drawable.egg5), + BitmapFactory.decodeResource(resources, R.drawable.egg6) + )) + b.rootFrame.addView(eggfall) + } }} private fun update() { diff --git a/app/src/main/res/layout/activity_counter.xml b/app/src/main/res/layout/activity_counter.xml index 9c7f832d..77b1cde2 100644 --- a/app/src/main/res/layout/activity_counter.xml +++ b/app/src/main/res/layout/activity_counter.xml @@ -1,6 +1,9 @@ - + - + From 48c9e2dfe36b7f80d9dc8106ce5cb8d0e920a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 6 Dec 2022 10:35:23 +0100 Subject: [PATCH 5/8] [4.13.3] Update build.gradle, signing and changelog. --- app/src/main/assets/pl-changelog.html | 5 ++++- app/src/main/cpp/szkolny-signing.cpp | 2 +- .../edziennik/data/api/szkolny/interceptor/Signing.kt | 2 +- build.gradle | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/assets/pl-changelog.html b/app/src/main/assets/pl-changelog.html index e49ccaa1..06eaf13b 100644 --- a/app/src/main/assets/pl-changelog.html +++ b/app/src/main/assets/pl-changelog.html @@ -1,5 +1,8 @@ -

Wersja 4.13.2, 2022-11-28

+

Wersja 4.13.3, 2022-12-06

    +
  • Notatki zastępujące treść lekcji są teraz wyświetlane wszędzie.
  • +
  • Opcja wyświetlania nazwy przedmiotu w miejscu rodzaju wydarzenia.
  • +
  • Na ekranie odliczania czasu lekcji również pada śnieg.
  • Poprawiono synchronizację w Mobidzienniku bez ustawionego adresu e-mail.
  • Poprawiono błąd synchronizacji w Vulcanie.
diff --git a/app/src/main/cpp/szkolny-signing.cpp b/app/src/main/cpp/szkolny-signing.cpp index 582bc8b3..5864ba65 100644 --- a/app/src/main/cpp/szkolny-signing.cpp +++ b/app/src/main/cpp/szkolny-signing.cpp @@ -9,7 +9,7 @@ /*secret password - removed for source code publication*/ static toys AES_IV[16] = { - 0x8c, 0xad, 0x9c, 0x3e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xf1, 0x81, 0xc5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat); 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 cea7a064..ae959d43 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 @@ -46,6 +46,6 @@ object Signing { /*fun provideKey(param1: String, param2: Long): ByteArray {*/ fun pleaseStopRightNow(param1: String, param2: Long): ByteArray { - return "$param1.MTIzNDU2Nzg5MDLUEjNGMN===.$param2".sha256() + return "$param1.MTIzNDU2Nzg5MDgyAWPEgk===.$param2".sha256() } } diff --git a/build.gradle b/build.gradle index d51f1fec..1cad0c68 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { kotlin_version = '1.6.10' release = [ - versionName: "4.13.2", - versionCode: 4130299 + versionName: "4.13.3", + versionCode: 4130399 ] setup = [ From aaa3b8626ea13a9179058328b609bf6d6af75f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 26 Dec 2022 14:01:25 +0100 Subject: [PATCH 6/8] [UI] Update event types for university school. --- .../szczodrzynski/edziennik/config/AppData.kt | 2 +- .../edziennik/config/ProfileConfig.kt | 2 +- .../config/utils/ProfileConfigMigration.kt | 16 +++++- .../edziennik/data/db/dao/EventTypeDao.kt | 22 +++++++- .../edziennik/data/db/entity/EventType.kt | 55 ------------------- .../edziennik/ui/agenda/AgendaFragment.kt | 8 +-- .../edziennik/ui/debug/LabPageFragment.kt | 7 +++ .../edziennik/ui/views/EventTypeDropdown.kt | 9 +-- app/src/main/res/layout/lab_fragment.xml | 7 +++ app/src/main/res/raw/app_data.json | 27 ++++----- 10 files changed, 66 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/AppData.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/AppData.kt index 6f72b82e..b2aa8797 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/AppData.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/AppData.kt @@ -62,7 +62,7 @@ data class AppData( ) data class EventType( - val id: Int, + val id: Long, val color: String, val name: String, ) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfig.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfig.kt index 4df2ef47..c36b6fae 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfig.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfig.kt @@ -15,7 +15,7 @@ class ProfileConfig( entries: List?, ) : BaseConfig(db, profileId, entries) { companion object { - const val DATA_VERSION = 4 + const val DATA_VERSION = 5 } val grades by lazy { ProfileConfigGrades(this) } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ProfileConfigMigration.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ProfileConfigMigration.kt index c5b56690..ab915b1d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ProfileConfigMigration.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/utils/ProfileConfigMigration.kt @@ -16,6 +16,8 @@ import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.YEAR_AL class ProfileConfigMigration(config: ProfileConfig) { init { config.apply { + val profile = db.profileDao().getByIdNow(profileId ?: -1) + if (dataVersion < 2) { sync.notificationFilter = sync.notificationFilter + NotificationType.TEACHER_ABSENCE @@ -37,11 +39,23 @@ class ProfileConfigMigration(config: ProfileConfig) { // switch to new event types (USOS) dataVersion = 4 - val profile = db.profileDao().getByIdNow(profileId ?: -1) if (profile?.loginStoreType?.schoolType == SchoolType.UNIVERSITY) { db.eventTypeDao().clear(profileId ?: -1) db.eventTypeDao().addDefaultTypes(profile) } } + + if (dataVersion < 5) { + // update USOS event types and the appropriate events (2022-12-25) + dataVersion = 5 + + if (profile?.loginStoreType?.schoolType == SchoolType.UNIVERSITY) { + db.eventTypeDao().getAllWithDefaults(profile) + // wejściówka (4) -> kartkówka (3) + db.eventDao().getRawNow("UPDATE events SET eventType = 3 WHERE profileId = $profileId AND eventType = 4;") + // zadanie (6) -> zadanie domowe (-1) + db.eventDao().getRawNow("UPDATE events SET eventType = -1 WHERE profileId = $profileId AND eventType = 6;") + } + } }} } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventTypeDao.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventTypeDao.kt index c6c9ee44..2f3f5c94 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventTypeDao.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventTypeDao.kt @@ -25,6 +25,9 @@ abstract class EventTypeDao { @Query("DELETE FROM eventTypes WHERE profileId = :profileId") abstract fun clear(profileId: Int) + @Query("DELETE FROM eventTypes WHERE profileId = :profileId AND eventTypeSource = :source") + abstract fun clearBySource(profileId: Int, source: Int) + @Query("SELECT * FROM eventTypes WHERE profileId = :profileId AND eventType = :typeId") abstract fun getByIdNow(profileId: Int, typeId: Long): EventType? @@ -43,7 +46,7 @@ abstract class EventTypeDao { val typeList = data.eventTypes.map { EventType( profileId = profile.id, - id = it.id.toLong(), + id = it.id, name = it.name, color = Color.parseColor(it.color), order = order++, @@ -53,4 +56,21 @@ abstract class EventTypeDao { addAll(typeList) return typeList } + + fun getAllWithDefaults(profile: Profile): List { + val eventTypes = getAllNow(profile.id) + + val defaultIdsExpected = AppData.get(profile.loginStoreType).eventTypes + .map { it.id } + val defaultIdsFound = eventTypes.filter { it.source == SOURCE_DEFAULT } + .sortedBy { it.order } + .map { it.id } + + if (defaultIdsExpected == defaultIdsFound) + return eventTypes + + clearBySource(profile.id, SOURCE_DEFAULT) + addDefaultTypes(profile) + return eventTypes + } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/EventType.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/EventType.kt index 7753b38a..00ba4c04 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/EventType.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/entity/EventType.kt @@ -5,31 +5,6 @@ package pl.szczodrzynski.edziennik.data.db.entity import androidx.room.ColumnInfo import androidx.room.Entity -import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_CLASS_EVENT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_DEFAULT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_ELEARNING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_ESSAY -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_EXAM -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_EXCURSION -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_HOMEWORK -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_INFORMATION -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_PROJECT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_PT_MEETING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_READING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.COLOR_SHORT_QUIZ -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_CLASS_EVENT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_DEFAULT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_ELEARNING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_ESSAY -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_EXAM -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_EXCURSION -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_HOMEWORK -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_INFORMATION -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_PROJECT -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_PT_MEETING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_READING -import pl.szczodrzynski.edziennik.data.db.entity.Event.Companion.TYPE_SHORT_QUIZ @Entity( tableName = "eventTypes", @@ -55,35 +30,5 @@ class EventType( const val SOURCE_REGISTER = 1 const val SOURCE_CUSTOM = 2 const val SOURCE_SHARED = 3 - - fun getTypeColorMap() = mapOf( - TYPE_ELEARNING to COLOR_ELEARNING, - TYPE_HOMEWORK to COLOR_HOMEWORK, - TYPE_DEFAULT to COLOR_DEFAULT, - TYPE_EXAM to COLOR_EXAM, - TYPE_SHORT_QUIZ to COLOR_SHORT_QUIZ, - TYPE_ESSAY to COLOR_ESSAY, - TYPE_PROJECT to COLOR_PROJECT, - TYPE_PT_MEETING to COLOR_PT_MEETING, - TYPE_EXCURSION to COLOR_EXCURSION, - TYPE_READING to COLOR_READING, - TYPE_CLASS_EVENT to COLOR_CLASS_EVENT, - TYPE_INFORMATION to COLOR_INFORMATION - ) - - fun getTypeNameMap() = mapOf( - TYPE_ELEARNING to R.string.event_type_elearning, - TYPE_HOMEWORK to R.string.event_type_homework, - TYPE_DEFAULT to R.string.event_other, - TYPE_EXAM to R.string.event_exam, - TYPE_SHORT_QUIZ to R.string.event_short_quiz, - TYPE_ESSAY to R.string.event_essay, - TYPE_PROJECT to R.string.event_project, - TYPE_PT_MEETING to R.string.event_pt_meeting, - TYPE_EXCURSION to R.string.event_excursion, - TYPE_READING to R.string.event_reading, - TYPE_CLASS_EVENT to R.string.event_class_event, - TYPE_INFORMATION to R.string.event_information - ) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/AgendaFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/AgendaFragment.kt index 52c9f345..cbdbce7b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/AgendaFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/agenda/AgendaFragment.kt @@ -142,13 +142,7 @@ class AgendaFragment : Fragment(), CoroutineScope { private suspend fun checkEventTypes() { withContext(Dispatchers.Default) { - val eventTypes = app.db.eventTypeDao().getAllNow(app.profileId).map { - it.id - } - val defaultEventTypes = EventType.getTypeColorMap().keys - if (!eventTypes.containsAll(defaultEventTypes)) { - app.db.eventTypeDao().addDefaultTypes(app.profile) - } + app.db.eventTypeDao().getAllWithDefaults(app.profile) } } 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 5aae3c11..792811eb 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 @@ -23,6 +23,7 @@ import kotlinx.coroutines.launch import pl.szczodrzynski.edziennik.* import pl.szczodrzynski.edziennik.config.Config import pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.SignatureInterceptor +import pl.szczodrzynski.edziennik.data.db.entity.EventType.Companion.SOURCE_DEFAULT import pl.szczodrzynski.edziennik.databinding.LabFragmentBinding import pl.szczodrzynski.edziennik.ext.* import pl.szczodrzynski.edziennik.ui.base.lazypager.LazyFragment @@ -65,6 +66,7 @@ class LabPageFragment : LazyFragment(), CoroutineScope { b.clearEndpointTimers.isVisible = false b.rodo.isVisible = false b.removeHomework.isVisible = false + b.resetEventTypes.isVisible = false b.unarchive.isVisible = false b.profile.isVisible = false } @@ -100,6 +102,11 @@ class LabPageFragment : LazyFragment(), CoroutineScope { app.db.eventDao().getRawNow("UPDATE events SET homeworkBody = NULL WHERE profileId = ${App.profileId}") } + b.resetEventTypes.onClick { + app.db.eventTypeDao().clearBySource(App.profileId, SOURCE_DEFAULT) + app.db.eventTypeDao().getAllWithDefaults(App.profile) + } + b.chucker.isChecked = App.enableChucker b.chucker.onChange { _, isChecked -> app.config.enableChucker = isChecked diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/EventTypeDropdown.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/EventTypeDropdown.kt index d6a8d1cd..48d327fc 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/EventTypeDropdown.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/views/EventTypeDropdown.kt @@ -33,13 +33,8 @@ class EventTypeDropdown : TextInputDropDown { suspend fun loadItems() { val types = withContext(Dispatchers.Default) { val list = mutableListOf() - - var types = db.eventTypeDao().getAllNow(profileId) - - if (types.none { it.id in -1L..10L }) { - val profile = db.profileDao().getByIdNow(profileId) ?: return@withContext listOf() - types = db.eventTypeDao().addDefaultTypes(profile) - } + val types = db.eventTypeDao().getAllNow(profileId) + .sortedBy { it.order } list += types.map { Item(it.id, it.name, tag = it, icon = IconicsDrawable(context).apply { diff --git a/app/src/main/res/layout/lab_fragment.xml b/app/src/main/res/layout/lab_fragment.xml index d290525c..e41a66f2 100644 --- a/app/src/main/res/layout/lab_fragment.xml +++ b/app/src/main/res/layout/lab_fragment.xml @@ -100,6 +100,13 @@ android:text="Remove all homework body (null)" android:textAllCaps="false" /> +