Archived
Started implementation of event update sheet
This commit is contained in:
@@ -3,6 +3,7 @@ package com.denizk0461.studip.adapter
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.denizk0461.studip.data.parseToMinutes
|
||||||
import com.denizk0461.studip.model.StudIPEvent
|
import com.denizk0461.studip.model.StudIPEvent
|
||||||
import com.denizk0461.studip.databinding.ItemEventBinding
|
import com.denizk0461.studip.databinding.ItemEventBinding
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -150,17 +151,6 @@ class StudIPEventItemAdapter(
|
|||||||
else -> Calendar.MONDAY
|
else -> Calendar.MONDAY
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a time stamp string to its numeric value in minutes.
|
|
||||||
* Example: 13:20. (20 minutes) + (13 hours * 60 minutes) = 800 minutes.
|
|
||||||
*
|
|
||||||
* @return minute value of the string
|
|
||||||
*/
|
|
||||||
private fun String.parseToMinutes(): Int {
|
|
||||||
val parts = split(":")
|
|
||||||
return (parts[0].toInt() * 60) + parts[1].toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used to evaluate clicks and long presses on a given item.
|
* Interface used to evaluate clicks and long presses on a given item.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,18 @@ package com.denizk0461.studip.data
|
|||||||
/**
|
/**
|
||||||
* Miscellaneous functions and variables that don't belong into any specific class.
|
* Miscellaneous functions and variables that don't belong into any specific class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a time stamp string to its numeric value in minutes.
|
||||||
|
* Example: 13:20. (20 minutes) + (13 hours * 60 minutes) = 800 minutes.
|
||||||
|
*
|
||||||
|
* @return minute value of the string
|
||||||
|
*/
|
||||||
|
fun String.parseToMinutes(): Int {
|
||||||
|
val parts = split(":")
|
||||||
|
return (parts[0].toInt() * 60) + parts[1].toInt()
|
||||||
|
}
|
||||||
|
|
||||||
object Misc {
|
object Misc {
|
||||||
|
|
||||||
// private val timeslotAcademicQuarter = mapOf(
|
// private val timeslotAcademicQuarter = mapOf(
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ class StudIPParser {
|
|||||||
// Retrieve the time slot and split it into start and end time stamps
|
// Retrieve the time slot and split it into start and end time stamps
|
||||||
val timeSlot = entryInfo[0].split(" - ")
|
val timeSlot = entryInfo[0].split(" - ")
|
||||||
|
|
||||||
|
// Time the event starts at
|
||||||
|
val eventStart = timeSlot[0]
|
||||||
|
|
||||||
// Construct the newly scraped Stud.IP event
|
// Construct the newly scraped Stud.IP event
|
||||||
val event = StudIPEvent(
|
val event = StudIPEvent(
|
||||||
id = id,
|
id = id,
|
||||||
@@ -83,8 +86,9 @@ class StudIPParser {
|
|||||||
lecturer = parsedLecturers,
|
lecturer = parsedLecturers,
|
||||||
room = entryInfo[1],
|
room = entryInfo[1],
|
||||||
day = index,
|
day = index,
|
||||||
timeslotStart = timeSlot[0],
|
timeslotStart = eventStart,
|
||||||
timeslotEnd = timeSlot[1],
|
timeslotEnd = timeSlot[1],
|
||||||
|
timeslotId = eventStart.parseToMinutes(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add the new element to the temporary list
|
// Add the new element to the temporary list
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.denizk0461.studip.db
|
package com.denizk0461.studip.db
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.room.Dao
|
import androidx.room.*
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.Query
|
|
||||||
import com.denizk0461.studip.model.*
|
import com.denizk0461.studip.model.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,13 +14,29 @@ interface AppDAO {
|
|||||||
/* --- Stud.IP schedule events --- */
|
/* --- Stud.IP schedule events --- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all Stud.IP events.
|
* Retrieves all Stud.IP events, ordered by their timeslots, then their IDs.
|
||||||
*
|
*
|
||||||
* @return all Stud.IP events exposed through a LiveData object
|
* @return all Stud.IP events exposed through a LiveData object
|
||||||
*/
|
*/
|
||||||
@get:Query("SELECT * FROM events ORDER BY id")
|
@get:Query("SELECT * FROM events ORDER BY timeslotId, id")
|
||||||
val allEvents: LiveData<List<StudIPEvent>>
|
val allEvents: LiveData<List<StudIPEvent>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a given Stud.IP element.
|
||||||
|
*
|
||||||
|
* @param event object to be updated
|
||||||
|
*/
|
||||||
|
@Update
|
||||||
|
fun update(event: StudIPEvent)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a given Stud.IP element.
|
||||||
|
*
|
||||||
|
* @param event object to be updated
|
||||||
|
*/
|
||||||
|
@Delete
|
||||||
|
fun delete(event: StudIPEvent)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a Stud.IP event into the database.
|
* Inserts a Stud.IP event into the database.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import com.denizk0461.studip.model.*
|
|||||||
OfferCategory::class,
|
OfferCategory::class,
|
||||||
OfferItem::class
|
OfferItem::class
|
||||||
],
|
],
|
||||||
version = 12,
|
version = 13,
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,24 @@ class AppRepository(app: Application) {
|
|||||||
*/
|
*/
|
||||||
val allOffers: LiveData<List<CanteenOffer>> = dao.allOffers
|
val allOffers: LiveData<List<CanteenOffer>> = dao.allOffers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a schedule element.
|
||||||
|
*
|
||||||
|
* @param event the event to update
|
||||||
|
*/
|
||||||
|
fun update(event: StudIPEvent) {
|
||||||
|
dao.update(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a schedule element.
|
||||||
|
*
|
||||||
|
* @param event the event to delete
|
||||||
|
*/
|
||||||
|
fun delete(event: StudIPEvent) {
|
||||||
|
dao.delete(event)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all canteen offer date objects.
|
* Retrieves all canteen offer date objects.
|
||||||
*
|
*
|
||||||
@@ -147,18 +165,20 @@ class AppRepository(app: Application) {
|
|||||||
// --- settings preferences --- //
|
// --- settings preferences --- //
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the user's preference on displaying allergens.
|
* Retrieves ta user-set boolean preference.
|
||||||
*
|
*
|
||||||
* @return whether the user set this preference
|
* @param pref preference to retrieve
|
||||||
|
* @return whether the user set this preference
|
||||||
*/
|
*/
|
||||||
fun getPreferenceAllergen(): Boolean = prefs.getBoolean("setting_allergen", false)
|
fun getPreference(pref: SettingsPreferences): Boolean = prefs.getBoolean(pref.key, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the user's preference on displaying allergens.
|
* Updates a user-set boolean preference.
|
||||||
*
|
*
|
||||||
* @param value new value to set the preference to
|
* @param pref preference to set
|
||||||
|
* @param newValue new value to set the preference to
|
||||||
*/
|
*/
|
||||||
fun setPreferenceAllergen(value: Boolean) {
|
fun setPreference(pref: SettingsPreferences, newValue: Boolean) {
|
||||||
prefs.edit().putBoolean("setting_allergen", value).apply()
|
prefs.edit().putBoolean(pref.key, newValue).apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.denizk0461.studip.dialog
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import android.app.TimePickerDialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.TimePicker
|
||||||
|
|
||||||
|
class TimePickerFragment(
|
||||||
|
private val timestamp: String,
|
||||||
|
private val listener: OnTimeSetListener,
|
||||||
|
private val isEventStart: Boolean,
|
||||||
|
) : DialogFragment(), TimePickerDialog.OnTimeSetListener {
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val timestampSplit = timestamp.split(":")
|
||||||
|
return TimePickerDialog(activity, this, timestampSplit[0].toInt(), timestampSplit[1].toInt(), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnTimeSetListener {
|
||||||
|
fun onTimeSet(hours: Int, minutes: Int, isEventStart: Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTimeSet(picker: TimePicker?, hours: Int, minutes: Int) {
|
||||||
|
listener.onTimeSet(hours, minutes, isEventStart)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import com.denizk0461.studip.adapter.StudIPEventItemAdapter
|
|||||||
import com.denizk0461.studip.adapter.StudIPEventPageAdapter
|
import com.denizk0461.studip.adapter.StudIPEventPageAdapter
|
||||||
import com.denizk0461.studip.databinding.FragmentEventBinding
|
import com.denizk0461.studip.databinding.FragmentEventBinding
|
||||||
import com.denizk0461.studip.model.StudIPEvent
|
import com.denizk0461.studip.model.StudIPEvent
|
||||||
|
import com.denizk0461.studip.sheet.ScheduleUpdateSheet
|
||||||
|
import com.denizk0461.studip.sheet.TextSheet
|
||||||
import com.denizk0461.studip.viewmodel.EventViewModel
|
import com.denizk0461.studip.viewmodel.EventViewModel
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -73,8 +75,13 @@ class EventFragment : AppFragment() {
|
|||||||
// TODO implement functionality or delete
|
// TODO implement functionality or delete
|
||||||
}
|
}
|
||||||
override fun onLongClick(event: StudIPEvent): Boolean {
|
override fun onLongClick(event: StudIPEvent): Boolean {
|
||||||
// TODO implement functionality or delete
|
// Open a bottom sheet to edit the event
|
||||||
return false
|
openBottomSheet(ScheduleUpdateSheet(event, onUpdate = { eventToUpdate ->
|
||||||
|
viewModel.update(eventToUpdate)
|
||||||
|
}, onDelete = { eventToDelete ->
|
||||||
|
viewModel.delete(eventToDelete)
|
||||||
|
}))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -52,13 +52,31 @@ class SettingsFragment : AppFragment() {
|
|||||||
launchWebView()
|
launchWebView()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.switchAllergens.apply {
|
// Set up switch for highlighting the next course in the schedule
|
||||||
isChecked = viewModel.preferenceAllergen
|
binding.switchHighlight.apply {
|
||||||
setOnCheckedChangeListener { _, b ->
|
isChecked = viewModel.preferenceCourseHighlighting
|
||||||
viewModel.preferenceAllergen = b
|
setOnCheckedChangeListener { _, newValue ->
|
||||||
|
viewModel.preferenceCourseHighlighting = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up switch for displaying allergens
|
||||||
|
binding.switchAllergens.apply {
|
||||||
|
isChecked = viewModel.preferenceAllergen
|
||||||
|
setOnCheckedChangeListener { _, newValue ->
|
||||||
|
viewModel.preferenceAllergen = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up switch for crash report opt-in
|
||||||
|
binding.switchCrashlytics.apply {
|
||||||
|
isChecked = viewModel.preferenceDataHandling
|
||||||
|
setOnCheckedChangeListener { _, newValue ->
|
||||||
|
viewModel.preferenceDataHandling = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set click listener for the data handling dialogue
|
||||||
binding.buttonDataHandling.setOnClickListener {
|
binding.buttonDataHandling.setOnClickListener {
|
||||||
openBottomSheet(TextSheet(
|
openBottomSheet(TextSheet(
|
||||||
R.string.settings_data_sheet_header,
|
R.string.settings_data_sheet_header,
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.denizk0461.studip.model
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration class for user-set preferences that will be saved in persistent storage via
|
||||||
|
* SharedPreferences.
|
||||||
|
*
|
||||||
|
* @param key key for the SharedPreferences transaction
|
||||||
|
*/
|
||||||
|
enum class SettingsPreferences(val key: String) {
|
||||||
|
// Whether the user wants to have allergens displayed in the canteen overview
|
||||||
|
ALLERGEN("setting_allergen"),
|
||||||
|
// Whether the user wants the next course in his schedule to be highlighted
|
||||||
|
COURSE_HIGHLIGHTING("setting_highlight"),
|
||||||
|
// Whether the user opts into sending crash report
|
||||||
|
DATA_HANDLING("setting_data_handling"),
|
||||||
|
;
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import androidx.room.PrimaryKey
|
|||||||
* @param day day the event takes place on; 0 = Monday, 4 = Friday
|
* @param day day the event takes place on; 0 = Monday, 4 = Friday
|
||||||
* @param timeslotStart time the event starts at
|
* @param timeslotStart time the event starts at
|
||||||
* @param timeslotEnd time the event ends at
|
* @param timeslotEnd time the event ends at
|
||||||
|
* @param timeslotId minute the event starts at - used for ordering
|
||||||
* @param colour user-defined colour the event will be shown in - UNIMPLEMENTED
|
* @param colour user-defined colour the event will be shown in - UNIMPLEMENTED
|
||||||
*/
|
*/
|
||||||
@Entity(tableName = "events")
|
@Entity(tableName = "events")
|
||||||
@@ -24,6 +25,7 @@ data class StudIPEvent(
|
|||||||
val day: Int,
|
val day: Int,
|
||||||
val timeslotStart: String,
|
val timeslotStart: String,
|
||||||
val timeslotEnd: String,
|
val timeslotEnd: String,
|
||||||
|
val timeslotId: Int,
|
||||||
val colour: Int = 0,
|
val colour: Int = 0,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class AllergenSheet(
|
|||||||
private val category: String,
|
private val category: String,
|
||||||
) : AppSheet(R.layout.sheet_allergen) {
|
) : AppSheet(R.layout.sheet_allergen) {
|
||||||
|
|
||||||
|
// View binding
|
||||||
private val binding: SheetAllergenBinding by viewBinding(SheetAllergenBinding::bind)
|
private val binding: SheetAllergenBinding by viewBinding(SheetAllergenBinding::bind)
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.denizk0461.studip.sheet
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import com.denizk0461.studip.R
|
||||||
|
import com.denizk0461.studip.data.parseToMinutes
|
||||||
|
import com.denizk0461.studip.data.viewBinding
|
||||||
|
import com.denizk0461.studip.databinding.SheetScheduleUpdateBinding
|
||||||
|
import com.denizk0461.studip.dialog.TimePickerFragment
|
||||||
|
import com.denizk0461.studip.model.StudIPEvent
|
||||||
|
|
||||||
|
class ScheduleUpdateSheet(
|
||||||
|
private val event: StudIPEvent,
|
||||||
|
private val onUpdate: (event: StudIPEvent) -> Unit,
|
||||||
|
private val onDelete: (event: StudIPEvent) -> Unit,
|
||||||
|
) : AppSheet(R.layout.sheet_schedule_update), TimePickerFragment.OnTimeSetListener {
|
||||||
|
|
||||||
|
// Editable fields
|
||||||
|
private var timeslotStart = event.timeslotStart
|
||||||
|
private var timeslotEnd = event.timeslotEnd
|
||||||
|
private var colour = event.colour
|
||||||
|
|
||||||
|
// View binding
|
||||||
|
private val binding: SheetScheduleUpdateBinding by viewBinding(SheetScheduleUpdateBinding::bind)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
binding.apply {
|
||||||
|
editTextTitle.setText(event.title)
|
||||||
|
editTextLecturers.setText(event.lecturer)
|
||||||
|
editTextRoom.setText(event.room)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.buttonDelete.setOnClickListener {
|
||||||
|
onDelete(event)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.buttonSave.setOnClickListener {
|
||||||
|
onUpdate(
|
||||||
|
StudIPEvent(
|
||||||
|
id = event.id,
|
||||||
|
title = binding.editTextTitle.text.toString(),
|
||||||
|
lecturer = binding.editTextLecturers.text.toString(),
|
||||||
|
room = binding.editTextRoom.text.toString(),
|
||||||
|
day = event.day,
|
||||||
|
timeslotStart = timeslotStart,
|
||||||
|
timeslotEnd = timeslotEnd,
|
||||||
|
timeslotId = timeslotStart.parseToMinutes(),
|
||||||
|
colour = colour,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
override fun onTimeSet(hours: Int, minutes: Int, isEventStart: Boolean) {
|
||||||
|
if (isEventStart) {
|
||||||
|
timeslotStart = "$hours:$minutes"
|
||||||
|
} else {
|
||||||
|
timeslotEnd = "$hours:$minutes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,11 +18,13 @@ class TextSheet(
|
|||||||
@StringRes private val content: Int
|
@StringRes private val content: Int
|
||||||
) : AppSheet(R.layout.sheet_text) {
|
) : AppSheet(R.layout.sheet_text) {
|
||||||
|
|
||||||
|
// View binding
|
||||||
private val binding: SheetTextBinding by viewBinding(SheetTextBinding::bind)
|
private val binding: SheetTextBinding by viewBinding(SheetTextBinding::bind)
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
// Set text values
|
||||||
binding.apply {
|
binding.apply {
|
||||||
textHeader.text = getString(header)
|
textHeader.text = getString(header)
|
||||||
textContent.text = getString(content)
|
textContent.text = getString(content)
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package com.denizk0461.studip.viewmodel
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import com.denizk0461.studip.data.StwParser
|
import com.denizk0461.studip.data.StwParser
|
||||||
import com.denizk0461.studip.model.CanteenOffer
|
import com.denizk0461.studip.model.*
|
||||||
import com.denizk0461.studip.model.DietaryPrefObject
|
|
||||||
import com.denizk0461.studip.model.DietaryPreferences
|
|
||||||
import com.denizk0461.studip.model.OfferDate
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View model for [com.denizk0461.studip.fragment.CanteenFragment]
|
* View model for [com.denizk0461.studip.fragment.CanteenFragment]
|
||||||
@@ -66,5 +63,5 @@ class CanteenViewModel(app: Application) : AppViewModel(app) {
|
|||||||
* This value determines whether the user wants to have allergens marked.
|
* This value determines whether the user wants to have allergens marked.
|
||||||
*/
|
*/
|
||||||
val preferenceAllergen: Boolean
|
val preferenceAllergen: Boolean
|
||||||
get() = repo.getPreferenceAllergen()
|
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
|
||||||
}
|
}
|
||||||
@@ -17,4 +17,18 @@ class EventViewModel(app: Application) : AppViewModel(app) {
|
|||||||
* @return all Stud.IP events exposed through a LiveData object
|
* @return all Stud.IP events exposed through a LiveData object
|
||||||
*/
|
*/
|
||||||
val allEvents: LiveData<List<StudIPEvent>> = repo.allEvents
|
val allEvents: LiveData<List<StudIPEvent>> = repo.allEvents
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a schedule element.
|
||||||
|
*
|
||||||
|
* @param event the event to update
|
||||||
|
*/
|
||||||
|
fun update(event: StudIPEvent) { doAsync { repo.update(event) } }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a schedule element.
|
||||||
|
*
|
||||||
|
* @param event the event to delete
|
||||||
|
*/
|
||||||
|
fun delete(event: StudIPEvent) { doAsync { repo.delete(event) } }
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.denizk0461.studip.viewmodel
|
package com.denizk0461.studip.viewmodel
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import com.denizk0461.studip.model.SettingsPreferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View model for [com.denizk0461.studip.fragment.SettingsFragment]
|
* View model for [com.denizk0461.studip.fragment.SettingsFragment]
|
||||||
@@ -9,10 +10,24 @@ import android.app.Application
|
|||||||
*/
|
*/
|
||||||
class SettingsViewModel(app: Application) : AppViewModel(app) {
|
class SettingsViewModel(app: Application) : AppViewModel(app) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value determines whether the user opts into submitting crash reports.
|
||||||
|
*/
|
||||||
|
var preferenceCourseHighlighting: Boolean
|
||||||
|
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
|
||||||
|
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This value determines whether the user wants to have allergens marked.
|
* This value determines whether the user wants to have allergens marked.
|
||||||
*/
|
*/
|
||||||
var preferenceAllergen: Boolean
|
var preferenceAllergen: Boolean
|
||||||
get() = repo.getPreferenceAllergen()
|
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
|
||||||
set(value) { repo.setPreferenceAllergen(value) }
|
set(newValue) { repo.setPreference(SettingsPreferences.ALLERGEN, newValue) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value determines whether the user opts into submitting crash reports.
|
||||||
|
*/
|
||||||
|
var preferenceDataHandling: Boolean
|
||||||
|
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
|
||||||
|
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
|
||||||
|
</vector>
|
||||||
@@ -4,11 +4,15 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
android:paddingHorizontal="24dp"
|
android:paddingHorizontal="24dp"
|
||||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_category"
|
android:id="@+id/text_category"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingHorizontal="24dp"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:fontFamily="@font/lato_blackitalic"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:text="@string/sheet_schedule_update_header"/>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:hint="@string/sheet_schedule_update_title_hint"
|
||||||
|
app:boxStrokeColor="@color/brightfuckingpink"
|
||||||
|
android:textColorHint="@color/brightfuckingpink">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_text_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/brightfuckingpink"/>
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
|
<!-- lecturers -->
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:scrollHorizontally="true"
|
||||||
|
android:hint="@string/sheet_schedule_update_lecturers_hint">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_text_lecturers"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"/>
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<!-- room -->
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:scrollHorizontally="true"
|
||||||
|
android:hint="@string/sheet_schedule_update_room_hint">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_text_room"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"/>
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="end">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_delete"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/delete"
|
||||||
|
app:icon="@drawable/delete"
|
||||||
|
android:layout_marginEnd="8dp"/>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_save"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save"
|
||||||
|
app:icon="@drawable/save"/>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
@@ -4,9 +4,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingTop="16dp"
|
|
||||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_header"
|
android:id="@+id/text_header"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Stud.IP Timetable</string>
|
<string name="app_name">Stud.IP Timetable</string>
|
||||||
|
|
||||||
<string name="monday">MONTAG</string>
|
<string name="monday">Montag</string>
|
||||||
<string name="tuesday">DIENSTAG</string>
|
<string name="tuesday">Dienstag</string>
|
||||||
<string name="wednesday">MITTWOCH</string>
|
<string name="wednesday">Mittwoch</string>
|
||||||
<string name="thursday">DONNERSTAG</string>
|
<string name="thursday">Donnerstag</string>
|
||||||
<string name="friday">FREITAG</string>
|
<string name="friday">Freitag</string>
|
||||||
|
<string name="saturday">Samstag</string>
|
||||||
|
<string name="sunday">Sonntag</string>
|
||||||
|
|
||||||
|
<string name="save">Speichern</string>
|
||||||
|
<string name="delete">Löschen</string>
|
||||||
|
<string name="sheet_schedule_update_header">Veranstaltung bearbeiten</string>
|
||||||
|
<string name="sheet_schedule_update_title_hint">Veranstaltungstitel</string>
|
||||||
|
<string name="sheet_schedule_update_lecturers_hint">Dozierende(r)</string>
|
||||||
|
<string name="sheet_schedule_update_room_hint">Raum</string>
|
||||||
|
|
||||||
<string name="title_schedule">Dein Stundenplan</string>
|
<string name="title_schedule">Dein Stundenplan</string>
|
||||||
<string name="title_food">Mensenangebote</string>
|
<string name="title_food">Mensenangebote</string>
|
||||||
@@ -100,7 +109,7 @@
|
|||||||
<string name="settings_quarter_title">Nutze akademisches Viertel</string>
|
<string name="settings_quarter_title">Nutze akademisches Viertel</string>
|
||||||
<string name="settings_quarter_subtitle">Wo es passt</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_title">Markiere Angebote mit Allergenen mit einem Stern*</string>
|
||||||
<string name="settings_allergens_subtitle">Wird auch für Zusatzstoffe genutzt</string>
|
<string name="settings_allergens_subtitle">Wird auch für Zusatzstoffe genutzt</string>
|
||||||
|
|
||||||
<string name="settings_crashlytics_title">Stimme Sammlung von Absturzreporten zu</string>
|
<string name="settings_crashlytics_title">Stimme Sammlung von Absturzreporten zu</string>
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Stud.IP Timetable</string>
|
<string name="app_name">Stud.IP Timetable</string>
|
||||||
|
|
||||||
<string name="monday">MONDAY</string>
|
<string name="monday">Monday</string>
|
||||||
<string name="tuesday">TUESDAY</string>
|
<string name="tuesday">Tuesday</string>
|
||||||
<string name="wednesday">WEDNESDAY</string>
|
<string name="wednesday">Wednesday</string>
|
||||||
<string name="thursday">THURSDAY</string>
|
<string name="thursday">Thursday</string>
|
||||||
<string name="friday">FRIDAY</string>
|
<string name="friday">Friday</string>
|
||||||
|
<string name="saturday">Saturday</string>
|
||||||
|
<string name="sunday">Sunday</string>
|
||||||
|
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="delete">Delete</string>
|
||||||
|
<string name="sheet_schedule_update_header">Edit Event</string>
|
||||||
|
<string name="sheet_schedule_update_title_hint">Event title</string>
|
||||||
|
<string name="sheet_schedule_update_lecturers_hint">Lecturer(s)</string>
|
||||||
|
<string name="sheet_schedule_update_room_hint">Room</string>
|
||||||
|
|
||||||
<string name="title_schedule">Your Schedule</string>
|
<string name="title_schedule">Your Schedule</string>
|
||||||
<string name="title_food">Canteen Offers</string>
|
<string name="title_food">Canteen Offers</string>
|
||||||
@@ -97,12 +106,12 @@
|
|||||||
<string name="refresh_schedule_subtitle">This will clear any customisations!</string>
|
<string name="refresh_schedule_subtitle">This will clear any customisations!</string>
|
||||||
|
|
||||||
<string name="settings_highlight_title">Highlight next course</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_highlight_subtitle">Only works properly if courses don\'t overlap!\nNOTE: Currently broken!</string>
|
||||||
|
|
||||||
<string name="settings_quarter_title">Use academic quarter</string>
|
<string name="settings_quarter_title">Use academic quarter</string>
|
||||||
<string name="settings_quarter_subtitle">Where applicable</string>
|
<string name="settings_quarter_subtitle">Where applicable</string>
|
||||||
|
|
||||||
<string name="settings_allergens_title">Mark allergens with a star*</string>
|
<string name="settings_allergens_title">Mark offers with allergens with a star*</string>
|
||||||
<string name="settings_allergens_subtitle">Also applies to additives</string>
|
<string name="settings_allergens_subtitle">Also applies to additives</string>
|
||||||
|
|
||||||
<string name="settings_crashlytics_title">Opt-in to sharing crash data</string>
|
<string name="settings_crashlytics_title">Opt-in to sharing crash data</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user