diff --git a/app/src/main/java/com/denizk0461/studip/sheet/ScheduleUpdateSheet.kt b/app/src/main/java/com/denizk0461/studip/sheet/ScheduleUpdateSheet.kt index 1d13386..fee7af4 100644 --- a/app/src/main/java/com/denizk0461/studip/sheet/ScheduleUpdateSheet.kt +++ b/app/src/main/java/com/denizk0461/studip/sheet/ScheduleUpdateSheet.kt @@ -2,6 +2,8 @@ package com.denizk0461.studip.sheet import android.os.Bundle import android.view.View +import android.widget.TimePicker +import androidx.fragment.app.FragmentActivity import com.denizk0461.studip.R import com.denizk0461.studip.data.parseToMinutes import com.denizk0461.studip.data.viewBinding @@ -26,10 +28,17 @@ class ScheduleUpdateSheet( 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.editTextTitle.setText(event.title) + binding.editTextLecturers.setText(event.lecturer) + binding.editTextRoom.setText(event.room) + + binding.buttonTimeStart.text = timeslotStart + binding.buttonTimeStart.setOnClickListener { + TimePickerFragment(binding.buttonTimeStart.text.toString(), this, true).show((context as FragmentActivity).supportFragmentManager, "timePicker") + } + binding.buttonTimeEnd.text = timeslotEnd + binding.buttonTimeEnd.setOnClickListener { + TimePickerFragment(binding.buttonTimeEnd.text.toString(), this, false).show((context as FragmentActivity).supportFragmentManager, "timePicker") } binding.buttonDelete.setOnClickListener { @@ -59,10 +68,21 @@ class ScheduleUpdateSheet( * */ override fun onTimeSet(hours: Int, minutes: Int, isEventStart: Boolean) { - if (isEventStart) { - timeslotStart = "$hours:$minutes" + + val newTimestamp = "$hours:$minutes" + + if ((isEventStart && newTimestamp.parseToMinutes() > timeslotEnd.parseToMinutes()) || + (!isEventStart && newTimestamp.parseToMinutes() < timeslotStart.parseToMinutes())) { + // tell user that the timestamp must be set earlier/later } else { - timeslotEnd = "$hours:$minutes" + + if (isEventStart) { + timeslotStart = newTimestamp + binding.buttonTimeStart.text = newTimestamp + } else { + timeslotEnd = newTimestamp + binding.buttonTimeEnd.text = newTimestamp + } } } } \ No newline at end of file diff --git a/app/src/main/res/color/selector_text_input.xml b/app/src/main/res/color/selector_text_input.xml new file mode 100644 index 0000000..a264cb5 --- /dev/null +++ b/app/src/main/res/color/selector_text_input.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/sheet_schedule_update.xml b/app/src/main/res/layout/sheet_schedule_update.xml index 913ee08..c418aa9 100644 --- a/app/src/main/res/layout/sheet_schedule_update.xml +++ b/app/src/main/res/layout/sheet_schedule_update.xml @@ -27,14 +27,15 @@ 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"> + app:boxStrokeColor="@color/selector_text_input" + app:hintTextColor="@color/selector_text_input"> + android:layout_height="wrap_content"/> @@ -54,9 +55,13 @@ android:layout_marginEnd="4dp" android:maxLines="1" android:scrollHorizontally="true" - android:hint="@string/sheet_schedule_update_lecturers_hint"> + android:hint="@string/sheet_schedule_update_lecturers_hint" + app:boxStrokeColor="@color/selector_text_input" + app:hintTextColor="@color/selector_text_input"> + android:hint="@string/sheet_schedule_update_room_hint" + app:boxStrokeColor="@color/selector_text_input" + app:hintTextColor="@color/selector_text_input"> + + + + + + + + + + @color/md_theme_dark_onSurfaceVariant @color/md_theme_dark_onSurfaceVariant + @color/md_theme_dark_outlineVariant @color/md_theme_light_background diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index f2387da..3256fe9 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,4 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5c9d81..f1d1c15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,6 +15,7 @@ Event title Lecturer(s) Room + Your Schedule Canteen Offers diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 662f485..336c40c 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -30,6 +30,7 @@ @color/md_theme_light_onSurfaceVariant @color/md_theme_light_onSurfaceVariant + @color/md_theme_light_outlineVariant @color/md_theme_dark_background