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
@@ -121,7 +121,7 @@ class AppRepository(app: Application) {
* @param pref the dietary preference that should be retrieved
* @return whether the preference needs to be met1
*/
fun getPreference(pref: DietaryPreferences): Boolean =
fun getBooleanPreference(pref: DietaryPreferences): Boolean =
getDietaryPrefs()[pref.ordinal] == DietaryPrefObject.C_TRUE
/**
@@ -170,7 +170,15 @@ class AppRepository(app: Application) {
* @param pref preference to retrieve
* @return whether the user set this preference
*/
fun getPreference(pref: SettingsPreferences): Boolean = prefs.getBoolean(pref.key, false)
fun getBooleanPreference(pref: SettingsPreferences): Boolean = prefs.getBoolean(pref.key, false)
/**
* Retrieves ta user-set integer preference.
*
* @param pref preference to retrieve
* @return whether the user set this preference
*/
fun getIntPreference(pref: SettingsPreferences): Int = prefs.getInt(pref.key, 0)
/**
* Updates a user-set boolean preference.
@@ -181,4 +189,14 @@ class AppRepository(app: Application) {
fun setPreference(pref: SettingsPreferences, newValue: Boolean) {
prefs.edit().putBoolean(pref.key, newValue).apply()
}
/**
* Updates a user-set integer preference.
*
* @param pref preference to set
* @param newValue new value to set the preference to
*/
fun setPreference(pref: SettingsPreferences, newValue: Int) {
prefs.edit().putInt(pref.key, newValue).apply()
}
}