diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigAttendance.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigAttendance.kt index 7e01502b..4f2c1a5c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigAttendance.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/ProfileConfigAttendance.kt @@ -4,6 +4,8 @@ package pl.szczodrzynski.edziennik.config +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_ALPHABET + @Suppress("RemoveExplicitTypeArguments") class ProfileConfigAttendance(base: ProfileConfig) { @@ -12,5 +14,5 @@ class ProfileConfigAttendance(base: ProfileConfig) { var showPresenceInMonth by base.config(false) var useSymbols by base.config(false) var showDifference by base.config(false) - var sortedDescending by base.config(false) + var orderBy by base.config(SORTED_BY_ALPHABET) } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/AttendanceDao.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/AttendanceDao.kt index a420c5b5..fe99c96b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/AttendanceDao.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/AttendanceDao.kt @@ -56,7 +56,6 @@ abstract class AttendanceDao : BaseDao { // GET ALL - LIVE DATA fun getAll(profileId: Int) = getRaw("$QUERY WHERE attendances.profileId = $profileId $ORDER_BY") - // GET ALL - NOW fun getAllNow(profileId: Int) = getRawNow("$QUERY WHERE attendances.profileId = $profileId $ORDER_BY") diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceSummaryFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceSummaryFragment.kt index 8597ac50..cec36d75 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceSummaryFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/attendance/AttendanceSummaryFragment.kt @@ -32,6 +32,9 @@ import pl.szczodrzynski.edziennik.ui.attendance.AttendanceFragment.Companion.VIE import pl.szczodrzynski.edziennik.ui.attendance.models.AttendanceSubject import pl.szczodrzynski.edziennik.ui.base.lazypager.LazyFragment import pl.szczodrzynski.edziennik.ui.grades.models.GradesSubject +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_ALPHABET +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_HIGHEST +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_LOWEST import pl.szczodrzynski.edziennik.utils.models.Date import java.text.DecimalFormat import kotlin.coroutines.CoroutineContext @@ -288,10 +291,10 @@ class AttendanceSummaryFragment : LazyFragment(), CoroutineScope { } } - if(manager.sortedDescending){ - return items.sortedByDescending { it.percentage }.toMutableList(); - } else { - return items.toMutableList() + return when(manager.orderBy){ + SORTED_BY_HIGHEST -> items.sortedByDescending { it.percentage }.toMutableList() + SORTED_BY_LOWEST -> items.sortedBy { it.percentage }.toMutableList() + else -> items.sortedBy { it.subjectName.lowercase() }.toMutableList() } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/AttendanceConfigDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/AttendanceConfigDialog.kt index 1f8bfcf1..8c140105 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/AttendanceConfigDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/settings/AttendanceConfigDialog.kt @@ -11,7 +11,11 @@ import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.databinding.AttendanceConfigDialogBinding import pl.szczodrzynski.edziennik.ext.onChange import pl.szczodrzynski.edziennik.ext.onClick +import pl.szczodrzynski.edziennik.ext.setOnSelectedListener import pl.szczodrzynski.edziennik.ui.dialogs.base.ConfigDialog +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_ALPHABET +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_HIGHEST +import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager.Companion.SORTED_BY_LOWEST class AttendanceConfigDialog( activity: AppCompatActivity, @@ -36,7 +40,13 @@ class AttendanceConfigDialog( b.groupConsecutiveDays.isChecked = app.profile.config.attendance.groupConsecutiveDays b.showPresenceInMonth.isChecked = app.profile.config.attendance.showPresenceInMonth b.showDifference.isChecked = app.profile.config.attendance.showDifference - b.sortedDescending.isChecked = app.profile.config.attendance.sortedDescending + + when (app.profile.config.attendance.orderBy) { + SORTED_BY_ALPHABET -> b.sortAttendanceByAlphabet + SORTED_BY_LOWEST -> b.sortAttendanceByLowest + SORTED_BY_HIGHEST -> b.sortAttendanceByHighest + else -> null + }?.isChecked = true } override fun initView() { @@ -52,9 +62,10 @@ class AttendanceConfigDialog( b.showDifference.onChange { _, isChecked -> app.profile.config.attendance.showDifference = isChecked } - b.sortedDescending.onChange { _, isChecked -> - app.profile.config.attendance.sortedDescending = isChecked - } + + b.sortAttendanceByAlphabet.setOnSelectedListener { app.profile.config.attendance.orderBy = SORTED_BY_ALPHABET } + b.sortAttendanceByHighest.setOnSelectedListener { app.profile.config.attendance.orderBy = SORTED_BY_HIGHEST } + b.sortAttendanceByLowest.setOnSelectedListener { app.profile.config.attendance.orderBy = SORTED_BY_LOWEST } b.showDifferenceHelp.onClick { MaterialAlertDialogBuilder(activity) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt index 12e2611d..fb02f9b1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/AttendanceManager.kt @@ -19,16 +19,20 @@ import kotlin.coroutines.CoroutineContext class AttendanceManager(val app: App) : CoroutineScope { + companion object { + const val SORTED_BY_ALPHABET = 0 + const val SORTED_BY_HIGHEST = 1 + const val SORTED_BY_LOWEST = 2 + } private val job = Job() override val coroutineContext: CoroutineContext get() = job + Dispatchers.Default - val useSymbols get() = app.profile.config.attendance.useSymbols val showDifference get() = app.profile.config.attendance.showDifference - val sortedDescending - get() = app.profile.config.attendance.sortedDescending + val orderBy + get() = app.profile.config.attendance.orderBy fun getTypeShort(baseType: Int): String { return when (baseType) { diff --git a/app/src/main/res/layout/attendance_config_dialog.xml b/app/src/main/res/layout/attendance_config_dialog.xml index 5603b35e..398e10ce 100644 --- a/app/src/main/res/layout/attendance_config_dialog.xml +++ b/app/src/main/res/layout/attendance_config_dialog.xml @@ -32,34 +32,6 @@ android:minHeight="32dp" android:text="@string/attendance_config_use_symbols" /> - - - - - - + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 4c9b97c4..6f2d2cd3 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -1433,5 +1433,9 @@ Agenda settings Share notes All lessons: - Display attendance differences + Display attendance differences + Sort attendance + Alphabetically + From the highest + from the lowest diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4794791b..16f9a52a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,10 +65,12 @@ Wyświetlaj obecność w widoku miesięcy Wyświetlaj różnice obecności Wyświetla różnice między obecnościami a nieobecnościami (Ile lekcji potrzebujesz lub możesz nie mieć aby mieć nadal 50%) \n\nnp. -1 oznacza, że brakuje ci jednej lekcji do 50% - Sortuj od największej obecności Konfiguracja frekwencji Używaj symboli i kolorów wg dziennika Widoczne po rozwinięciu listy + Alfabetycznie + Od najniższej + Od najwyższej Nie ma tutaj żadnych nieobecności. w lekcja %d @@ -680,6 +682,7 @@ Tablica ogłoszeń Frekwencja Ustawienia frekwencji + Sortuj frekwencje Debugowanie Pomoc i opinie Zapisz plan lekcji jako obraz