Prevent changing the current day by accident when excusing absences (#1599)

This commit is contained in:
Michael 2021-11-13 19:56:17 +01:00 committed by GitHub
parent 6de937703a
commit c183428107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -12,6 +12,7 @@ import android.view.View.INVISIBLE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ActionMode import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.datepicker.CalendarConstraints import com.google.android.material.datepicker.CalendarConstraints
import com.google.android.material.datepicker.MaterialDatePicker import com.google.android.material.datepicker.MaterialDatePicker
@ -216,13 +217,7 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
} }
override fun showExcuseButton(show: Boolean) { override fun showExcuseButton(show: Boolean) {
with(binding.attendanceExcuseButton) { binding.attendanceExcuseButton.isVisible = show
if (show) {
show()
} else {
hide()
}
}
} }
override fun showAttendanceDialog(lesson: Attendance) { override fun showAttendanceDialog(lesson: Attendance) {
@ -293,12 +288,16 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
} }
override fun showExcuseCheckboxes(show: Boolean) { override fun showExcuseCheckboxes(show: Boolean) {
attendanceAdapter.apply { with(attendanceAdapter) {
excuseActionMode = show excuseActionMode = show
notifyDataSetChanged() notifyDataSetChanged()
} }
} }
override fun showDayNavigation(show: Boolean) {
binding.attendanceNavContainer.isVisible = show
}
override fun finishActionMode() { override fun finishActionMode() {
actionMode?.finish() actionMode?.finish()
} }

View File

@ -174,6 +174,8 @@ class AttendancePresenter @Inject constructor(
view?.apply { view?.apply {
showExcuseCheckboxes(true) showExcuseCheckboxes(true)
showExcuseButton(false) showExcuseButton(false)
enableSwipe(false)
showDayNavigation(false)
} }
attendanceToExcuseList.clear() attendanceToExcuseList.clear()
return true return true
@ -183,6 +185,8 @@ class AttendancePresenter @Inject constructor(
view?.apply { view?.apply {
showExcuseCheckboxes(false) showExcuseCheckboxes(false)
showExcuseButton(true) showExcuseButton(true)
enableSwipe(true)
showDayNavigation(true)
} }
} }

View File

@ -60,6 +60,8 @@ interface AttendanceView : BaseView {
fun showExcuseCheckboxes(show: Boolean) fun showExcuseCheckboxes(show: Boolean)
fun showDayNavigation(show: Boolean)
fun finishActionMode() fun finishActionMode()
fun popView() fun popView()

View File

@ -1,14 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.modules.attendance.AttendanceFragment"> tools:context=".ui.modules.attendance.AttendanceFragment">
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_marginBottom="50dp"> android:layout_weight="1">
<com.google.android.material.progressindicator.CircularProgressIndicator <com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/attendanceProgress" android:id="@+id/attendanceProgress"
@ -170,4 +171,4 @@
app:srcCompat="@drawable/ic_chevron_right" app:srcCompat="@drawable/ic_chevron_right"
app:tint="?colorPrimary" /> app:tint="?colorPrimary" />
</io.github.wulkanowy.ui.widgets.MaterialLinearLayout> </io.github.wulkanowy.ui.widgets.MaterialLinearLayout>
</FrameLayout> </LinearLayout>