add: new settings fragment + basic functionality

This commit is contained in:
sadorowo 2024-03-21 20:17:05 +01:00
parent d068371fb1
commit d17614fa64
21 changed files with 391 additions and 160 deletions

View File

@ -9,6 +9,7 @@ import androidx.core.content.edit
import com.fredporciuncula.flow.preferences.FlowSharedPreferences import com.fredporciuncula.flow.preferences.FlowSharedPreferences
import com.fredporciuncula.flow.preferences.Preference import com.fredporciuncula.flow.preferences.Preference
import com.fredporciuncula.flow.preferences.Serializer import com.fredporciuncula.flow.preferences.Serializer
import com.fredporciuncula.flow.preferences.map
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.data.enums.AppTheme import io.github.wulkanowy.data.enums.AppTheme
@ -308,16 +309,20 @@ class PreferencesRepository @Inject constructor(
} }
var attendancePercentage: Float? var attendancePercentage: Float?
get() { get() = getString(
val value = attendancePercentagePreference.get() R.string.pref_key_attendance_percentage,
return if (value == context.resources.getInteger(R.integer.pref_default_attendance_percentage).toFloat()) { R.string.pref_default_attendance_percentage
null ).let { if (it.isNullOrEmpty()) null else it.toFloat() }
} else { set(value) = sharedPref.edit {
value putString(
} context.getString(R.string.pref_key_attendance_percentage),
value?.toString() ?: "-1"
)
} }
set(value) = value?.let { attendancePercentagePreference.set(it) }
?: attendancePercentagePreference.delete() var hiddenAttendanceItems: List<DashboardItem.HiddenAttendanceTile>
get() = hiddenAttendanceItemsPreference.get().toList()
set(value) = hiddenAttendanceItemsPreference.set(value.toSet())
var hiddenGrades: List<String> var hiddenGrades: List<String>
get() = hiddenGradesPreference.get().toList() get() = hiddenGradesPreference.get().toList()
@ -331,6 +336,20 @@ class PreferencesRepository @Inject constructor(
return flowSharedPref.getStringSet(prefKey, defaultSet) return flowSharedPref.getStringSet(prefKey, defaultSet)
} }
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"
return flowSharedPref
.getStringSet(prefKey, defaultSet)
.map(
mapper = { it -> it.map { DashboardItem.HiddenAttendanceTile.valueOf(it) }.toSet() },
reverse = { it -> it.map { it.name }.toSet() }
)
}
private val selectedDashboardTilesPreference: Preference<Set<String>> private val selectedDashboardTilesPreference: Preference<Set<String>>
get() { get() {
val defaultSet = val defaultSet =

View File

@ -153,6 +153,17 @@ sealed class DashboardItem(val type: Type) {
NOTES, NOTES,
ATTENDANCE, ATTENDANCE,
} }
enum class HiddenAttendanceTile {
UNEXCUSED_ABSENCE,
EXEMPTION,
EXCUSED_LATENESS,
UNEXCUSED_LATENESS,
PRESENT,
DELETED,
EXCUSED_ABSENCE,
UNKNOWN,
}
} }
fun DashboardItem.Tile.toDashboardItemType() = when (this) { fun DashboardItem.Tile.toDashboardItemType() = when (this) {

View File

@ -1,45 +1,19 @@
package io.github.wulkanowy.ui.modules.more package io.github.wulkanowy.ui.modules.more
import android.os.Bundle import android.os.Bundle
import android.text.InputFilter
import android.text.InputType
import android.text.Spanned
import android.view.View import android.view.View
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.databinding.FragmentMoreBinding import io.github.wulkanowy.databinding.FragmentMoreBinding
import io.github.wulkanowy.ui.base.BaseFragment import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.Destination import io.github.wulkanowy.ui.modules.Destination
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
import io.github.wulkanowy.ui.modules.main.MainActivity import io.github.wulkanowy.ui.modules.main.MainActivity
import io.github.wulkanowy.ui.modules.main.MainView import io.github.wulkanowy.ui.modules.main.MainView
import io.github.wulkanowy.ui.modules.message.MessageFragment import io.github.wulkanowy.ui.modules.message.MessageFragment
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
private class AttendancePercentageFilter : InputFilter {
override fun filter(
source: CharSequence?,
start: Int,
end: Int,
dest: Spanned?,
dstart: Int,
dend: Int
): CharSequence? {
val input = dest.toString() + source.toString()
val floatRepresentation = input.toFloatOrNull()
if (floatRepresentation != null && floatRepresentation in 0.0..100.0) return null
return ""
}
}
@AndroidEntryPoint @AndroidEntryPoint
class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more), MoreView, class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more), MoreView,
MainView.TitledView, MainView.MainChildView { MainView.TitledView, MainView.MainChildView {
@ -68,7 +42,6 @@ class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more),
override fun initView() { override fun initView() {
moreAdapter.onClickListener = presenter::onItemSelected moreAdapter.onClickListener = presenter::onItemSelected
moreAdapter.onLongClickListener = presenter::onItemHold
with(binding.moreRecycler) { with(binding.moreRecycler) {
layoutManager = LinearLayoutManager(context) layoutManager = LinearLayoutManager(context)
@ -105,68 +78,6 @@ class MoreFragment : BaseFragment<FragmentMoreBinding>(R.layout.fragment_more),
super.onDestroyView() super.onDestroyView()
} }
private fun showGradeDialog() {
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_hide_grades_title)
.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 showHiddenSettings(data: List<DashboardItem.HiddenSettingTile>) {
val entries = requireContext().resources.getStringArray(R.array.hidden_settings_entries)
val values = requireContext().resources.getStringArray(R.array.hidden_settings_values)
val selectedItemsState = values.map { value -> data.any { it.name == value } }
val attendancePercentage = preferencesRepository.attendancePercentage
val input = EditText(requireContext()).apply {
setPadding(40, 20, 40, 20)
hint = requireContext().getString(R.string.pref_hidden_settings_hint)
filters = arrayOf(AttendancePercentageFilter())
inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL
}
// enable only if attendance modifier is enabled
val attendanceModifierEnabled = data.any { it == DashboardItem.HiddenSettingTile.ATTENDANCE }
input.isEnabled = attendanceModifierEnabled
if (attendancePercentage != null) input.setText(attendancePercentage.toString())
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.pref_hidden_settings_title)
.setMultiChoiceItems(entries, selectedItemsState.toBooleanArray()) { dialog, index, _ ->
// if attendance modifier is enabled, enable text input
if (index == values.indexOf(DashboardItem.HiddenSettingTile.ATTENDANCE.name))
input.isEnabled = (dialog as AlertDialog).listView.checkedItemPositions[index]
}
.setView(input)
.setPositiveButton(android.R.string.ok) { dialog, _ ->
val selectedState = (dialog as AlertDialog).listView.checkedItemPositions
val selectedValues = values.filterIndexed { index, _ -> selectedState[index] }
val inputAttendancePercentage = selectedValues
.find { it == DashboardItem.HiddenSettingTile.ATTENDANCE.name }
?.let { input.text.toString().toFloatOrNull() }
Timber.i("Selected hidden settings: $selectedValues")
presenter.onHiddenSettingsSelected(selectedValues, inputAttendancePercentage)
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
.setNeutralButton(R.string.pref_hidden_settings_hide_grades_title) { _, _ -> showGradeDialog() }
.show()
}
override fun restartApp() { override fun restartApp() {
startActivity(MainActivity.getStartIntent(requireContext())) startActivity(MainActivity.getStartIntent(requireContext()))
requireActivity().finishAffinity() requireActivity().finishAffinity()

View File

@ -6,23 +6,19 @@ import io.github.wulkanowy.data.repositories.StudentRepository
import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.base.ErrorHandler import io.github.wulkanowy.ui.base.ErrorHandler
import io.github.wulkanowy.ui.modules.Destination import io.github.wulkanowy.ui.modules.Destination
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
import okhttp3.internal.notify
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class MorePresenter @Inject constructor( class MorePresenter @Inject constructor(
errorHandler: ErrorHandler, errorHandler: ErrorHandler,
studentRepository: StudentRepository, studentRepository: StudentRepository,
private val preferencesRepository: PreferencesRepository preferencesRepository: PreferencesRepository
) : BasePresenter<MoreView>(errorHandler, studentRepository) { ) : BasePresenter<MoreView>(errorHandler, studentRepository) {
private val moreAppMenuItem = preferencesRepository.appMenuItemOrder private val moreAppMenuItem = preferencesRepository.appMenuItemOrder
.sortedBy { it.order } .sortedBy { it.order }
.drop(4) .drop(4)
private val selectedHiddenSettingsTiles = preferencesRepository.selectedHiddenSettingTiles
override fun onAttachView(view: MoreView) { override fun onAttachView(view: MoreView) {
super.onAttachView(view) super.onAttachView(view)
view.initView() view.initView()
@ -36,30 +32,6 @@ class MorePresenter @Inject constructor(
view?.openView(moreItem.destination) view?.openView(moreItem.destination)
} }
fun onItemHold(moreItem: MoreItem) {
Timber.i("More item hold")
when (moreItem.destination) {
Destination.Settings -> view?.showHiddenSettings(selectedHiddenSettingsTiles)
else -> return
}
}
fun onHiddenSettingsSelected(selectedItems: List<String>, attendance: Float?) {
preferencesRepository.selectedHiddenSettingTiles = selectedItems.map {
DashboardItem.HiddenSettingTile.valueOf(it)
}
preferencesRepository.attendancePercentage = attendance
view?.restartApp()
}
fun onHiddenGradesSelected(selectedItems: List<String>) {
preferencesRepository.hiddenGrades = selectedItems
view?.restartApp()
}
fun onViewReselected() { fun onViewReselected() {
Timber.i("More view is reselected") Timber.i("More view is reselected")
view?.popView(2) view?.popView(2)

View File

@ -2,7 +2,6 @@ package io.github.wulkanowy.ui.modules.more
import io.github.wulkanowy.ui.base.BaseView import io.github.wulkanowy.ui.base.BaseView
import io.github.wulkanowy.ui.modules.Destination import io.github.wulkanowy.ui.modules.Destination
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
interface MoreView : BaseView { interface MoreView : BaseView {
@ -14,7 +13,5 @@ interface MoreView : BaseView {
fun openView(destination: Destination) fun openView(destination: Destination)
fun showHiddenSettings(data: List<DashboardItem.HiddenSettingTile>)
fun restartApp() fun restartApp()
} }

View File

@ -0,0 +1,165 @@
package io.github.wulkanowy.ui.modules.settings.mod_settings
import android.content.SharedPreferences
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.preference.EditTextPreference
import androidx.preference.PreferenceFragmentCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import io.github.wulkanowy.R
import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.ui.base.BaseActivity
import io.github.wulkanowy.ui.base.ErrorDialog
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
import io.github.wulkanowy.ui.modules.main.MainActivity
import io.github.wulkanowy.ui.modules.main.MainView
import io.github.wulkanowy.utils.AppInfo
import timber.log.Timber
import javax.inject.Inject
@AndroidEntryPoint
class ModSettingsFragment : PreferenceFragmentCompat(),
SharedPreferences.OnSharedPreferenceChangeListener,
MainView.TitledView, ModSettingsView {
@Inject
lateinit var presenter: ModSettingsPresenter
@Inject
lateinit var appInfo: AppInfo
@Inject
lateinit var preferencesRepository: PreferencesRepository
override val titleStringId get() = R.string.pref_settings_advanced_title
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
presenter.onAttachView(this)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.scheme_preferences_mod_settings, rootKey)
val etp: EditTextPreference? = findPreference("attendance_percentage")
etp?.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, _, _ ->
if (source == "." && dest.isEmpty()) {
return@InputFilter "0."
}
val input = dest.toString() + source.toString()
if (input == "100.00") {
return@InputFilter null
}
val inputVal = input.toFloatOrNull()
if (inputVal != null && inputVal >= 0 && inputVal <= 100) {
null
} else {
""
}
}
)
}
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
presenter.onSharedPreferenceChanged(key)
}
override fun showError(text: String, error: Throwable) {
(activity as? BaseActivity<*, *>)?.showError(text, error)
}
override fun showMessage(text: String) {
(activity as? BaseActivity<*, *>)?.showMessage(text)
}
override fun showExpiredCredentialsDialog() {
(activity as? BaseActivity<*, *>)?.showExpiredCredentialsDialog()
}
override fun onCaptchaVerificationRequired(url: String?) {
(activity as? BaseActivity<*, *>)?.onCaptchaVerificationRequired(url)
}
override fun showDecryptionFailedDialog() {
(activity as? BaseActivity<*, *>)?.showDecryptionFailedDialog()
}
override fun showChangePasswordSnackbar(redirectUrl: String) {
(activity as? BaseActivity<*, *>)?.showChangePasswordSnackbar(redirectUrl)
}
override fun openClearLoginView() {
(activity as? BaseActivity<*, *>)?.openClearLoginView()
}
override fun showErrorDetailsDialog(error: Throwable) {
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
}
override fun showAuthDialog() {
(activity as? BaseActivity<*, *>)?.showAuthDialog()
}
override fun onResume() {
super.onResume()
preferenceScreen.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
super.onPause()
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)
val selectedItemsState = values.map { value -> items.any { it.name == value } }
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.attendance_title)
.setMultiChoiceItems(entries, selectedItemsState.toBooleanArray()) { _, _, _ -> }
.setPositiveButton(android.R.string.ok) { dialog, _ ->
val selectedState = (dialog as AlertDialog).listView.checkedItemPositions
val selectedValues = values
.filterIndexed { index, _ -> selectedState[index] }
.map { DashboardItem.HiddenAttendanceTile.valueOf(it) }
Timber.i("Selected attendance to hide: $selectedValues")
presenter.onAttendanceSettingsSelected(selectedValues)
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
.show()
}
override fun restartApp() {
startActivity(MainActivity.getStartIntent(requireContext()))
requireActivity().finishAffinity()
}
}

View File

@ -0,0 +1,39 @@
package io.github.wulkanowy.ui.modules.settings.mod_settings
import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.data.repositories.StudentRepository
import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.base.ErrorHandler
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
import io.github.wulkanowy.utils.AnalyticsHelper
import timber.log.Timber
import javax.inject.Inject
class ModSettingsPresenter @Inject constructor(
errorHandler: ErrorHandler,
studentRepository: StudentRepository,
private val analytics: AnalyticsHelper,
private val preferencesRepository: PreferencesRepository
) : BasePresenter<ModSettingsView>(errorHandler, studentRepository) {
override fun onAttachView(view: ModSettingsView) {
super.onAttachView(view)
Timber.i("Mod settings view was initialized")
}
fun onSharedPreferenceChanged(key: String?) {
key ?: return
Timber.i("Change mod settings $key")
analytics.logEvent("setting_changed", "name" to key)
}
fun onHiddenGradesSelected(selectedItems: List<String>) {
preferencesRepository.hiddenGrades = selectedItems
view?.restartApp()
}
fun onAttendanceSettingsSelected(selectedValues: List<DashboardItem.HiddenAttendanceTile>) {
preferencesRepository.hiddenAttendanceItems = selectedValues
view?.restartApp()
}
}

View File

@ -0,0 +1,10 @@
package io.github.wulkanowy.ui.modules.settings.mod_settings
import io.github.wulkanowy.ui.base.BaseView
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
interface ModSettingsView : BaseView {
fun restartApp()
fun showGradeDialogSettings()
fun showAttendanceSettings(items: List<DashboardItem.HiddenAttendanceTile>)
}

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Skrytá nastavení</string> <string name="pref_mod_settings_title">Skrytá nastavení</string>
<string name="pref_hidden_settings_hint">Procento docházky</string> <string name="pref_hidden_settings_attendance_percentage">Procento docházky</string>
<string name="pref_hidden_settings_hide_grades_title">Skrýt známky</string> <string name="pref_hidden_settings_hidden_grades">Skrýt známky</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Špatná účast</item> <item>Špatná účast</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Hidden settings</string> <string name="pref_mod_settings_title">Hidden settings</string>
<string name="pref_hidden_settings_hint">Attendance percentage</string> <string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
<string name="pref_hidden_settings_hide_grades_title">Hide grades</string> <string name="pref_hidden_settings_hidden_grades">Hide grades</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Bad attendance</item> <item>Bad attendance</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Geheime Einstellungen</string> <string name="pref_mod_settings_title">Geheime Einstellungen</string>
<string name="pref_hidden_settings_hint">Prozentuale Erwartung</string> <string name="pref_hidden_settings_attendance_percentage">Prozentuale Erwartung</string>
<string name="pref_hidden_settings_hide_grades_title">Hide Grades</string> <string name="pref_hidden_settings_hidden_grades">Hide Grades</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Schlechte Anwesenheit</item> <item>Schlechte Anwesenheit</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Hidden settings</string> <string name="pref_mod_settings_title">Hidden settings</string>
<string name="pref_hidden_settings_hint">Attendance percentage</string> <string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
<string name="pref_hidden_settings_hide_grades_title">Hide grades</string> <string name="pref_hidden_settings_hidden_grades">Hide grades</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Bad attendance</item> <item>Bad attendance</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Hidden settings</string> <string name="pref_mod_settings_title">Hidden settings</string>
<string name="pref_hidden_settings_hint">Attendance percentage</string> <string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
<string name="pref_hidden_settings_hide_grades_title">Hide grades</string> <string name="pref_hidden_settings_hidden_grades">Hide grades</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Bad attendance</item> <item>Bad attendance</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Sekretne ustawienia</string> <string name="pref_mod_settings_title">Sekretne ustawienia</string>
<string name="pref_hidden_settings_hint">Procent frekwencji</string> <string name="pref_hidden_settings_attendance_percentage">Procent frekwencji</string>
<string name="pref_hidden_settings_hide_grades_title">Ukryj oceny</string> <string name="pref_hidden_settings_hidden_grades">Ukryj oceny</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Słaba frekwencja</item> <item>Słaba frekwencja</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Секретные настройки</string> <string name="pref_mod_settings_title">Секретные настройки</string>
<string name="pref_hidden_settings_hint">Процент посещаемости</string> <string name="pref_hidden_settings_attendance_percentage">Процент посещаемости</string>
<string name="pref_hidden_settings_hide_grades_title">Скрыть оценки</string> <string name="pref_hidden_settings_hidden_grades">Скрыть оценки</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Плохая посещаемость</item> <item>Плохая посещаемость</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Skryté nastavenia</string> <string name="pref_mod_settings_title">Skryté nastavenia</string>
<string name="pref_hidden_settings_hint">Percento dochádzky</string> <string name="pref_hidden_settings_attendance_percentage">Percento dochádzky</string>
<string name="pref_hidden_settings_hide_grades_title">Skryť známky</string> <string name="pref_hidden_settings_hidden_grades">Skryť známky</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Zlá účasť</item> <item>Zlá účasť</item>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Секретні налаштування</string> <string name="pref_mod_settings_title">Секретні налаштування</string>
<string name="pref_hidden_settings_hint">Відсоток відвідуваності</string> <string name="pref_hidden_settings_attendance_percentage">Відсоток відвідуваності</string>
<string name="pref_hidden_settings_hide_grades_title">Приховати оцінки</string> <string name="pref_hidden_settings_hidden_grades">Приховати оцінки</string>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Погана відвідуваність</item> <item>Погана відвідуваність</item>

View File

@ -1,9 +1,41 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_hidden_settings_title">Hidden settings</string> <string name="pref_mod_settings_title">Wulkanowy MOD settings</string>
<string name="pref_hidden_settings_hint">Attendance percentage</string> <string name="pref_mod_settings_hidden_attendance_items">Hidden attendance items</string>
<string name="pref_hidden_settings_attendance_percentage">Attendance percentage</string>
<string name="pref_hidden_settings_hidden_grades">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_key_attendance_percentage" translatable="false">attendance_percentage</string>
<string name="pref_hidden_settings_hide_grades_title">Hide grades</string> <string name="pref_default_attendance_percentage" translatable="false">
</string>
<string-array name="mod_settings_attendance_entries">
<item>Unexcused absence</item>
<item>Exemption</item>
<item>Excused lateness</item>
<item>Unexcused lateness</item>
<item>Present</item>
<item>Deleted</item>
<item>Excused absence</item>
<item>Unknown</item>
</string-array>
<string-array name="mod_settings_attendance_values" translatable="false">
<item>UNEXCUSED_ABSENCE</item>
<item>EXEMPTION</item>
<item>EXCUSED_LATENESS</item>
<item>UNEXCUSED_LATENESS</item>
<item>PRESENT</item>
<item>DELETED</item>
<item>EXCUSED_ABSENCE</item>
<item>UNKNOWN</item>
</string-array>
<string-array name="pref_default_hidden_attendance_items">
</string-array>
<string-array name="hidden_settings_entries"> <string-array name="hidden_settings_entries">
<item>Bad attendance</item> <item>Bad attendance</item>

View File

@ -30,4 +30,9 @@
app:key="about" app:key="about"
app:summary="@string/pref_about_category_summary" app:summary="@string/pref_about_category_summary"
app:title="@string/about_title" /> app:title="@string/about_title" />
<Preference
app:fragment="io.github.wulkanowy.ui.modules.settings.mod_settings.ModSettingsFragment"
app:icon="@drawable/ic_dashboard_warning"
app:key="mod_settings"
app:title="@string/pref_mod_settings_title" />
</PreferenceScreen> </PreferenceScreen>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/attendance_title">
<EditTextPreference
android:inputType="numberDecimal"
android:digits="0123456789"
app:iconSpaceReserved="false"
app:key="@string/pref_key_attendance_percentage"
app:title="@string/pref_hidden_settings_attendance_percentage"
app:useSimpleSummaryProvider="true" />
<MultiSelectListPreference
app:defaultValue="@array/pref_default_hidden_attendance_items"
app:entries="@array/mod_settings_attendance_entries"
app:entryValues="@array/mod_settings_attendance_values"
app:iconSpaceReserved="false"
app:key="@string/pref_key_attendance_items"
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>-->
</PreferenceScreen>

View File

@ -36,4 +36,9 @@
app:key="about" app:key="about"
app:summary="@string/pref_about_category_summary" app:summary="@string/pref_about_category_summary"
app:title="@string/about_title" /> app:title="@string/about_title" />
<Preference
app:fragment="io.github.wulkanowy.ui.modules.settings.mod_settings.ModSettingsFragment"
app:icon="@drawable/ic_dashboard_warning"
app:key="mod_settings"
app:title="@string/pref_hidden_settings_title" />
</PreferenceScreen> </PreferenceScreen>