[Usos] Override lesson colors by activity type.

This commit is contained in:
Kuba Szczodrzyński 2022-10-16 18:13:22 +02:00
parent 4de066bf5f
commit 044cedff99
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
6 changed files with 2343 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -105,6 +105,15 @@ class UsosApiTimetable(
val groupName = classTypeId?.plus(groupNumber)?.let { s -> "($s)" }
it.classroom = "$buildingId / $roomNumber ${groupName ?: ""}"
it.id = it.buildId()
it.color = when (classTypeId) {
"WYK" -> 0xff0d6091
"CW" -> 0xff54306e
"LAB" -> 0xff772747
"KON" -> 0xff1e5128
"^P?SEM" -> 0xff1e5128 // TODO make it regex
else -> 0xff08534c
}.toInt()
}
lesson.date?.let { foundDates += it }

View File

@ -44,7 +44,7 @@ import pl.szczodrzynski.edziennik.data.db.migration.*
TimetableManual::class,
Note::class,
Metadata::class
], version = 97)
], version = 98)
@TypeConverters(
ConverterTime::class,
ConverterDate::class,
@ -185,6 +185,7 @@ abstract class AppDb : RoomDatabase() {
Migration95(),
Migration96(),
Migration97(),
Migration98(),
).allowMainThreadQueries().build()
}
}

View File

@ -74,6 +74,8 @@ open class Lesson(
@Ignore
var showAsUnseen = false
var color: Int? = null
override fun toString(): String {
return "Lesson(profileId=$profileId, " +
"id=$id, " +

View File

@ -0,0 +1,15 @@
/*
* Copyright (c) Kuba Szczodrzyński 2022-10-16.
*/
package pl.szczodrzynski.edziennik.data.db.migration
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
class Migration98 : Migration(97, 98) {
override fun migrate(database: SupportSQLiteDatabase) {
// timetable colors - override color in lesson object
database.execSQL("ALTER TABLE timetable ADD COLUMN color INT DEFAULT NULL;")
}
}

View File

@ -328,7 +328,7 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope {
lesson.getNoteSubstituteText(showNotes = true) ?: lesson.displaySubjectName
val (subjectTextPrimary, subjectTextSecondary) = if (profileConfig.timetableColorSubjectName) {
val subjectColor = Colors.stringToMaterialColorCRC(lessonText?.toString() ?: "")
val subjectColor = lesson.color ?: Colors.stringToMaterialColorCRC(lessonText?.toString() ?: "")
if (lb.annotationVisible) {
lb.subjectContainer.background = ColorDrawable(subjectColor)
} else {