add developer mode
This commit is contained in:
Franek 2024-03-22 17:07:45 +01:00 committed by GitHub
commit ecae5d96c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 141 additions and 14 deletions

View File

@ -8,7 +8,12 @@
* Skrýt komentáře. * Skrýt komentáře.
* falešná docházka % * falešná docházka %
Pro přístup ke skrytému panelu přejděte na kartu "Více", poté na "Nastavení" a nakonec klikněte na poslední dlaždici. Přístup ke skrytému panelu:
1. Přejděte na záložku "Více".
2. přejděte na panel "Nastavení".
3. přejděte na panel "O aplikaci".
4. Klikněte pětkrát na logo aplikace
5. přejděte zpět do nastavení (budete muset obnovit zobrazení, přejít na domovskou obrazovku a vrátit se do nastavení).
# Wulkanowy # Wulkanowy

View File

@ -8,7 +8,12 @@
* Kommentare ausblenden. * Kommentare ausblenden.
* Anwesenheit fälschen % * Anwesenheit fälschen %
Um auf das verborgene Panel zuzugreifen, gehen Sie auf die Registerkarte "Mehr", dann auf "Einstellungen" und schließlich auf die letzte Kachel. So greifen Sie auf das verborgene Panel zu:
1. Gehen Sie auf die Registerkarte "Mehr".
2. Gehen Sie zum Bereich "Einstellungen".
3. Gehen Sie auf das Feld "Über die Anwendung".
4. Klicken Sie 5 Mal auf das Logo der Anwendung
5. Gehen Sie zurück zu den Einstellungen (Sie müssen die Ansicht aktualisieren, zum Startbildschirm wechseln und zu den Einstellungen zurückkehren)
# Wulkanowy # Wulkanowy

View File

@ -8,7 +8,12 @@
* hide comments * hide comments
* fake attendance %. * fake attendance %.
To get to the hidden panel, go to the "More" tab, then "Settings", and finally click the last tile. To get to the hidden panel:
1. go to the "More" tab
2. go to the "Settings" panel
3. go to the "About application" panel
4. click 5 times on the application logo
5. go back to settings (a refresh of the view will be required, go to the home screen and return to settings)
# Wulkanowy # Wulkanowy

View File

@ -8,7 +8,12 @@
* ukryj uwagi * ukryj uwagi
* sfałszuj % frekwencji * sfałszuj % frekwencji
Aby dostać się do ukrytego panelu, przejdź do karty "Więcej", następnie "Ustawienia", a na końcu kliknij ostatni kafelek. Aby dostać się do ukrytego panelu:
1. Przejdź do karty "Więcej"
2. Przejdź do panelu "Ustawienia"
3. Przejdź do panelu "O aplikacji"
4. Kliknij 5 razy w logo aplikacji
5. Wróć do ustawień (wymagane będzie odświeżenie widoku, przejdź na ekran główny i wróć do ustawień)
# Wulkanowy # Wulkanowy

View File

@ -8,7 +8,12 @@
* Skryť komentáre. * Skryť komentáre.
* falošná dochádzka % * falošná dochádzka %
Ak chcete získať prístup k skrytému panelu, prejdite na kartu "Viac", potom na "Nastavenia" a nakoniec kliknite na poslednú dlaždicu. Prístup k skrytému panelu:
1. Prejdite na kartu "Viac".
2. prejdite na panel "Nastavenia".
3. prejdite na panel "O aplikácii"
4. 5-krát kliknite na logo aplikácie
5. vráťte sa do nastavení (budete musieť obnoviť zobrazenie, prejsť na domovskú obrazovku a vrátiť sa do nastavení)
# Wulkanowy # Wulkanowy

View File

@ -28,7 +28,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 34 targetSdkVersion 34
versionCode 151 versionCode 151
versionName "2.6.0" versionName "2.6.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "app_name", "Wulkanowy" resValue "string", "app_name", "Wulkanowy"

View File

@ -313,6 +313,16 @@ class PreferencesRepository @Inject constructor(
get() = showNotesPreference.get() get() = showNotesPreference.get()
set(value) = showNotesPreference.set(value) set(value) = showNotesPreference.set(value)
var developerMode: Boolean
get() = developerModePreference.get()
set(value) = developerModePreference.set(value)
private val developerModePreference: Preference<Boolean>
get() = flowSharedPref.getBoolean(
context.getString(R.string.pref_key_developer_mode),
context.resources.getBoolean(R.bool.pref_default_developer_mode)
)
private val hiddenGradesPreference: Preference<Set<String>> private val hiddenGradesPreference: Preference<Set<String>>
get() { get() {
val defaultSet = context.resources.getStringArray(R.array.pref_default_hidden_grades).toSet() val defaultSet = context.resources.getStringArray(R.array.pref_default_hidden_grades).toSet()

View File

@ -3,14 +3,19 @@ package io.github.wulkanowy.ui.modules.about
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.databinding.ItemAboutBinding import io.github.wulkanowy.databinding.ItemAboutBinding
import io.github.wulkanowy.databinding.ScrollableHeaderAboutBinding import io.github.wulkanowy.databinding.ScrollableHeaderAboutBinding
import javax.inject.Inject import javax.inject.Inject
class AboutAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView.ViewHolder>() { class AboutAdapter @Inject constructor(
private val preferencesRepository: PreferencesRepository
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var developerModeClicks = 0
private enum class ViewType(val id: Int) { private enum class ViewType(val id: Int) {
ITEM_HEADER(1), ITEM_HEADER(1),
ITEM_ELEMENT(2) ITEM_ELEMENT(2)
@ -46,6 +51,19 @@ class AboutAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView.Vie
private fun bindHeaderViewHolder(binding: ScrollableHeaderAboutBinding) { private fun bindHeaderViewHolder(binding: ScrollableHeaderAboutBinding) {
with(binding.aboutScrollableHeaderIcon) { with(binding.aboutScrollableHeaderIcon) {
setOnClickListener {
if (++developerModeClicks == 5 && !preferencesRepository.developerMode) {
preferencesRepository.developerMode = true
developerModeClicks = 0
Toast.makeText(
context,
"done!",
Toast.LENGTH_SHORT
).show()
}
}
setImageDrawable(ResourcesCompat.getDrawableForDensity( setImageDrawable(ResourcesCompat.getDrawableForDensity(
context.resources, context.applicationInfo.icon, 640, null) context.resources, context.applicationInfo.icon, 640, null)
) )

View File

@ -1,13 +1,22 @@
package io.github.wulkanowy.ui.modules.settings package io.github.wulkanowy.ui.modules.settings
import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceScreen
import dagger.hilt.android.AndroidEntryPoint
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.ui.base.BaseActivity import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.ui.modules.main.MainView import io.github.wulkanowy.ui.modules.main.MainView
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject
class SettingsFragment : PreferenceFragmentCompat(), MainView.TitledView, SettingsView { @AndroidEntryPoint
class SettingsFragment : PreferenceFragmentCompat(),
SharedPreferences.OnSharedPreferenceChangeListener,
MainView.TitledView, SettingsView {
companion object { companion object {
@ -16,11 +25,26 @@ class SettingsFragment : PreferenceFragmentCompat(), MainView.TitledView, Settin
override val titleStringId get() = R.string.settings_title override val titleStringId get() = R.string.settings_title
@Inject
lateinit var preferencesRepository: PreferencesRepository
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.scheme_preferences, rootKey) setPreferencesFromResource(R.xml.scheme_preferences, rootKey)
val prefScreen: PreferenceScreen? = findPreference("settings_preferences")
val prefDeveloper: Preference? = findPreference("mod_settings")
if (!preferencesRepository.developerMode && prefScreen != null && prefDeveloper != null) {
prefScreen.removePreference(prefDeveloper)
}
Timber.i("Settings view was initialized") Timber.i("Settings view was initialized")
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, rootKey: String?) {
setPreferencesFromResource(R.xml.scheme_preferences, rootKey)
}
override fun showError(text: String, error: Throwable) {} override fun showError(text: String, error: Throwable) {}
override fun showMessage(text: String) {} override fun showMessage(text: String) {}

View File

@ -16,4 +16,6 @@
<item>Ospravedlněná absence</item> <item>Ospravedlněná absence</item>
<item>Neznámá</item> <item>Neznámá</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Režim pro vývojáře (přístup na tuto stránku)</string>
<string name="pref_mod_settings_developer_mode_summary">Po deaktivaci tohoto nastavení již nebudete mít přístup na tuto stránku, ale nastavení se bude nadále používat.</string>
</resources> </resources>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View File

@ -883,4 +883,5 @@
<string name="message_unmute">Zrušit ztlumení</string> <string name="message_unmute">Zrušit ztlumení</string>
<string name="message_mute_success">Ztlumili jste tohoto uživatele</string> <string name="message_mute_success">Ztlumili jste tohoto uživatele</string>
<string name="message_unmute_success">Zrušili jste ztlumení tohoto uživatele</string> <string name="message_unmute_success">Zrušili jste ztlumení tohoto uživatele</string>
<string name="pref_mod_settings_other_title">Jiné</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Excused absence</item> <item>Excused absence</item>
<item>Unknown</item> <item>Unknown</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Developer mode (access to this page)</string>
<string name="pref_mod_settings_developer_mode_summary">After disabling this setting, you will not be able to access this page anymore, but the settings will still be applied.</string>
</resources> </resources>

View File

@ -754,4 +754,5 @@
<string name="error_feature_disabled">Feature disabled by your school</string> <string name="error_feature_disabled">Feature disabled by your school</string>
<string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string> <string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string>
<string name="error_field_required">This field is required</string> <string name="error_field_required">This field is required</string>
<string name="pref_mod_settings_other_title">Other</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Unentschuldigtes Fehlen</item> <item>Unentschuldigtes Fehlen</item>
<item>Unbekannt</item> <item>Unbekannt</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Entwicklermodus (Zugang zu dieser Seite)</string>
<string name="pref_mod_settings_developer_mode_summary">Wenn Sie diese Einstellung deaktivieren, können Sie nicht mehr auf diese Seite zugreifen, aber die Einstellungen werden weiterhin angewendet.</string>
</resources> </resources>

View File

@ -789,4 +789,5 @@
<string name="message_unmute">Unmute</string> <string name="message_unmute">Unmute</string>
<string name="message_mute_success">You have muted this user</string> <string name="message_mute_success">You have muted this user</string>
<string name="message_unmute_success">You have unmuted this user</string> <string name="message_unmute_success">You have unmuted this user</string>
<string name="pref_mod_settings_other_title">Sonstiges</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Excused absence</item> <item>Excused absence</item>
<item>Unknown</item> <item>Unknown</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Developer mode (access to this page)</string>
<string name="pref_mod_settings_developer_mode_summary">After disabling this setting, you will not be able to access this page anymore, but the settings will still be applied.</string>
</resources> </resources>

View File

@ -754,4 +754,5 @@
<string name="error_feature_disabled">Feature disabled by your school</string> <string name="error_feature_disabled">Feature disabled by your school</string>
<string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string> <string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string>
<string name="error_field_required">This field is required</string> <string name="error_field_required">This field is required</string>
<string name="pref_mod_settings_other_title">Other</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Excused absence</item> <item>Excused absence</item>
<item>Unknown</item> <item>Unknown</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Developer mode (access to this page)</string>
<string name="pref_mod_settings_developer_mode_summary">After disabling this setting, you will not be able to access this page anymore, but the settings will still be applied.</string>
</resources> </resources>

View File

@ -754,4 +754,5 @@
<string name="error_feature_disabled">Feature disabled by your school</string> <string name="error_feature_disabled">Feature disabled by your school</string>
<string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string> <string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string>
<string name="error_field_required">This field is required</string> <string name="error_field_required">This field is required</string>
<string name="pref_mod_settings_other_title">Other</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Nieobecność usprawiedliwiona</item> <item>Nieobecność usprawiedliwiona</item>
<item>Nieznane</item> <item>Nieznane</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Tryb dewelopera (dostęp do tej strony)</string>
<string name="pref_mod_settings_developer_mode_summary">Po wyłączeniu tego ustawienia nie będzie już można uzyskać dostępu do tej strony, ale ustawienia będą zachowane.</string>
</resources> </resources>

View File

@ -883,4 +883,5 @@
<string name="message_unmute">Wyłącz wyciszenie</string> <string name="message_unmute">Wyłącz wyciszenie</string>
<string name="message_mute_success">Wyciszyleś tego użytkownika</string> <string name="message_mute_success">Wyciszyleś tego użytkownika</string>
<string name="message_unmute_success">Wyłączyłeś wyciszenie tego użytkownika</string> <string name="message_unmute_success">Wyłączyłeś wyciszenie tego użytkownika</string>
<string name="pref_mod_settings_other_title">Inne</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Отсутствие без уважительной причины</item> <item>Отсутствие без уважительной причины</item>
<item>Неизвестный</item> <item>Неизвестный</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Режим разработчика (доступ к этой странице)</string>
<string name="pref_mod_settings_developer_mode_summary">После отключения этой настройки вы больше не сможете зайти на эту страницу, но настройки все равно будут применены.</string>
</resources> </resources>

View File

@ -883,4 +883,5 @@
<string name="message_unmute">Unmute</string> <string name="message_unmute">Unmute</string>
<string name="message_mute_success">You have muted this user</string> <string name="message_mute_success">You have muted this user</string>
<string name="message_unmute_success">You have unmuted this user</string> <string name="message_unmute_success">You have unmuted this user</string>
<string name="pref_mod_settings_other_title">Прочее</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Ospravedlnená absencia</item> <item>Ospravedlnená absencia</item>
<item>Neznámy</item> <item>Neznámy</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Vývojársky režim (prístup na túto stránku)</string>
<string name="pref_mod_settings_developer_mode_summary">Po vypnutí tohto nastavenia už nebudete mať prístup na túto stránku, ale nastavenia sa budú naďalej uplatňovať.</string>
</resources> </resources>

View File

@ -883,4 +883,5 @@
<string name="message_unmute">Zrušiť stlmenie</string> <string name="message_unmute">Zrušiť stlmenie</string>
<string name="message_mute_success">Stlmili ste tohto používateľa</string> <string name="message_mute_success">Stlmili ste tohto používateľa</string>
<string name="message_unmute_success">Zrušili ste stlmenie tohto používateľa</string> <string name="message_unmute_success">Zrušili ste stlmenie tohto používateľa</string>
<string name="pref_mod_settings_other_title">Iné</string>
</resources> </resources>

View File

@ -16,4 +16,6 @@
<item>Поважна відсутність</item> <item>Поважна відсутність</item>
<item>Невідомо</item> <item>Невідомо</item>
</string-array> </string-array>
<string name="pref_mod_settings_developer_mode">Режим розробника (доступ до цієї сторінки)</string>
<string name="pref_mod_settings_developer_mode_summary">Після вимкнення цього налаштування ви більше не зможете отримати доступ до цієї сторінки, але налаштування все одно будуть застосовані.</string>
</resources> </resources>

View File

@ -883,4 +883,5 @@
<string name="message_unmute">Ввімкнути сповіщення</string> <string name="message_unmute">Ввімкнути сповіщення</string>
<string name="message_mute_success">Ви ігноруєте цього користувача</string> <string name="message_mute_success">Ви ігноруєте цього користувача</string>
<string name="message_unmute_success">Ви не ігноруєте цього користувача</string> <string name="message_unmute_success">Ви не ігноруєте цього користувача</string>
<string name="pref_mod_settings_other_title">Інше</string>
</resources> </resources>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="pref_mod_settings_title">Wulkanowy MOD settings</string> <string name="pref_mod_settings_title">Hidden settings</string>
<string name="pref_mod_settings_hidden_attendance_items">Hidden attendance items</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_attendance_percentage">Attendance percentage</string>
<string name="pref_hidden_settings_hidden_grades">Hidden grades</string> <string name="pref_hidden_settings_hidden_grades">Hidden grades</string>
@ -8,10 +8,15 @@
<string name="pref_key_hidden_grades" translatable="false">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_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_key_developer_mode" translatable="false">developer_mode</string>
<string name="pref_default_attendance_percentage" translatable="false">-1</string> <string name="pref_default_attendance_percentage" translatable="false">-1</string>
<string name="pref_mod_settings_show_notes">Show notes</string>
<string name="pref_key_show_notes" translatable="false">show_notes</string> <string name="pref_key_show_notes" translatable="false">show_notes</string>
<string name="pref_mod_settings_developer_mode">Developer mode (access to this page)</string>
<string name="pref_mod_settings_developer_mode_summary">After disabling this setting, you will not be able to access this page anymore, but the settings will still be applied.</string>
<string name="pref_mod_settings_show_notes">Show notes</string>
<bool name="pref_default_developer_mode">false</bool>
<bool name="pref_default_show_notes">true</bool> <bool name="pref_default_show_notes">true</bool>
<string-array name="mod_settings_attendance_entries"> <string-array name="mod_settings_attendance_entries">

View File

@ -884,4 +884,5 @@
<string name="message_unmute">Unmute</string> <string name="message_unmute">Unmute</string>
<string name="message_mute_success">You have muted this user</string> <string name="message_mute_success">You have muted this user</string>
<string name="message_unmute_success">You have unmuted this user</string> <string name="message_unmute_success">You have unmuted this user</string>
<string name="pref_mod_settings_other_title">Other</string>
</resources> </resources>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto"
app:key="settings_preferences">
<Preference <Preference
app:fragment="io.github.wulkanowy.ui.modules.settings.appearance.AppearanceFragment" app:fragment="io.github.wulkanowy.ui.modules.settings.appearance.AppearanceFragment"
app:icon="@drawable/ic_settings_appearance" app:icon="@drawable/ic_settings_appearance"

View File

@ -42,4 +42,15 @@
app:singleLineTitle="false" app:singleLineTitle="false"
app:title="@string/pref_mod_settings_show_notes" /> app:title="@string/pref_mod_settings_show_notes" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/pref_mod_settings_other_title">
<SwitchPreferenceCompat
app:defaultValue="@bool/pref_default_developer_mode"
app:iconSpaceReserved="false"
app:key="@string/pref_key_developer_mode"
app:singleLineTitle="false"
app:title="@string/pref_mod_settings_developer_mode"
app:summary="@string/pref_mod_settings_developer_mode_summary"/>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto"
app:key="settings_preferences">
<Preference <Preference
app:fragment="io.github.wulkanowy.ui.modules.settings.appearance.AppearanceFragment" app:fragment="io.github.wulkanowy.ui.modules.settings.appearance.AppearanceFragment"
app:icon="@drawable/ic_settings_appearance" app:icon="@drawable/ic_settings_appearance"