Finished style for schedule update bottom sheet (I think); implemented time picker, TODO: warn user if time span is invalid (start > end)

This commit is contained in:
denizk0461
2023-04-25 10:24:15 +02:00
parent 9b6e267cb0
commit 96862497e4
7 changed files with 82 additions and 13 deletions
@@ -2,6 +2,8 @@ package com.denizk0461.studip.sheet
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.TimePicker
import androidx.fragment.app.FragmentActivity
import com.denizk0461.studip.R import com.denizk0461.studip.R
import com.denizk0461.studip.data.parseToMinutes import com.denizk0461.studip.data.parseToMinutes
import com.denizk0461.studip.data.viewBinding import com.denizk0461.studip.data.viewBinding
@@ -26,10 +28,17 @@ class ScheduleUpdateSheet(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.apply { binding.editTextTitle.setText(event.title)
editTextTitle.setText(event.title) binding.editTextLecturers.setText(event.lecturer)
editTextLecturers.setText(event.lecturer) binding.editTextRoom.setText(event.room)
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 { binding.buttonDelete.setOnClickListener {
@@ -59,10 +68,21 @@ class ScheduleUpdateSheet(
* *
*/ */
override fun onTimeSet(hours: Int, minutes: Int, isEventStart: Boolean) { 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 { } else {
timeslotEnd = "$hours:$minutes"
if (isEventStart) {
timeslotStart = newTimestamp
binding.buttonTimeStart.text = newTimestamp
} else {
timeslotEnd = newTimestamp
binding.buttonTimeEnd.text = newTimestamp
}
} }
} }
} }
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorOnSurfaceVariant" android:state_focused="true"/>
<item android:color="?attr/colorOutlineVariant"/>
</selector>
@@ -27,14 +27,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:hint="@string/sheet_schedule_update_title_hint" android:hint="@string/sheet_schedule_update_title_hint"
app:boxStrokeColor="@color/brightfuckingpink" app:boxStrokeColor="@color/selector_text_input"
android:textColorHint="@color/brightfuckingpink"> app:hintTextColor="@color/selector_text_input">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:textColor="?attr/colorOnSurfaceVariant"
android:id="@+id/edit_text_title" android:id="@+id/edit_text_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"/>
android:textColor="@color/brightfuckingpink"/>
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
@@ -54,9 +55,13 @@
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:maxLines="1" android:maxLines="1"
android:scrollHorizontally="true" 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">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:textColor="?attr/colorOnSurfaceVariant"
android:id="@+id/edit_text_lecturers" android:id="@+id/edit_text_lecturers"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -73,9 +78,13 @@
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:maxLines="1" android:maxLines="1"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:hint="@string/sheet_schedule_update_room_hint"> android:hint="@string/sheet_schedule_update_room_hint"
app:boxStrokeColor="@color/selector_text_input"
app:hintTextColor="@color/selector_text_input">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:textColor="?attr/colorOnSurfaceVariant"
android:id="@+id/edit_text_room" android:id="@+id/edit_text_room"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -85,6 +94,36 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp">
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.OutlinedButton"
android:id="@+id/button_time_start"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:strokeColor="?attr/colorOutlineVariant"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sheet_schedule_update_timeslot_middle"
android:layout_marginHorizontal="8dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.OutlinedButton"
android:id="@+id/button_time_end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:strokeColor="?attr/colorOutlineVariant"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
+1
View File
@@ -30,6 +30,7 @@
<item name="android:textColor">@color/md_theme_dark_onSurfaceVariant</item> <item name="android:textColor">@color/md_theme_dark_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_dark_onSurfaceVariant</item> <item name="android:scrollbarThumbVertical">@color/md_theme_dark_onSurfaceVariant</item>
<item name="colorOutlineVariant">@color/md_theme_dark_outlineVariant</item>
<!-- is this correct? --> <!-- is this correct? -->
<item name="scheduleColorDefault">@color/md_theme_light_background</item> <item name="scheduleColorDefault">@color/md_theme_light_background</item>
+2
View File
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<attr name="scheduleColorDefault" type="color"/> <attr name="scheduleColorDefault" type="color"/>
<attr name="colorOutlineVariant" type="color"/>
<attr name="colorOnSurfaceVariant" type="color"/>
</resources> </resources>
+1
View File
@@ -15,6 +15,7 @@
<string name="sheet_schedule_update_title_hint">Event title</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_lecturers_hint">Lecturer(s)</string>
<string name="sheet_schedule_update_room_hint">Room</string> <string name="sheet_schedule_update_room_hint">Room</string>
<string name="sheet_schedule_update_timeslot_middle" translatable="false"></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>
+1
View File
@@ -30,6 +30,7 @@
<item name="android:textColor">@color/md_theme_light_onSurfaceVariant</item> <item name="android:textColor">@color/md_theme_light_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_light_onSurfaceVariant</item> <item name="android:scrollbarThumbVertical">@color/md_theme_light_onSurfaceVariant</item>
<item name="colorOutlineVariant">@color/md_theme_light_outlineVariant</item>
<!-- is this correct? --> <!-- is this correct? -->
<item name="scheduleColorDefault">@color/md_theme_dark_background</item> <item name="scheduleColorDefault">@color/md_theme_dark_background</item>