diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceAdapter.kt index a63d5045..8e8a6149 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceAdapter.kt @@ -9,6 +9,7 @@ import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.data.repositories.attendance.SentExcuseStatus import io.github.wulkanowy.databinding.ItemAttendanceBinding +import io.github.wulkanowy.utils.description import javax.inject.Inject class AttendanceAdapter @Inject constructor() : @@ -34,7 +35,7 @@ class AttendanceAdapter @Inject constructor() : with(holder.binding) { attendanceItemNumber.text = item.number.toString() attendanceItemSubject.text = item.subject - attendanceItemDescription.text = item.name + attendanceItemDescription.setText(item.description) attendanceItemAlert.visibility = item.run { if (absence && !excused) View.VISIBLE else View.INVISIBLE } attendanceItemNumber.visibility = View.GONE attendanceItemExcuseInfo.visibility = View.GONE diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt index 97b76e81..d5e2fe12 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt @@ -7,6 +7,7 @@ import android.view.ViewGroup import androidx.fragment.app.DialogFragment import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.databinding.DialogAttendanceBinding +import io.github.wulkanowy.utils.description import io.github.wulkanowy.utils.lifecycleAwareVariable import io.github.wulkanowy.utils.toFormattedString @@ -43,7 +44,7 @@ class AttendanceDialog : DialogFragment() { with(binding) { attendanceDialogSubject.text = attendance.subject - attendanceDialogDescription.text = attendance.name + attendanceDialogDescription.setText(attendance.description) attendanceDialogDate.text = attendance.date.toFormattedString() attendanceDialogNumber.text = attendance.number.toString() attendanceDialogClose.setOnClickListener { dismiss() } diff --git a/app/src/main/java/io/github/wulkanowy/utils/AttendanceExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/AttendanceExtension.kt index c2b1efaa..92e8661f 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/AttendanceExtension.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/AttendanceExtension.kt @@ -1,6 +1,9 @@ package io.github.wulkanowy.utils +import io.github.wulkanowy.R +import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.data.db.entities.AttendanceSummary +import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory /** * [UONET+ - Zasady tworzenia podsumowań liczb uczniów obecnych i nieobecnych w tabeli frekwencji] @@ -23,4 +26,15 @@ private fun calculatePercentage(presence: Double, absence: Double): Double { return if ((presence + absence) == 0.0) 0.0 else (presence / (presence + absence)) * 100 } - +inline val Attendance.description + get() = when (AttendanceCategory.valueOf(name)) { + AttendanceCategory.PRESENCE -> R.string.attendance_present + AttendanceCategory.ABSENCE_UNEXCUSED -> R.string.attendance_absence_unexcused + AttendanceCategory.ABSENCE_EXCUSED -> R.string.attendance_absence_excused + AttendanceCategory.UNEXCUSED_LATENESS -> R.string.attendance_unexcused_lateness + AttendanceCategory.EXCUSED_LATENESS -> R.string.attendance_excused_lateness + AttendanceCategory.ABSENCE_FOR_SCHOOL_REASONS -> R.string.attendance_absence_school + AttendanceCategory.EXEMPTION -> R.string.attendance_exemption + AttendanceCategory.DELETED -> R.string.attendance_deleted + else -> R.string.attendance_unknown + } diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index e4d3e902..ebc14542 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -168,6 +168,8 @@ Spóźnienie usprawiedliwione Spóźnienie nieusprawiedliwione Obecność + Usunięty + Nieznany Numer lekcji Brak wpisów diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1eaebf28..963c7047 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -170,6 +170,8 @@ Excused lateness Unexcused lateness Present + Deleted + Unknown Number of lesson No entries