Added colour to StudIPEvent.kt to implement at a later date in an effort to prepare the app for release without needing to migrate (= nuke) the database once the functionality will be implemented

This commit is contained in:
denizk0461
2023-04-23 21:40:04 +02:00
parent ca89e68a91
commit 8d6a15c4d5
10 changed files with 168 additions and 66 deletions
@@ -17,7 +17,7 @@ import com.denizk0461.studip.model.*
OfferCategory::class,
OfferItem::class
],
version = 11,
version = 12,
)
abstract class AppDatabase : RoomDatabase() {
@@ -0,0 +1,26 @@
package com.denizk0461.studip.model
import com.denizk0461.studip.R
/**
* Enumeration used to save and apply custom colours to Stud.IP events.
* TODO finish implementation
*
* @param colourId resource ID of the colour
*/
enum class StudIPColour(val colourId: Int) {
DEFAULT(R.attr.scheduleColorDefault);
companion object {
/**
* Retrieve a StudIPColour object by its ordinal.
*
* @param ordinal numeric position of the colour in the enumeration
* @return enum object
*/
fun getEnumValue(ordinal: Int): StudIPColour =
StudIPColour.values()[ordinal]
}
}
@@ -24,7 +24,7 @@ data class StudIPEvent(
val day: Int,
val timeslotStart: String,
val timeslotEnd: String,
val colour: String = "000000",
val colour: Int = 0,
) {
/**
+1
View File
@@ -43,6 +43,7 @@
android:layout_height="wrap_content"
app:menu="@menu/nav_view_items"
app:labelVisibilityMode="selected"
app:itemTextColor="?attr/colorOnSurfaceVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
+114 -45
View File
@@ -11,6 +11,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Stud.IP schedule settings -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -30,7 +31,7 @@
android:layout_marginBottom="8dp"
android:textSize="22sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_misc"
android:text="@string/settings_schedule"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"/>
@@ -40,7 +41,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"/>
<!-- App version -->
<!-- Refresh schedule -->
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/button_refresh_schedule"
android:layout_width="match_parent"
@@ -67,49 +68,6 @@
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- Academic quarter -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_quarter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/switch_quarter"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_quarter_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="@string/settings_quarter_subtitle"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switch_quarter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Highlight course -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_highlight"
@@ -153,6 +111,117 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>
<!-- canteen settings -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="4dp"
style="@style/Widget.Material3.CardView.Outlined">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textSize="22sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_canteen"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"/>
<com.google.android.material.divider.MaterialDivider
style="@style/DividerTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"/>
<!-- Allergens -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_allergens"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/switch_allergens"
android:layout_marginEnd="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_allergens_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="@string/settings_allergens_subtitle"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switch_allergens"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>
<!-- miscellaneous settings -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="4dp"
style="@style/Widget.Material3.CardView.Outlined">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textSize="22sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_misc"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"/>
<com.google.android.material.divider.MaterialDivider
style="@style/DividerTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"/>
<!-- Data handling -->
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/button_data_handling"
+9 -5
View File
@@ -8,7 +8,7 @@
<string name="friday">FREITAG</string>
<string name="title_schedule">Dein Stundenplan</string>
<string name="title_food">Mensen-Angebote</string>
<string name="title_food">Mensenangebote</string>
<string name="title_settings">App-Einstellungen</string>
<string name="mensa_uni">Uni-Mensa</string>
@@ -81,22 +81,26 @@
<string name="allergens_contains">Enthält: %s.</string>
<string name="nav_schedule">Stundenplan</string>
<string name="nav_food">Mensen</string>
<string name="nav_food">Mensa</string>
<string name="nav_settings">Einstellungen</string>
<string name="toast_fetch_finished">Dein Stundenplan wurde aktualisiert!</string>
<string name="settings_general">Allgemein</string>
<string name="settings_schedule">Stud.IP-Stundenplan</string>
<string name="settings_canteen">Mensenangebote</string>
<string name="settings_misc">Sonstiges</string>
<string name="refresh_schedule_title">Aktualisiere deinen Stud.IP-Stundenplan</string>
<string name="refresh_schedule_subtitle">Dies wird alle Anpassungen löschen!</string>
<string name="settings_quarter_title">Nutze akademisches Viertel</string>
<string name="settings_quarter_subtitle">Wo es passt</string>
<string name="settings_highlight_title">Markiere meinen nächsten Kurs</string>
<string name="settings_highlight_subtitle">Funktioniert nur wenn Kurse sich nicht überschneiden!</string>
<string name="settings_quarter_title">Nutze akademisches Viertel</string>
<string name="settings_quarter_subtitle">Wo es passt</string>
<string name="settings_allergens_title">Markiere Allergene mit einem Stern*</string>
<string name="settings_allergens_subtitle">Wird auch für Zusatzstoffe genutzt</string>
<string name="settings_data_title">Was passiert mit meinen Daten?</string>
<string name="settings_data_subtitle">Stiehlst du meinen Login?</string>
<string name="settings_data_subtitle">Stiehlst du meinen Stud.IP-Login?</string>
<string name="settings_app_version">App-Verison</string>
<string name="with_love">mit ♡️ aus Bremen-Osterholz\von denizk0461 \\__*</string>
+4
View File
@@ -29,6 +29,10 @@
<item name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item>
<item name="android:textColor">@color/md_theme_dark_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_dark_onSurfaceVariant</item>
<!-- is this correct? -->
<item name="scheduleColorDefault">@color/md_theme_light_background</item>
</style>
<style name="DividerTheme" parent="Widget.Material3.MaterialDivider">
+1 -11
View File
@@ -1,14 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="colorNavHighlight" format="color" />
<attr name="colorPrimaryOnContrast" format="color" />
<attr name="colorPrimary" format="color" />
<attr name="colorPrimaryTranslucent" format="color" />
<attr name="colorOnPrimary" format="color" />
<attr name="colorText" format="color" />
<attr name="colorTextHint" format="color" />
<attr name="colorTextHintLighter" format="color" />
<attr name="colorBackground" format="color" />
<attr name="colorCardBackground" format="color" />
<attr name="colorSwitchTrack" format="color" />
<attr name="scheduleColorDefault" type="color"/>
</resources>
+7 -3
View File
@@ -87,16 +87,20 @@
<string name="toast_fetch_finished">Your schedule has been refreshed!</string>
<string name="settings_general">General</string>
<string name="settings_schedule">Stud.IP Schedule</string>
<string name="settings_canteen">Canteen Offers</string>
<string name="settings_misc">Miscellaneous</string>
<string name="refresh_schedule_title">Refresh your Stud.IP schedule</string>
<string name="refresh_schedule_subtitle">This will clear any customisations!</string>
<string name="settings_quarter_title">Use academic quarter</string>
<string name="settings_quarter_subtitle">Where applicable</string>
<string name="settings_highlight_title">Highlight next course</string>
<string name="settings_highlight_subtitle">Only works properly if courses don\'t overlap!</string>
<string name="settings_quarter_title">Use academic quarter</string>
<string name="settings_quarter_subtitle">Where applicable</string>
<string name="settings_allergens_title">Mark allergens with a star*</string>
<string name="settings_allergens_subtitle">Also applies to additives</string>
<string name="settings_data_title">What happens with my data?</string>
<string name="settings_data_subtitle">Will you steal my login?</string>
<string name="settings_data_subtitle">Will you steal my Stud.IP login?</string>
<string name="settings_app_version">App Version</string>
<string name="with_love">with ♡️ from Bremen-Osterholz\nmade by denizk0461 \\__*</string>
+4
View File
@@ -29,6 +29,10 @@
<item name="colorPrimaryInverse">@color/md_theme_light_inversePrimary</item>
<item name="android:textColor">@color/md_theme_light_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_light_onSurfaceVariant</item>
<!-- is this correct? -->
<item name="scheduleColorDefault">@color/md_theme_dark_background</item>
</style>
<style name="Theme.StudIPTimetable" parent="Base.Theme.StudIPTimetable" />