forked from github/wulkanowy-mirror
add: hiding grades, notes and attendance entries
This commit is contained in:
parent
d17614fa64
commit
92bad9d112
@ -1,7 +1,7 @@
|
||||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
insert_final_newline=true
|
||||
insert_final_newline=Advanced
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.data.db.dao
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import io.github.wulkanowy.data.db.entities.Attendance
|
||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.time.LocalDate
|
||||
import javax.inject.Singleton
|
||||
@ -18,12 +19,4 @@ interface AttendanceDao : BaseDao<Attendance> {
|
||||
start: LocalDate,
|
||||
end: LocalDate
|
||||
): Flow<List<Attendance>>
|
||||
|
||||
@Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :start AND date <= :end AND (presence OR excused)")
|
||||
fun loadAllCensored(
|
||||
diaryId: Int,
|
||||
studentId: Int,
|
||||
start: LocalDate,
|
||||
end: LocalDate
|
||||
): Flow<List<Attendance>>
|
||||
}
|
||||
|
@ -11,7 +11,4 @@ import javax.inject.Singleton
|
||||
interface NoteDao : BaseDao<Note> {
|
||||
@Query("SELECT * FROM Notes WHERE student_id = :studentId")
|
||||
fun loadAll(studentId: Int): Flow<List<Note>>
|
||||
|
||||
@Query("SELECT * FROM Notes WHERE student_id = :studentId AND 1 != 1")
|
||||
fun pretendLoadingAll(studentId: Int): Flow<List<Note>>
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.mappers.mapToEntities
|
||||
import io.github.wulkanowy.data.networkBoundResource
|
||||
import io.github.wulkanowy.sdk.pojo.Absent
|
||||
import io.github.wulkanowy.sdk.pojo.Attendance as SdkAttendance
|
||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||
import io.github.wulkanowy.utils.getRefreshKey
|
||||
@ -16,6 +17,7 @@ import io.github.wulkanowy.utils.monday
|
||||
import io.github.wulkanowy.utils.sunday
|
||||
import io.github.wulkanowy.utils.uniqueSubtract
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
@ -36,6 +38,64 @@ class AttendanceRepository @Inject constructor(
|
||||
|
||||
private val cacheKey = "attendance"
|
||||
|
||||
private fun filterAttendance(
|
||||
hiddenAttendanceTiles: List<DashboardItem.HiddenAttendanceTile>,
|
||||
attendanceItem: Attendance
|
||||
): Boolean {
|
||||
return when {
|
||||
attendanceItem.absence && attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.EXCUSED_ABSENCE
|
||||
) -> false
|
||||
|
||||
attendanceItem.absence && !attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.UNEXCUSED_ABSENCE
|
||||
) -> false
|
||||
|
||||
attendanceItem.lateness && attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.EXCUSED_LATENESS
|
||||
) -> false
|
||||
|
||||
attendanceItem.lateness && !attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.UNEXCUSED_LATENESS
|
||||
) -> false
|
||||
|
||||
attendanceItem.exemption && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.EXEMPTION) -> false
|
||||
attendanceItem.deleted && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.DELETED) -> false
|
||||
attendanceItem.presence && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.PRESENT) -> false
|
||||
|
||||
else -> !hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.UNKNOWN)
|
||||
}
|
||||
}
|
||||
|
||||
private fun filterAttendance(
|
||||
hiddenAttendanceTiles: List<DashboardItem.HiddenAttendanceTile>,
|
||||
attendanceItem: SdkAttendance
|
||||
): Boolean {
|
||||
return when {
|
||||
attendanceItem.absence && attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.EXCUSED_ABSENCE
|
||||
) -> false
|
||||
|
||||
attendanceItem.absence && !attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.UNEXCUSED_ABSENCE
|
||||
) -> false
|
||||
|
||||
attendanceItem.lateness && attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.EXCUSED_LATENESS
|
||||
) -> false
|
||||
|
||||
attendanceItem.lateness && !attendanceItem.excused && hiddenAttendanceTiles.contains(
|
||||
DashboardItem.HiddenAttendanceTile.UNEXCUSED_LATENESS
|
||||
) -> false
|
||||
|
||||
attendanceItem.exemption && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.EXEMPTION) -> false
|
||||
attendanceItem.deleted && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.DELETED) -> false
|
||||
attendanceItem.presence && hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.PRESENT) -> false
|
||||
|
||||
else -> !hiddenAttendanceTiles.contains(DashboardItem.HiddenAttendanceTile.UNKNOWN)
|
||||
}
|
||||
}
|
||||
|
||||
fun getAttendance(
|
||||
student: Student,
|
||||
semester: Semester,
|
||||
@ -53,30 +113,16 @@ class AttendanceRepository @Inject constructor(
|
||||
it.isEmpty() || forceRefresh || isExpired
|
||||
},
|
||||
query = {
|
||||
val badAttendanceHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.NOTES)
|
||||
val hiddenAttendanceItems = preferencesRepository.hiddenAttendanceItems
|
||||
|
||||
if (badAttendanceHidden) {
|
||||
attendanceDb.loadAllCensored(
|
||||
semester.diaryId,
|
||||
semester.studentId,
|
||||
start.monday,
|
||||
end.sunday
|
||||
)
|
||||
} else {
|
||||
attendanceDb.loadAll(
|
||||
semester.diaryId,
|
||||
semester.studentId,
|
||||
start.monday,
|
||||
end.sunday
|
||||
)
|
||||
}
|
||||
attendanceDb
|
||||
.loadAll(semester.diaryId, semester.studentId, start.monday, end.sunday)
|
||||
.map {
|
||||
it.filter { item -> filterAttendance(hiddenAttendanceItems, item) }
|
||||
}
|
||||
},
|
||||
fetch = {
|
||||
val badAttendanceHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.NOTES)
|
||||
val hiddenAttendanceItems = preferencesRepository.hiddenAttendanceItems
|
||||
|
||||
val lessons = timetableDb.load(
|
||||
semester.diaryId, semester.studentId, start.monday, end.sunday
|
||||
@ -84,7 +130,7 @@ class AttendanceRepository @Inject constructor(
|
||||
|
||||
wulkanowySdkFactory.create(student, semester)
|
||||
.getAttendance(start.monday, end.sunday)
|
||||
.filter { !badAttendanceHidden || (it.presence || it.excused) }
|
||||
.filter { item -> filterAttendance(hiddenAttendanceItems, item) }
|
||||
.mapToEntities(semester, lessons)
|
||||
},
|
||||
saveFetchResult = { old, new ->
|
||||
@ -105,15 +151,13 @@ class AttendanceRepository @Inject constructor(
|
||||
start: LocalDate,
|
||||
end: LocalDate
|
||||
): Flow<List<Attendance>> {
|
||||
val badAttendanceHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.BAD_ATTENDANCE)
|
||||
val hiddenAttendanceItems = preferencesRepository.hiddenAttendanceItems
|
||||
|
||||
return if (badAttendanceHidden) {
|
||||
attendanceDb.loadAllCensored(semester.diaryId, semester.studentId, start, end)
|
||||
} else {
|
||||
attendanceDb.loadAll(semester.diaryId, semester.studentId, start, end)
|
||||
}
|
||||
return attendanceDb
|
||||
.loadAll(semester.diaryId, semester.studentId, start.monday, end.sunday)
|
||||
.map {
|
||||
it.filter { item -> filterAttendance(hiddenAttendanceItems, item) }
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateTimetable(timetable: List<Attendance>) {
|
||||
|
@ -7,7 +7,6 @@ import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.mappers.mapToEntities
|
||||
import io.github.wulkanowy.data.networkBoundResource
|
||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||
import io.github.wulkanowy.utils.AutoRefreshHelper
|
||||
import io.github.wulkanowy.utils.getRefreshKey
|
||||
import io.github.wulkanowy.utils.toLocalDate
|
||||
@ -41,27 +40,16 @@ class NoteRepository @Inject constructor(
|
||||
val isExpired = refreshHelper.shouldBeRefreshed(
|
||||
getRefreshKey(cacheKey, semester)
|
||||
)
|
||||
|
||||
it.isEmpty() || forceRefresh || isExpired
|
||||
},
|
||||
query = {
|
||||
val notesHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.NOTES)
|
||||
|
||||
if (notesHidden) {
|
||||
noteDb.pretendLoadingAll(student.studentId)
|
||||
} else {
|
||||
noteDb.loadAll(student.studentId)
|
||||
}
|
||||
},
|
||||
query = { noteDb.loadAll(student.studentId) },
|
||||
fetch = {
|
||||
val notesHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.NOTES)
|
||||
val showNotes = preferencesRepository.showNotes
|
||||
|
||||
wulkanowySdkFactory.create(student, semester)
|
||||
.getNotes()
|
||||
.filter { !notesHidden }
|
||||
.filter { showNotes }
|
||||
.mapToEntities(semester)
|
||||
},
|
||||
saveFetchResult = { old, new ->
|
||||
@ -80,15 +68,7 @@ class NoteRepository @Inject constructor(
|
||||
)
|
||||
|
||||
fun getNotesFromDatabase(student: Student): Flow<List<Note>> {
|
||||
val notesHidden = preferencesRepository
|
||||
.selectedHiddenSettingTiles
|
||||
.contains(DashboardItem.HiddenSettingTile.NOTES)
|
||||
|
||||
return if (notesHidden) {
|
||||
noteDb.pretendLoadingAll(student.studentId)
|
||||
} else {
|
||||
noteDb.loadAll(student.studentId)
|
||||
}
|
||||
return noteDb.loadAll(student.studentId)
|
||||
}
|
||||
|
||||
suspend fun updateNote(note: Note) {
|
||||
|
@ -2,8 +2,6 @@ package io.github.wulkanowy.data.repositories
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.edit
|
||||
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
|
||||
@ -26,7 +24,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.internal.notifyAll
|
||||
import timber.log.Timber
|
||||
import java.time.Instant
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
@ -39,6 +37,8 @@ class PreferencesRepository @Inject constructor(
|
||||
private val flowSharedPref: FlowSharedPreferences,
|
||||
private val json: Json,
|
||||
) {
|
||||
private val NO_ATTENDANCE_VALUE = -1.0
|
||||
|
||||
val isShowPresent: Boolean
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_attendance_present,
|
||||
@ -297,28 +297,9 @@ class PreferencesRepository @Inject constructor(
|
||||
selectedDashboardTilesPreference.set(filteredValue)
|
||||
}
|
||||
|
||||
var selectedHiddenSettingTiles: List<DashboardItem.HiddenSettingTile>
|
||||
get() = selectedHiddenSettingTilesPreference.get()
|
||||
.map { DashboardItem.HiddenSettingTile.valueOf(it) }
|
||||
set(value) {
|
||||
val filteredValue = value
|
||||
.map { it.name }
|
||||
.toSet()
|
||||
|
||||
selectedHiddenSettingTilesPreference.set(filteredValue)
|
||||
}
|
||||
|
||||
var attendancePercentage: Float?
|
||||
get() = getString(
|
||||
R.string.pref_key_attendance_percentage,
|
||||
R.string.pref_default_attendance_percentage
|
||||
).let { if (it.isNullOrEmpty()) null else it.toFloat() }
|
||||
set(value) = sharedPref.edit {
|
||||
putString(
|
||||
context.getString(R.string.pref_key_attendance_percentage),
|
||||
value?.toString() ?: "-1"
|
||||
)
|
||||
}
|
||||
var attendancePercentage: Double?
|
||||
get() = attendancePercentagePreference.get().takeIf { it != NO_ATTENDANCE_VALUE }
|
||||
set(value) = attendancePercentagePreference.set(value ?: NO_ATTENDANCE_VALUE)
|
||||
|
||||
var hiddenAttendanceItems: List<DashboardItem.HiddenAttendanceTile>
|
||||
get() = hiddenAttendanceItemsPreference.get().toList()
|
||||
@ -328,6 +309,10 @@ class PreferencesRepository @Inject constructor(
|
||||
get() = hiddenGradesPreference.get().toList()
|
||||
set(value) = hiddenGradesPreference.set(value.toSet())
|
||||
|
||||
var showNotes: Boolean
|
||||
get() = showNotesPreference.get()
|
||||
set(value) = showNotesPreference.set(value)
|
||||
|
||||
private val hiddenGradesPreference: Preference<Set<String>>
|
||||
get() {
|
||||
val defaultSet = context.resources.getStringArray(R.array.pref_default_hidden_grades).toSet()
|
||||
@ -336,11 +321,17 @@ class PreferencesRepository @Inject constructor(
|
||||
return flowSharedPref.getStringSet(prefKey, defaultSet)
|
||||
}
|
||||
|
||||
private val showNotesPreference: Preference<Boolean>
|
||||
get() = flowSharedPref.getBoolean(
|
||||
context.getString(R.string.pref_key_show_notes),
|
||||
context.resources.getBoolean(R.bool.pref_default_show_notes)
|
||||
)
|
||||
|
||||
private val hiddenAttendanceItemsPreference: Preference<Set<DashboardItem.HiddenAttendanceTile>>
|
||||
get() {
|
||||
val defaultSet =
|
||||
context.resources.getStringArray(R.array.pref_default_hidden_attendance_items).toSet()
|
||||
val prefKey = "hidden_attendance_items"
|
||||
val prefKey = "attendance_items"
|
||||
|
||||
return flowSharedPref
|
||||
.getStringSet(prefKey, defaultSet)
|
||||
@ -359,21 +350,19 @@ class PreferencesRepository @Inject constructor(
|
||||
return flowSharedPref.getStringSet(prefKey, defaultSet)
|
||||
}
|
||||
|
||||
private val selectedHiddenSettingTilesPreference: Preference<Set<String>>
|
||||
private val attendancePercentagePreference: Preference<Double>
|
||||
get() {
|
||||
val defaultSet =
|
||||
context.resources.getStringArray(R.array.pref_default_hidden_settings_tiles).toSet()
|
||||
val prefKey = "hidden_settings_tiles"
|
||||
val prefKey = context.getString(R.string.pref_key_attendance_percentage)
|
||||
val defaultValue = context.resources.getString(R.string.pref_default_attendance_percentage)
|
||||
|
||||
return flowSharedPref.getStringSet(prefKey, defaultSet)
|
||||
return flowSharedPref
|
||||
.getString(prefKey, defaultValue)
|
||||
.map(
|
||||
mapper = { it.toDoubleOrNull() ?: NO_ATTENDANCE_VALUE },
|
||||
reverse = { it.toString() }
|
||||
)
|
||||
}
|
||||
|
||||
private val attendancePercentagePreference: Preference<Float>
|
||||
get() = flowSharedPref.getFloat(
|
||||
context.getString(R.string.pref_key_attendance_percentage),
|
||||
context.resources.getInteger(R.integer.pref_default_attendance_percentage).toFloat()
|
||||
)
|
||||
|
||||
var dismissedAdminMessageIds: List<Int>
|
||||
get() = sharedPref.getStringSet(PREF_KEY_ADMIN_DISMISSED_MESSAGE_IDS, emptySet())
|
||||
.orEmpty()
|
||||
|
@ -54,7 +54,7 @@ class AttendanceSummaryAdapter @Inject constructor(
|
||||
|
||||
private fun bindHeaderViewHolder(binding: ScrollableHeaderAttendanceSummaryBinding) {
|
||||
binding.attendanceSummaryScrollableHeaderPercentage.text = formatPercentage(
|
||||
attendancePercentage?.toDouble() ?:
|
||||
attendancePercentage ?:
|
||||
items.calculatePercentage()
|
||||
)
|
||||
}
|
||||
@ -68,8 +68,8 @@ class AttendanceSummaryAdapter @Inject constructor(
|
||||
else -> item.month.getFormattedName()
|
||||
}
|
||||
attendanceSummaryPercentage.text = when (position) {
|
||||
-1 -> formatPercentage(attendancePercentage?.toDouble() ?: item.calculatePercentage())
|
||||
else -> formatPercentage(attendancePercentage?.toDouble() ?: item.calculatePercentage())
|
||||
-1 -> formatPercentage(attendancePercentage ?: item.calculatePercentage())
|
||||
else -> formatPercentage(attendancePercentage ?: item.calculatePercentage())
|
||||
}
|
||||
|
||||
attendanceSummaryPresent.text = item.presence.toString()
|
||||
|
@ -148,12 +148,6 @@ sealed class DashboardItem(val type: Type) {
|
||||
CONFERENCES,
|
||||
}
|
||||
|
||||
enum class HiddenSettingTile {
|
||||
BAD_ATTENDANCE,
|
||||
NOTES,
|
||||
ATTENDANCE,
|
||||
}
|
||||
|
||||
enum class HiddenAttendanceTile {
|
||||
UNEXCUSED_ABSENCE,
|
||||
EXEMPTION,
|
||||
|
@ -338,7 +338,7 @@ class DashboardPresenter @Inject constructor(
|
||||
} else null
|
||||
},
|
||||
attendancePercentage = DashboardItem.HorizontalGroup.Cell(
|
||||
data = attendancePercentage?.toDouble() ?: attendanceResource.dataOrNull?.calculatePercentage(),
|
||||
data = attendancePercentage ?: attendanceResource.dataOrNull?.calculatePercentage(),
|
||||
error = attendanceResource.errorOrNull != null,
|
||||
isLoading = attendanceResource is Resource.Loading,
|
||||
),
|
||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.note
|
||||
import io.github.wulkanowy.data.*
|
||||
import io.github.wulkanowy.data.db.entities.Note
|
||||
import io.github.wulkanowy.data.repositories.NoteRepository
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.data.repositories.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
@ -17,6 +18,7 @@ class NotePresenter @Inject constructor(
|
||||
studentRepository: StudentRepository,
|
||||
private val noteRepository: NoteRepository,
|
||||
private val semesterRepository: SemesterRepository,
|
||||
private val preferencesRepository: PreferencesRepository,
|
||||
private val analytics: AnalyticsHelper
|
||||
) : BasePresenter<NoteView>(errorHandler, studentRepository) {
|
||||
|
||||
@ -48,6 +50,19 @@ class NotePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData(forceRefresh: Boolean = false) {
|
||||
if (!preferencesRepository.showNotes) {
|
||||
view?.run {
|
||||
enableSwipe(false)
|
||||
showEmpty(false)
|
||||
showContent(false)
|
||||
showErrorView(false)
|
||||
showProgress(false)
|
||||
showEmpty(true)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
flatResourceFlow {
|
||||
val student = studentRepository.getCurrentStudent()
|
||||
val semester = semesterRepository.getCurrentSemester(student)
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.MultiSelectListPreference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@ -43,8 +44,8 @@ class ModSettingsFragment : PreferenceFragmentCompat(),
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.scheme_preferences_mod_settings, rootKey)
|
||||
|
||||
val etp: EditTextPreference? = findPreference("attendance_percentage")
|
||||
etp?.setOnBindEditTextListener { editText ->
|
||||
val attendancePercentagePreference: EditTextPreference? = findPreference("attendance_percentage")
|
||||
attendancePercentagePreference?.setOnBindEditTextListener { editText ->
|
||||
editText.inputType = android.text.InputType.TYPE_CLASS_NUMBER or android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL
|
||||
editText.filters = arrayOf(
|
||||
android.text.InputFilter { source, _, _, dest, _, _ ->
|
||||
@ -118,25 +119,6 @@ class ModSettingsFragment : PreferenceFragmentCompat(),
|
||||
preferenceScreen.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun showGradeDialogSettings() {
|
||||
val hiddenGrades = preferencesRepository.hiddenGrades
|
||||
|
||||
val grades = requireContext().resources.getStringArray(R.array.hidden_settings_bad_grades)
|
||||
val selectedItemsState = grades.map { grade -> hiddenGrades.any { it == grade } }
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.pref_hidden_settings_hidden_grades)
|
||||
.setMultiChoiceItems(grades, selectedItemsState.toBooleanArray()) { _, _, _ -> }
|
||||
.setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||
val selectedState = (dialog as AlertDialog).listView.checkedItemPositions
|
||||
val selectedValues = grades.filterIndexed { index, _ -> selectedState[index] }
|
||||
|
||||
Timber.i("Selected hidden grades: $selectedValues")
|
||||
presenter.onHiddenGradesSelected(selectedValues)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun showAttendanceSettings(items: List<DashboardItem.HiddenAttendanceTile>) {
|
||||
val entries = requireContext().resources.getStringArray(R.array.mod_settings_attendance_entries)
|
||||
val values = requireContext().resources.getStringArray(R.array.mod_settings_attendance_values)
|
||||
|
@ -18,6 +18,7 @@ class ModSettingsPresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: ModSettingsView) {
|
||||
super.onAttachView(view)
|
||||
|
||||
Timber.i("Mod settings view was initialized")
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,5 @@ import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
|
||||
|
||||
interface ModSettingsView : BaseView {
|
||||
fun restartApp()
|
||||
fun showGradeDialogSettings()
|
||||
fun showAttendanceSettings(items: List<DashboardItem.HiddenAttendanceTile>)
|
||||
}
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Skrytá nastavení</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Procento docházky</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Skrýt známky</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Špatná účast</item>
|
||||
<item>Poznámky</item>
|
||||
<item>Falešná účast</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Hidden settings</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Hide grades</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Bad attendance</item>
|
||||
<item>Notes</item>
|
||||
<item>Fake attendance</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Geheime Einstellungen</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Prozentuale Erwartung</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Hide Grades</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Schlechte Anwesenheit</item>
|
||||
<item>Notizen</item>
|
||||
<item>Vorgetäuschte 100-prozentige Anwesenheit</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Hidden settings</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Hide grades</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Bad attendance</item>
|
||||
<item>Notes</item>
|
||||
<item>Fake attendance</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Hidden settings</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Hide grades</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Bad attendance</item>
|
||||
<item>Notes</item>
|
||||
<item>Fake attendance</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Sekretne ustawienia</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Procent frekwencji</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Ukryj oceny</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Słaba frekwencja</item>
|
||||
<item>Uwagi</item>
|
||||
<item>Fałszywa frekwencja</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Секретные настройки</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Процент посещаемости</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Скрыть оценки</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Плохая посещаемость</item>
|
||||
<item>Примечания</item>
|
||||
<item>Фейковая посещаемость</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Skryté nastavenia</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Percento dochádzky</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Skryť známky</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Zlá účasť</item>
|
||||
<item>Poznámky</item>
|
||||
<item>Falošná účasť</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -3,10 +3,4 @@
|
||||
<string name="pref_mod_settings_title">Секретні налаштування</string>
|
||||
<string name="pref_hidden_settings_attendance_percentage">Відсоток відвідуваності</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Приховати оцінки</string>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Погана відвідуваність</item>
|
||||
<item>Примітки</item>
|
||||
<item>Фальшива явка</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<integer name="pref_default_attendance_percentage">-1</integer>
|
||||
</resources>
|
@ -5,11 +5,14 @@
|
||||
<string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
|
||||
<string name="pref_hidden_settings_hidden_grades">Hidden grades</string>
|
||||
|
||||
<string name="pref_key_hidden_grades" translatable="false">hidden_grades</string>
|
||||
<string name="pref_key_attendance_items" translatable="false">attendance_items</string>
|
||||
<string name="pref_key_attendance_percentage" translatable="false">attendance_percentage</string>
|
||||
<string name="pref_default_attendance_percentage" translatable="false">
|
||||
<string name="pref_default_attendance_percentage">-1</string>
|
||||
|
||||
</string>
|
||||
<string name="pref_mod_settings_show_notes">Show notes</string>
|
||||
<string name="pref_key_show_notes" translatable="false">show_notes</string>
|
||||
<bool name="pref_default_show_notes">true</bool>
|
||||
|
||||
<string-array name="mod_settings_attendance_entries">
|
||||
<item>Unexcused absence</item>
|
||||
@ -37,17 +40,6 @@
|
||||
|
||||
</string-array>
|
||||
|
||||
<string-array name="hidden_settings_entries">
|
||||
<item>Bad attendance</item>
|
||||
<item>Notes</item>
|
||||
<item>Fake attendance</item>
|
||||
</string-array>
|
||||
<string-array name="hidden_settings_values" translatable="false">
|
||||
<item>BAD_ATTENDANCE</item>
|
||||
<item>NOTES</item>
|
||||
<item>ATTENDANCE</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="hidden_settings_bad_grades" translatable="false">
|
||||
<item>1</item>
|
||||
<item>1+</item>
|
||||
|
@ -21,45 +21,25 @@
|
||||
app:title="@string/pref_mod_settings_hidden_attendance_items"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceCategory>
|
||||
<!-- <PreferenceCategory-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:title="@string/pref_counted_average_advanced_header">-->
|
||||
<!-- <SwitchPreferenceCompat-->
|
||||
<!-- app:defaultValue="@bool/pref_default_grade_average_force_calc"-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:key="@string/pref_key_grade_average_force_calc"-->
|
||||
<!-- app:singleLineTitle="false"-->
|
||||
<!-- app:title="@string/pref_view_grade_average_force_calc" />-->
|
||||
<!-- <ListPreference-->
|
||||
<!-- app:defaultValue="@string/pref_default_grade_average_mode"-->
|
||||
<!-- app:entries="@array/grade_average_mode_entries"-->
|
||||
<!-- app:entryValues="@array/grade_average_mode_values"-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:key="@string/pref_key_grade_average_mode"-->
|
||||
<!-- app:title="@string/pref_view_grade_average_mode"-->
|
||||
<!-- app:useSimpleSummaryProvider="true" />-->
|
||||
<!-- <SwitchPreferenceCompat-->
|
||||
<!-- app:defaultValue="@bool/pref_default_optional_arithmetic_average"-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:key="@string/pref_key_optional_arithmetic_average"-->
|
||||
<!-- app:singleLineTitle="false"-->
|
||||
<!-- app:title="@string/pref_other_optional_arithmetic_average" />-->
|
||||
<!-- </PreferenceCategory>-->
|
||||
<!-- <PreferenceCategory-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:title="@string/pref_messages_advanced_header">-->
|
||||
<!-- <SwitchPreferenceCompat-->
|
||||
<!-- app:defaultValue="@bool/pref_default_fill_message_content"-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:key="@string/pref_key_fill_message_content"-->
|
||||
<!-- app:singleLineTitle="false"-->
|
||||
<!-- app:title="@string/pref_other_fill_message_content" />-->
|
||||
<!-- <SwitchPreferenceCompat-->
|
||||
<!-- app:defaultValue="@bool/pref_default_incognito_mode"-->
|
||||
<!-- app:iconSpaceReserved="false"-->
|
||||
<!-- app:key="@string/pref_key_incognito_moge"-->
|
||||
<!-- app:singleLineTitle="false"-->
|
||||
<!-- app:title="@string/pref_other_incognito_mode"-->
|
||||
<!-- app:summary="@string/pref_other_incognito_mode_summary" />-->
|
||||
<!-- </PreferenceCategory>-->
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:title="@string/grade_title">
|
||||
<MultiSelectListPreference
|
||||
app:entries="@array/hidden_settings_bad_grades"
|
||||
app:entryValues="@array/hidden_settings_bad_grades"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/pref_key_hidden_grades"
|
||||
app:title="@string/pref_hidden_settings_hidden_grades"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:title="@string/note_title">
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="@bool/pref_default_show_notes"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/pref_key_show_notes"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/pref_mod_settings_show_notes" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user