Archived
Added data type EventTask.kt for the task fragment; added timetableId to StudIPEvent.kt to assign events with a specific timetable, for a future implementation of being able to store multiple timetables simultaneously; database scheme will now be exported to allow for automatic migrations
This commit is contained in:
@@ -96,6 +96,7 @@ class StudIPParser(application: Application) {
|
||||
|
||||
// Construct the newly scraped Stud.IP event
|
||||
val event = StudIPEvent(
|
||||
timetableId = 0, // TODO
|
||||
title = parsedTitle,
|
||||
lecturer = parsedLecturers,
|
||||
room = entryInfo.getOrQuestionMark(1),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.denizk0461.weserplaner.db
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.AutoMigration
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
@@ -18,8 +19,13 @@ import com.denizk0461.weserplaner.model.*
|
||||
OfferCanteen::class,
|
||||
OfferCategory::class,
|
||||
OfferItem::class,
|
||||
EventTask::class,
|
||||
],
|
||||
version = 21,
|
||||
exportSchema = true,
|
||||
autoMigrations = [
|
||||
AutoMigration(from = 20, to = 21),
|
||||
],
|
||||
version = 20,
|
||||
)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
@@ -50,7 +56,11 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
context.applicationContext,
|
||||
AppDatabase::class.java,
|
||||
"event_db",
|
||||
).addMigrations(migrationAddNewsToOfferCanteen_19_20)
|
||||
).addMigrations(
|
||||
migrationAddNewsToOfferCanteen_19_20,
|
||||
// migrationAddTimetableId_20_21,
|
||||
// migrationAddEventTask_20_21,
|
||||
)
|
||||
// .fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ class EventPageFragment : AppFragment<RecyclerViewBinding>(), StudIPEventItemAda
|
||||
eventAdapter.setNewData(events.ifEmpty { listOf(
|
||||
// Use an event with eventId = -1 to denote that there are no events for this day
|
||||
StudIPEvent(
|
||||
-1,
|
||||
-1,
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.denizk0461.weserplaner.model
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(
|
||||
tableName = "event_tasks",
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
StudIPEvent::class,
|
||||
["eventId"],
|
||||
["eventId"],
|
||||
ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class EventTask(
|
||||
@PrimaryKey(autoGenerate = true) val taskId: Int = 0,
|
||||
val eventId: Int,
|
||||
val dueDate: Int,
|
||||
val title: String,
|
||||
val notes: String,
|
||||
val room: String,
|
||||
)
|
||||
@@ -2,6 +2,7 @@ package com.denizk0461.weserplaner.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@@ -9,6 +10,7 @@ import androidx.room.PrimaryKey
|
||||
* Entity for storing entries of the user's Stud.IP schedule. Registered in the app database.
|
||||
*
|
||||
* @param eventId primary key that uniquely identifies the entry
|
||||
* @param timetableId identifier to assign the event to a timetable
|
||||
* @param title title of the event
|
||||
* @param lecturer lecturer(s) organising the event
|
||||
* @param room room the event takes place in
|
||||
@@ -21,6 +23,7 @@ import androidx.room.PrimaryKey
|
||||
@Entity(tableName = "studip_events")
|
||||
data class StudIPEvent(
|
||||
@PrimaryKey(autoGenerate = true) val eventId: Int = 0,
|
||||
@ColumnInfo(defaultValue = "0") val timetableId: Int,
|
||||
val title: String,
|
||||
val lecturer: String,
|
||||
val room: String,
|
||||
@@ -30,6 +33,7 @@ data class StudIPEvent(
|
||||
val timeslotId: Int,
|
||||
val colour: Int = 0,
|
||||
) : Parcelable {
|
||||
|
||||
/**
|
||||
* Parse timeslotStart and timeslotEnd into an easily readable string in the following format:
|
||||
* 12:15 – 13:45
|
||||
@@ -45,6 +49,7 @@ data class StudIPEvent(
|
||||
other as StudIPEvent
|
||||
|
||||
if (eventId != other.eventId) return false
|
||||
if (timetableId != other.timetableId) return false
|
||||
if (title != other.title) return false
|
||||
if (lecturer != other.lecturer) return false
|
||||
if (room != other.room) return false
|
||||
@@ -59,6 +64,7 @@ data class StudIPEvent(
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = eventId
|
||||
result = 31 * result + timetableId
|
||||
result = 31 * result + title.hashCode()
|
||||
result = 31 * result + lecturer.hashCode()
|
||||
result = 31 * result + room.hashCode()
|
||||
@@ -71,6 +77,7 @@ data class StudIPEvent(
|
||||
}
|
||||
|
||||
constructor(source: Parcel) : this(
|
||||
source.readInt(),
|
||||
source.readInt(),
|
||||
source.readString() ?: "",
|
||||
source.readString() ?: "",
|
||||
@@ -86,6 +93,7 @@ data class StudIPEvent(
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int): Unit = with(dest) {
|
||||
writeInt(eventId)
|
||||
writeInt(timetableId)
|
||||
writeString(title)
|
||||
writeString(lecturer)
|
||||
writeString(room)
|
||||
|
||||
@@ -144,6 +144,7 @@ class ScheduleUpdateSheet : AppSheet(R.layout.sheet_schedule_update) {
|
||||
// construct new StudIPEvent from the data the user may have edited
|
||||
StudIPEvent(
|
||||
eventId = event.eventId,
|
||||
timetableId = event.timetableId,
|
||||
title = binding.editTextTitle.text.toString().trim(),
|
||||
lecturer = binding.editTextLecturers.text.toString().trim(),
|
||||
room = binding.editTextRoom.text.toString().trim(),
|
||||
@@ -204,6 +205,7 @@ class ScheduleUpdateSheet : AppSheet(R.layout.sheet_schedule_update) {
|
||||
viewModel.insert(
|
||||
// construct new StudIPEvent from the data the user may have edited
|
||||
StudIPEvent(
|
||||
timetableId = 0, // TODO current timetable
|
||||
title = binding.editTextTitle.text.toString().trim(),
|
||||
lecturer = binding.editTextLecturers.text.toString().trim(),
|
||||
room = binding.editTextRoom.text.toString().trim(),
|
||||
|
||||
@@ -240,6 +240,10 @@
|
||||
|
||||
<string name="settings_licences_title">Siehe Lizenzen</string>
|
||||
<string name="settings_licences_subtitle">Ressourcen, die diese App möglich gemacht haben</string>
|
||||
<string name="settings_unlocked_experiments">Experimentelle Einstellungen werden angezeigt.</string>
|
||||
<string name="settings_hide_experiments">Experimentelle Einstellungen wurden ausgeblendet.</string>
|
||||
|
||||
<string name="sheet_cheat_header">Cheatcodes</string>
|
||||
|
||||
<string name="settings_app_version">App-Version</string>
|
||||
|
||||
|
||||
@@ -245,10 +245,10 @@
|
||||
|
||||
<string name="settings_licences_title">View licences</string>
|
||||
<string name="settings_licences_subtitle">Resources that made this app possible</string>
|
||||
<string name="settings_unlocked_experiments" translatable="false">Experimental settings have been unlocked.</string>
|
||||
<string name="settings_hide_experiments" translatable="false">Experimental settings have been hidden.</string>
|
||||
<string name="settings_unlocked_experiments">Experimental settings have been unlocked.</string>
|
||||
<string name="settings_hide_experiments">Experimental settings have been hidden.</string>
|
||||
|
||||
<string name="sheet_cheat_header" translatable="false">Cheat Codes</string>
|
||||
<string name="sheet_cheat_header">Cheat Codes</string>
|
||||
|
||||
<string name="settings_app_version">App Version</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user