Archived
Tweaks to the timetable/schedule feature so that it works properly now:
- adding events without any schedules present is prohibited - events are now properly assigned to the currently active schedule - changed top bar text in schedule fragment - changed order of headers in allergen detail sheet
This commit is contained in:
Generated
-17
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="RF8R50XDV6F" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-07-31T20:39:47.926002300Z" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -87,6 +87,9 @@ interface AppDAO {
|
||||
@Query("SELECT * FROM timetables ORDER BY id")
|
||||
fun getTimetables(): LiveData<List<Timetable>>
|
||||
|
||||
@Query("SELECT COUNT(*) FROM timetables")
|
||||
fun getTimetableCount(): Int
|
||||
|
||||
@Query("SELECT * FROM timetables WHERE id = :id LIMIT 1")
|
||||
fun getTimetableForId(id: Int): Timetable
|
||||
|
||||
|
||||
@@ -178,6 +178,8 @@ class AppRepository(app: Application) {
|
||||
|
||||
fun getTimetables(): LiveData<List<Timetable>> = dao.getTimetables()
|
||||
|
||||
fun getTimetableCount(): Int = dao.getTimetableCount()
|
||||
|
||||
fun getTimetableForId(id: Int): Timetable = dao.getTimetableForId(id)
|
||||
|
||||
fun deleteTimetable(id: Int) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.denizk0461.weserplaner.activity.FetcherActivity
|
||||
import com.denizk0461.weserplaner.activity.TimetableOverviewActivity
|
||||
import com.denizk0461.weserplaner.adapter.StudIPEventPageAdapter
|
||||
import com.denizk0461.weserplaner.data.getTextSheet
|
||||
import com.denizk0461.weserplaner.data.showErrorSnackBar
|
||||
import com.denizk0461.weserplaner.data.showSnackBar
|
||||
import com.denizk0461.weserplaner.databinding.FragmentEventBinding
|
||||
import com.denizk0461.weserplaner.sheet.ScheduleUpdateSheet
|
||||
@@ -35,6 +36,9 @@ class EventFragment : AppFragment<FragmentEventBinding>() {
|
||||
// Titles for the view pager's tabs
|
||||
private lateinit var weekdays: Array<String>
|
||||
|
||||
// Name of the currently selected schedule
|
||||
private lateinit var timetableName: String
|
||||
|
||||
// Instantiate the view binding
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = FragmentEventBinding.inflate(inflater, container, false)
|
||||
@@ -118,9 +122,9 @@ class EventFragment : AppFragment<FragmentEventBinding>() {
|
||||
// Set visibility of the fetch button depending on whether any events have been stored
|
||||
viewModel.getEventCount().observe(viewLifecycleOwner) { eventCount ->
|
||||
|
||||
val timetableName = viewModel.getSelectedTimetableName()
|
||||
timetableName = viewModel.getSelectedTimetableName()
|
||||
if (timetableName.isNotBlank()) {
|
||||
binding.appTitleBar.text = timetableName
|
||||
binding.appTitleBar.text = getString(R.string.title_schedule_placeholder, timetableName)
|
||||
}
|
||||
|
||||
binding.buttonFetchSchedule.visibility = if (eventCount == 0) {
|
||||
@@ -132,6 +136,14 @@ class EventFragment : AppFragment<FragmentEventBinding>() {
|
||||
|
||||
// Set up button for adding a new event
|
||||
binding.fabAddEvent.setOnClickListener {
|
||||
|
||||
if (viewModel.getTimetableCount() == 0) {
|
||||
context.theme.showErrorSnackBar(
|
||||
binding.coordinatorLayout,
|
||||
getString(R.string.sheet_schedule_update_no_timetable),
|
||||
)
|
||||
return@setOnClickListener
|
||||
}
|
||||
/*
|
||||
* Open the bottom sheet used for editing an event, but tell the sheet that it will be
|
||||
* used for creating a new event instead.
|
||||
|
||||
@@ -171,7 +171,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
|
||||
timetableId = viewModel.getCurrentTimetableId(),
|
||||
title = binding.editTextTitle.text.toString().trim(),
|
||||
lecturer = binding.editTextLecturers.text.toString().trim(),
|
||||
room = binding.editTextRoom.text.toString().trim(),
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.denizk0461.weserplaner.sheet
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import com.denizk0461.weserplaner.R
|
||||
@@ -38,6 +39,16 @@ class TimetableAddSheet : AppSheet(R.layout.sheet_timetable_add) {
|
||||
}
|
||||
|
||||
binding.buttonSave.setOnClickListener {
|
||||
|
||||
if (binding.editTextTitle.text.toString().isBlank()) {
|
||||
// Set an error on the title field
|
||||
binding.textLayoutTitle.error =
|
||||
getString(R.string.sheet_schedule_update_text_field_empty_error)
|
||||
|
||||
// action must not be executed
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
viewModel.insertTimetable(Timetable(name = binding.editTextTitle.text.toString().trim()))
|
||||
|
||||
// Tell the user that the event has been updated
|
||||
@@ -47,5 +58,9 @@ class TimetableAddSheet : AppSheet(R.layout.sheet_timetable_add) {
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
||||
binding.editTextTitle.addTextChangedListener {
|
||||
binding.textLayoutTitle.error = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ class EventViewModel(private val app: Application) : AppViewModel(app) {
|
||||
}
|
||||
}
|
||||
|
||||
fun getTimetableCount(): Int = returnBlocking { repo.getTimetableCount() }
|
||||
|
||||
/**
|
||||
* This value determines whether the user wants their timetable to launch with the current day.
|
||||
*/
|
||||
|
||||
@@ -18,4 +18,6 @@ class ScheduleUpdateViewModel(application: Application) : AppViewModel(applicati
|
||||
* @param event the event to update
|
||||
*/
|
||||
fun update(event: StudIPEvent) { doAsync { repo.update(event) } }
|
||||
|
||||
fun getCurrentTimetableId(): Int = repo.getPreferenceSelectedTimetable()
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -31,22 +32,24 @@
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/text_category"
|
||||
android:id="@+id/text_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="22sp"
|
||||
app:fontFamily="@font/lato_blackitalic"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:layout_marginBottom="2dp"/>
|
||||
android:layout_marginBottom="2dp"
|
||||
tools:text="Some kind of meal with extras I guess"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/text_title"
|
||||
android:id="@+id/text_category"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="22sp"
|
||||
android:textSize="18sp"
|
||||
app:fontFamily="@font/lato_bolditalic"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:paddingHorizontal="24dp"/>
|
||||
android:paddingHorizontal="24dp"
|
||||
tools:text="[Category]"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -39,10 +39,22 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
app:fontFamily="@font/lato_blackitalic"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/button_cancel"/>
|
||||
|
||||
<!-- <androidx.appcompat.widget.AppCompatTextView-->
|
||||
<!-- android:id="@+id/sheet_subtitle"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:textSize="16sp"-->
|
||||
<!-- android:paddingHorizontal="24dp"-->
|
||||
<!-- android:layout_marginBottom="8dp"-->
|
||||
<!-- app:fontFamily="@font/lato_bolditalic"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/sheet_title"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toStartOf="@id/button_cancel"/>-->
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -94,9 +94,11 @@
|
||||
<string name="sheet_schedule_snack_update">Veranstaltung wurde aktualisiert.</string>
|
||||
<string name="sheet_schedule_update_header_edit">Bestehende Veranstaltung bearbeiten</string>
|
||||
<string name="sheet_schedule_update_header_add">Neue Veranstaltung hinzufügen</string>
|
||||
<string name="sheet_schedule_update_subheader_add">Stundenplan: %s</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="sheet_schedule_update_no_timetable">Du musst einen Stundenplan erstellen, bevor du Veranstaltungen hinzufügst!</string>
|
||||
<string name="sheet_schedule_update_hint_quarter">Auf akademisches Viertel umstellen</string>
|
||||
<string name="sheet_schedule_update_hint_quarter_error">Sorry, ein Fehler ist aufgetreten!</string>
|
||||
<string name="sheet_schedule_update_timestamp_error_mixed">Der Kurs kann nicht enden bevor er aufhört.</string>
|
||||
@@ -145,6 +147,7 @@
|
||||
|
||||
<string name="title_schedule">Dein Stundenplan</string>
|
||||
<string name="title_schedule_short">Stundenplan</string>
|
||||
<string name="title_schedule_placeholder">Stundenplan: %s</string>
|
||||
<string name="title_exam_overview">Aufgaben & Prüfungen</string>
|
||||
<string name="title_exam_overview_short">Aufgaben</string>
|
||||
<string name="title_canteen">Mensenangebote</string>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<string name="introduction_button_continue">Continue to the app</string>
|
||||
|
||||
<string name="compact_overview_button_settings_hint">App settings</string>
|
||||
<string name="compact_overview_button_events_hint">Timetable</string>
|
||||
<string name="compact_overview_button_events_hint">Schedule</string>
|
||||
<string name="compact_overview_button_refresh_offers_hint">Refresh offers</string>
|
||||
<string name="compact_overview_button_offers_hint">All offers</string>
|
||||
<string name="compact_overview_header_events">Today\'s events</string>
|
||||
@@ -67,9 +67,9 @@
|
||||
<string name="fetch_bar_help_desc">Show help</string>
|
||||
<string name="fetch_bar_schedule_title">Schedule</string>
|
||||
<string name="fetch_bar_schedule_desc">Go to your schedule</string>
|
||||
<string name="fetch_bar_help_sheet_title">How to save your timetable in the app</string>
|
||||
<string name="fetch_bar_help_sheet_content"> • Log in with your Stud.IP login\n • Open your timetable view, in case it doesn\'t open automatically, by clicking the rightmost icon in the bottom bar that looks like a pencil and a ruler\n • Click the \'save\' button that appears in the bottom right corner\n • Done!</string>
|
||||
<string name="fetch_bar_save_desc">Save the timetable in the app</string>
|
||||
<string name="fetch_bar_help_sheet_title">How to save your schedule in the app</string>
|
||||
<string name="fetch_bar_help_sheet_content"> • Log in with your Stud.IP login\n • Open your schedule view, in case it doesn\'t open automatically, by clicking the rightmost icon in the bottom bar that looks like a pencil and a ruler\n • Click the \'save\' button that appears in the bottom right corner\n • Done!</string>
|
||||
<string name="fetch_bar_save_desc">Save the schedule in the app</string>
|
||||
|
||||
<string name="schedule_button_overview_hint">View full schedule</string>
|
||||
<string name="schedule_fab_add_text">New event</string>
|
||||
@@ -95,10 +95,12 @@
|
||||
<string name="sheet_schedule_snack_update">Event has been updated.</string>
|
||||
<string name="sheet_schedule_update_header_edit">Edit existing event</string>
|
||||
<string name="sheet_schedule_update_header_add">Add new event</string>
|
||||
<string name="sheet_schedule_update_subheader_add">Schedule: %s</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="sheet_schedule_update_timeslot_middle" translatable="false">–</string>
|
||||
<string name="sheet_schedule_update_no_timetable">You must create a schedule before you add events!</string>
|
||||
<string name="sheet_schedule_update_hint_quarter">Change to academic quarter</string>
|
||||
<string name="sheet_schedule_update_hint_quarter_error">Sorry, an error occurred!</string>
|
||||
<string name="sheet_schedule_update_timestamp_error_mixed">The course cannot end before it begins.</string>
|
||||
@@ -148,6 +150,7 @@
|
||||
|
||||
<string name="title_schedule">Your Schedule</string>
|
||||
<string name="title_schedule_short">Schedule</string>
|
||||
<string name="title_schedule_placeholder">Schedule: %s</string>
|
||||
<string name="title_exam_overview">Tasks & Exams</string>
|
||||
<string name="title_exam_overview_short">Tasks</string>
|
||||
<string name="title_canteen">Canteen Offers</string>
|
||||
@@ -243,7 +246,7 @@
|
||||
<string name="nav_settings">Settings</string>
|
||||
|
||||
<string name="new_feature_timetables_header">Heads up, new feature!</string>
|
||||
<string name="new_feature_timetables_content">As the new semester will start in a couple of weeks, you can prepare in advance by adding your new timetable! You can now add as many timetables to the app as you like.\n\nHead into the settings to find the new \'timetables\' option!</string>
|
||||
<string name="new_feature_timetables_content">As the new semester will start in a couple of weeks, you can prepare in advance by adding your new schedule! You can now add as many schedules to the app as you like.\n\nHead into the settings to find the new \'schedules\' option!</string>
|
||||
|
||||
<string name="settings_general">General</string>
|
||||
<string name="settings_schedule">Stud.IP Schedule</string>
|
||||
@@ -254,22 +257,22 @@
|
||||
<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_selected_timetable_header">Select which timetable to display</string>
|
||||
<string name="settings_selected_timetable_hint">Timetable</string>
|
||||
<string name="settings_selected_timetable_edit_button_hint">Edit timetable</string>
|
||||
<string name="settings_selected_timetable_edit_text_title">Timetable name</string>
|
||||
<string name="settings_selected_timetable_header">Select which schedule to display</string>
|
||||
<string name="settings_selected_timetable_hint">Schedule</string>
|
||||
<string name="settings_selected_timetable_edit_button_hint">Edit schedule</string>
|
||||
<string name="settings_selected_timetable_edit_text_title">Schedule name</string>
|
||||
<string name="settings_timetable_button_add">Add</string>
|
||||
<string name="settings_timetable_button_edit">Edit</string>
|
||||
<string name="settings_timetable_sheet_header">Edit this timetable</string>
|
||||
<string name="settings_timetable_sheet_header_add">Add a new timetable</string>
|
||||
<string name="settings_timetable_edit_fail">There is no timetable to edit!</string>
|
||||
<string name="settings_timetable_sheet_confirm_save">Timetable has been updated.</string>
|
||||
<string name="settings_timetable_sheet_confirm_add">Timetable has been added.</string>
|
||||
<string name="settings_timetable_sheet_confirm_delete">Timetable has been deleted.</string>
|
||||
<string name="settings_timetable_sheet_header">Edit this schedule</string>
|
||||
<string name="settings_timetable_sheet_header_add">Add a new schedule</string>
|
||||
<string name="settings_timetable_edit_fail">There is no schedule to edit!</string>
|
||||
<string name="settings_timetable_sheet_confirm_save">Schedule has been updated.</string>
|
||||
<string name="settings_timetable_sheet_confirm_add">Schedule has been added.</string>
|
||||
<string name="settings_timetable_sheet_confirm_delete">Schedule has been deleted.</string>
|
||||
<string name="settings_timetable_sheet_delete_confirm">Sure?</string>
|
||||
<string name="settings_timetable_add_hint">Hint: if you download a timetable from Stud.IP, it automatically gets added as a new timetable, so you won\'t need to do anything here!</string>
|
||||
<string name="settings_timetable_add_hint">Hint: if you download a schedule from Stud.IP, it automatically gets added as a new schedule, so you won\'t need to do anything here!</string>
|
||||
|
||||
<string name="settings_current_day_title">Launch timetable on current day</string>
|
||||
<string name="settings_current_day_title">Launch schedule on current day</string>
|
||||
<string name="settings_current_day_subtitle">If unselected, Monday will be shown on launch instead</string>
|
||||
|
||||
<string name="settings_highlight_title">Highlight next course</string>
|
||||
|
||||
Reference in New Issue
Block a user