forked from github/wulkanowy-mirror
Move excuse whole day button to action bar
This commit is contained in:
parent
f8c9122686
commit
28c234a8fd
@ -69,6 +69,8 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
|
||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||
val inflater = mode.menuInflater
|
||||
inflater.inflate(R.menu.context_menu_attendance, menu)
|
||||
menu.findItem(R.id.excuseMenuDaySubmit).setVisible(presenter.isWholeDayExcusable)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@ -84,6 +86,7 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
|
||||
|
||||
override fun onActionItemClicked(mode: ActionMode, menu: MenuItem): Boolean {
|
||||
return when (menu.itemId) {
|
||||
R.id.excuseMenuDaySubmit -> presenter.onExcuseDayButtonClick()
|
||||
R.id.excuseMenuSubmit -> presenter.onExcuseSubmitButtonClick()
|
||||
else -> false
|
||||
}
|
||||
@ -129,7 +132,6 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
|
||||
attendanceNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
attendanceExcuseButton.setOnClickListener { presenter.onExcuseButtonClick() }
|
||||
attendanceExcuseDayButton.setOnClickListener { presenter.onExcuseDayButtonClick() }
|
||||
|
||||
attendanceNavContainer.elevation = requireContext().dpToPx(3f)
|
||||
}
|
||||
@ -222,10 +224,6 @@ class AttendanceFragment : BaseFragment<FragmentAttendanceBinding>(R.layout.frag
|
||||
binding.attendanceExcuseButton.isVisible = show
|
||||
}
|
||||
|
||||
override fun showExcuseDayButton(show: Boolean) {
|
||||
binding.attendanceExcuseDayButton.isVisible = show
|
||||
}
|
||||
|
||||
override fun showAttendanceDialog(lesson: Attendance) {
|
||||
(activity as? MainActivity)?.showDialogFragment(AttendanceDialog.newInstance(lesson))
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class AttendancePresenter @Inject constructor(
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
private val attendanceToExcuseList = mutableListOf<Attendance>()
|
||||
private var isWholeDayExcusable = false
|
||||
var isWholeDayExcusable = false
|
||||
|
||||
private var isVulcanExcusedFunctionEnabled = false
|
||||
|
||||
@ -130,14 +130,12 @@ class AttendancePresenter @Inject constructor(
|
||||
|
||||
fun onExcuseButtonClick() {
|
||||
view?.startActionMode()
|
||||
|
||||
if (isWholeDayExcusable) {
|
||||
view?.showExcuseDayButton(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun onExcuseDayButtonClick() {
|
||||
fun onExcuseDayButtonClick(): Boolean {
|
||||
view?.showExcuseDialog()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun onExcuseCheckboxSelect(attendanceItem: Attendance, checked: Boolean) {
|
||||
@ -183,7 +181,6 @@ class AttendancePresenter @Inject constructor(
|
||||
view?.apply {
|
||||
showExcuseCheckboxes(true)
|
||||
showExcuseButton(false)
|
||||
showExcuseDayButton(false)
|
||||
enableSwipe(false)
|
||||
showDayNavigation(false)
|
||||
}
|
||||
@ -195,7 +192,6 @@ class AttendancePresenter @Inject constructor(
|
||||
view?.apply {
|
||||
showExcuseCheckboxes(false)
|
||||
showExcuseButton(true)
|
||||
showExcuseDayButton(false)
|
||||
enableSwipe(true)
|
||||
showDayNavigation(true)
|
||||
}
|
||||
@ -230,7 +226,6 @@ class AttendancePresenter @Inject constructor(
|
||||
.onResourceLoading {
|
||||
view?.apply {
|
||||
showExcuseButton(false)
|
||||
showExcuseDayButton(false)
|
||||
}
|
||||
}
|
||||
.mapResourceData {
|
||||
@ -256,7 +251,7 @@ class AttendancePresenter @Inject constructor(
|
||||
.onResourceIntermediate { view?.showRefresh(true) }
|
||||
.onResourceSuccess { items ->
|
||||
isVulcanExcusedFunctionEnabled = items.any { item -> item.excusable }
|
||||
isWholeDayExcusable = items.all { it.isExcusableOrNotExcused }
|
||||
isWholeDayExcusable = items.all { it.isAbsenceExcusable }
|
||||
val anyExcusables = items.any { it.isExcusableOrNotExcused }
|
||||
view?.showExcuseButton(anyExcusables && (isParent || isVulcanExcusedFunctionEnabled))
|
||||
|
||||
@ -336,7 +331,6 @@ class AttendancePresenter @Inject constructor(
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
showExcuseButton(false)
|
||||
showExcuseDayButton(false)
|
||||
}
|
||||
|
||||
is Resource.Success -> {
|
||||
@ -345,7 +339,6 @@ class AttendancePresenter @Inject constructor(
|
||||
attendanceToExcuseList.clear()
|
||||
view?.run {
|
||||
showExcuseButton(false)
|
||||
showExcuseDayButton(false)
|
||||
showMessage(excuseSuccessString)
|
||||
showContent(true)
|
||||
showProgress(false)
|
||||
|
@ -48,8 +48,6 @@ interface AttendanceView : BaseView {
|
||||
|
||||
fun showExcuseButton(show: Boolean)
|
||||
|
||||
fun showExcuseDayButton(show: Boolean)
|
||||
|
||||
fun showAttendanceDialog(lesson: Attendance)
|
||||
|
||||
fun showDatePickerDialog(selectedDate: LocalDate)
|
||||
|
@ -19,6 +19,9 @@ private inline val AttendanceSummary.allAbsences: Double
|
||||
inline val Attendance.isExcusableOrNotExcused: Boolean
|
||||
get() = (excusable || ((absence || lateness) && !excused)) && excuseStatus == null
|
||||
|
||||
inline val Attendance.isAbsenceExcusable: Boolean
|
||||
get() = (excusable && absence && !excused) && excuseStatus == null
|
||||
|
||||
fun AttendanceSummary.calculatePercentage() = calculatePercentage(allPresences, allAbsences)
|
||||
|
||||
fun List<AttendanceSummary>.calculatePercentage(): Double {
|
||||
|
@ -69,19 +69,6 @@
|
||||
app:icon="@drawable/ic_all_done_all"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/attendanceExcuseDayButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:text="@string/attendance_excuse_day_title"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_all_done_all"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attendanceError"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -2,6 +2,13 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/excuseMenuDaySubmit"
|
||||
android:icon="@drawable/ic_all_done_all"
|
||||
android:title="@string/attendance_excuse_day_title"
|
||||
app:iconTint="@color/material_on_surface_emphasis_medium"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/excuseMenuSubmit"
|
||||
android:icon="@drawable/ic_all_done"
|
||||
|
Loading…
Reference in New Issue
Block a user