mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-09-19 21:49:07 -05:00
Adding new features to attendance
This commit is contained in:
parent
cefb0deba8
commit
62b824f68f
@ -104,7 +104,7 @@ android {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version "3.10.2"
|
||||
version "3.22.1"
|
||||
}
|
||||
}
|
||||
lint {
|
||||
|
@ -11,4 +11,6 @@ class ProfileConfigAttendance(base: ProfileConfig) {
|
||||
var groupConsecutiveDays by base.config<Boolean>(true)
|
||||
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)
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ class AttendanceSummaryFragment : LazyFragment(), CoroutineScope {
|
||||
totalCountSum += totalCount
|
||||
presenceCountSum += presenceCount
|
||||
|
||||
subject.presenceDifference = presenceCount - (totalCount-presenceCount);
|
||||
|
||||
subject.percentage = if (totalCount == 0)
|
||||
0f
|
||||
else
|
||||
@ -286,7 +288,11 @@ class AttendanceSummaryFragment : LazyFragment(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
return items.toMutableList()
|
||||
if(manager.sortedDescending){
|
||||
return items.sortedByDescending { it.percentage }.toMutableList();
|
||||
} else {
|
||||
return items.toMutableList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun animatePercentageIndicator(targetProgress: Double) {
|
||||
|
@ -23,4 +23,5 @@ data class AttendanceSubject(
|
||||
|
||||
var typeCountMap: Map<AttendanceType, Int> = mapOf()
|
||||
var percentage: Float = 0f
|
||||
var presenceDifference: Int = 0
|
||||
}
|
||||
|
@ -49,6 +49,15 @@ class SubjectViewHolder(
|
||||
}
|
||||
else {
|
||||
b.percentage.setText(R.string.attendance_percentage_format, item.percentage)
|
||||
|
||||
if(manager.showDifference){
|
||||
val differenceText = if(item.presenceDifference > 0)
|
||||
"+" + item.presenceDifference
|
||||
else
|
||||
item.presenceDifference
|
||||
|
||||
b.percentage.setText(b.percentage.text.toString() + " | " + differenceText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ package pl.szczodrzynski.edziennik.ui.dialogs.settings
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
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.ui.dialogs.base.ConfigDialog
|
||||
|
||||
class AttendanceConfigDialog(
|
||||
@ -33,6 +35,8 @@ class AttendanceConfigDialog(
|
||||
b.useSymbols.isChecked = app.profile.config.attendance.useSymbols
|
||||
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
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
@ -45,5 +49,19 @@ class AttendanceConfigDialog(
|
||||
b.showPresenceInMonth.onChange { _, isChecked ->
|
||||
app.profile.config.attendance.showPresenceInMonth = isChecked
|
||||
}
|
||||
b.showDifference.onChange { _, isChecked ->
|
||||
app.profile.config.attendance.showDifference = isChecked
|
||||
}
|
||||
b.sortedDescending.onChange { _, isChecked ->
|
||||
app.profile.config.attendance.sortedDescending = isChecked
|
||||
}
|
||||
|
||||
b.showDifferenceHelp.onClick {
|
||||
MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.attendance_config_show_difference)
|
||||
.setMessage(R.string.attendance_config_show_difference_message)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,10 @@ class AttendanceManager(val app: App) : CoroutineScope {
|
||||
|
||||
val useSymbols
|
||||
get() = app.profile.config.attendance.useSymbols
|
||||
val showDifference
|
||||
get() = app.profile.config.attendance.showDifference
|
||||
val sortedDescending
|
||||
get() = app.profile.config.attendance.sortedDescending
|
||||
|
||||
fun getTypeShort(baseType: Int): String {
|
||||
return when (baseType) {
|
||||
|
@ -3,7 +3,9 @@
|
||||
~ Copyright (c) Kuba Szczodrzyński 2020-5-4.
|
||||
-->
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
@ -52,6 +54,37 @@
|
||||
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"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/showDifference"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="32dp"
|
||||
android:text="@string/attendance_config_show_difference" />
|
||||
|
||||
<com.mikepenz.iconics.view.IconicsImageView
|
||||
android:id="@+id/showDifferenceHelp"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:scaleType="centerInside"
|
||||
app:iiv_color="?android:textColorSecondary"
|
||||
app:iiv_icon="cmd-help-circle-outline"
|
||||
app:iiv_size="24dp"
|
||||
tools:src="@android:drawable/ic_menu_help" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</layout>
|
||||
|
@ -1433,4 +1433,5 @@
|
||||
<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>
|
||||
</resources>
|
||||
|
@ -63,6 +63,9 @@
|
||||
<string name="attendance_belated_excused" translatable="false">su</string>
|
||||
<string name="attendance_config_group_consecutive_days">Grupuj kolejne dni na liście</string>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user