mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-09-19 21:49:07 -05:00
Add sort types to attendance
This commit is contained in:
parent
62b824f68f
commit
4728f0a00a
@ -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<Boolean>(false)
|
||||
var useSymbols by base.config<Boolean>(false)
|
||||
var showDifference by base.config<Boolean>(false)
|
||||
var sortedDescending by base.config<Boolean>(false)
|
||||
var orderBy by base.config<Int>(SORTED_BY_ALPHABET)
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ abstract class AttendanceDao : BaseDao<Attendance, AttendanceFull> {
|
||||
// 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")
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -32,34 +32,6 @@
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_use_symbols" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="@string/attendance_config_use_symbols_hint"
|
||||
android:textAppearance="@style/NavView.TextView.Helper"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/groupConsecutiveDays"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_group_consecutive_days" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/showPresenceInMonth"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_show_presence_in_month" />
|
||||
<CheckBox
|
||||
android:id="@+id/sortedDescending"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_sorted_descending"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -85,6 +57,62 @@
|
||||
tools:src="@android:drawable/ic_menu_help" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="@string/attendance_config_use_symbols_hint"
|
||||
android:textAppearance="@style/NavView.TextView.Helper"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/groupConsecutiveDays"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_group_consecutive_days" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/showPresenceInMonth"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_show_presence_in_month" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="4dp"
|
||||
style="@style/TextAppearance.AppCompat.Small"
|
||||
android:text="@string/menu_attendance_sort_mode"/>
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/sortAttendanceByAlphabet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:text="@string/attendance_config_dialog_sort_by_alphabet" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/sortAttendanceByLowest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:text="@string/attendance_config_dialog_sort_by_lowest"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/sortAttendanceByHighest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:text="@string/attendance_config_dialog_sort_by_highest"/>
|
||||
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</layout>
|
||||
|
@ -1433,5 +1433,9 @@
|
||||
<string name="menu_agenda_config">Agenda settings</string>
|
||||
<string name="registration_config_note_sharing_title">Share notes</string>
|
||||
<string name="home_timetable_all_lessons">All lessons:</string>
|
||||
<string name="attendace_config_show_difference">Display attendance differences</string>
|
||||
<string name="attendance_config_show_difference">Display attendance differences</string>
|
||||
<string name="menu_attendance_sort_mode">Sort attendance</string>
|
||||
<string name="attendance_config_dialog_sort_by_alphabet">Alphabetically</string>
|
||||
<string name="attendance_config_dialog_sort_by_highest">From the highest</string>
|
||||
<string name="attendance_config_dialog_sort_by_lowest">from the lowest</string>
|
||||
</resources>
|
||||
|
@ -65,10 +65,12 @@
|
||||
<string name="attendance_config_show_presence_in_month">Wyświetlaj obecność w widoku miesięcy</string>
|
||||
<string name="attendance_config_show_difference">Wyświetlaj różnice obecności</string>
|
||||
<string name="attendance_config_show_difference_message">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%</string>
|
||||
<string name="attendance_config_sorted_descending">Sortuj od największej obecności</string>
|
||||
<string name="attendance_config_title">Konfiguracja frekwencji</string>
|
||||
<string name="attendance_config_use_symbols">Używaj symboli i kolorów wg dziennika</string>
|
||||
<string name="attendance_config_use_symbols_hint">Widoczne po rozwinięciu listy</string>
|
||||
<string name="attendance_config_dialog_sort_by_alphabet">Alfabetycznie</string>
|
||||
<string name="attendance_config_dialog_sort_by_lowest">Od najniższej</string>
|
||||
<string name="attendance_config_dialog_sort_by_highest">Od najwyższej</string>
|
||||
<string name="attendance_empty_text">Nie ma tutaj żadnych nieobecności.</string>
|
||||
<string name="attendance_free_day" translatable="false">w</string>
|
||||
<string name="attendance_lesson_number_format">lekcja %d</string>
|
||||
@ -680,6 +682,7 @@
|
||||
<string name="menu_announcements">Tablica ogłoszeń</string>
|
||||
<string name="menu_attendance">Frekwencja</string>
|
||||
<string name="menu_attendance_config">Ustawienia frekwencji</string>
|
||||
<string name="menu_attendance_sort_mode">Sortuj frekwencje</string>
|
||||
<string name="menu_debug">Debugowanie</string>
|
||||
<string name="menu_feedback">Pomoc i opinie</string>
|
||||
<string name="menu_generate_block_timetable">Zapisz plan lekcji jako obraz</string>
|
||||
|
Loading…
Reference in New Issue
Block a user