Implemented functionality to switch canteens. UI for this is not fully implemented.

This commit is contained in:
denizk0461
2023-04-25 15:38:30 +02:00
parent 840c8f1db7
commit 6b1d77dfb3
21 changed files with 363 additions and 106 deletions
@@ -37,8 +37,8 @@ class CanteenViewModel(app: Application) : AppViewModel(app) {
fun getDates(): List<OfferDate> = returnBlocking { repo.getDates() }
// Fetch the canteen offers asynchronously. Updates will be provided through a LiveData object.
fun fetchOffers(onRefreshUpdate: (status: Int) -> Unit, onFinish: () -> Unit) {
doAsync { parser.parse(onRefreshUpdate, onFinish) }
fun fetchOffers(canteen: Int, onRefreshUpdate: (status: Int) -> Unit, onFinish: () -> Unit) {
doAsync { parser.parse(canteen, onRefreshUpdate, onFinish) }
}
/**
@@ -57,11 +57,15 @@ class CanteenViewModel(app: Application) : AppViewModel(app) {
* @param pref the dietary preference that should be retrieved
* @return whether the preference needs to be met
*/
fun getPreference(pref: DietaryPreferences): Boolean = repo.getPreference(pref)
fun getPreference(pref: DietaryPreferences): Boolean = repo.getBooleanPreference(pref)
/**
* This value determines whether the user wants to have allergens marked.
*/
val preferenceAllergen: Boolean
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
get() = repo.getBooleanPreference(SettingsPreferences.ALLERGEN)
var preferenceCanteen: Int
get() = repo.getIntPreference(SettingsPreferences.CANTEEN)
set(newValue) { repo.setPreference(SettingsPreferences.CANTEEN, newValue) }
}
@@ -11,23 +11,31 @@ import com.denizk0461.studip.model.SettingsPreferences
class SettingsViewModel(app: Application) : AppViewModel(app) {
/**
* This value determines whether the user opts into submitting crash reports.
* This value determines whether the user wants to have the next course in their schedule
* highlighted.
*/
var preferenceCourseHighlighting: Boolean
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
get() = repo.getBooleanPreference(SettingsPreferences.COURSE_HIGHLIGHTING)
set(newValue) { repo.setPreference(SettingsPreferences.COURSE_HIGHLIGHTING, newValue) }
/**
* This value determines whether the user wants to have allergens marked.
*/
var preferenceAllergen: Boolean
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
get() = repo.getBooleanPreference(SettingsPreferences.ALLERGEN)
set(newValue) { repo.setPreference(SettingsPreferences.ALLERGEN, newValue) }
/**
* This value determines whether the user wants the app to launch with the canteen view.
*/
var preferenceLaunchCanteen: Boolean
get() = repo.getBooleanPreference(SettingsPreferences.LAUNCH_CANTEEN_ON_START)
set(newValue) { repo.setPreference(SettingsPreferences.LAUNCH_CANTEEN_ON_START, newValue) }
/**
* This value determines whether the user opts into submitting crash reports.
*/
var preferenceDataHandling: Boolean
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
get() = repo.getBooleanPreference(SettingsPreferences.DATA_HANDLING)
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
}