mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[Usos] Override lesson colors by activity type.
This commit is contained in:
parent
4de066bf5f
commit
044cedff99
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/98.json
Normal file
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/98.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -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 }
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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, " +
|
||||
|
@ -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;")
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user