Skip to content

Commit

Permalink
Set default preference options
Browse files Browse the repository at this point in the history
  • Loading branch information
Hafizzle authored and phillipthelen committed Jul 31, 2023
1 parent d46d26f commit becaf0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Habitica/res/xml/preferences_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
android:key="launch_screen"
android:entries="@array/launch_screen_types"
android:entryValues="@array/launch_screen_values"
android:defaultValue="habits"
android:defaultValue="/user/tasks/habits"
android:layout="@layout/preference_child_summary"/>
<ListPreference android:title="@string/Language_title"
android:key="language"
Expand All @@ -163,11 +163,13 @@
android:key="theme_name"
android:entries="@array/AppThemes"
android:entryValues="@array/AppThemeValues"
android:defaultValue="purple"
android:layout="@layout/preference_child_summary"/>
<ListPreference android:title="@string/theme_mode"
android:key="theme_mode"
android:entries="@array/AppThemeModes"
android:entryValues="@array/AppThemeModeValues"
android:defaultValue="system"
android:layout="@layout/preference_child_summary" />
<CheckBoxPreference android:title="@string/disablePrivateMessages"
android:key="disablePMs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.habitrpg.android.habitica.ui.activities.PrefsActivity
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
import com.habitrpg.android.habitica.ui.views.SnackbarActivity
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGemsDialog
import com.habitrpg.android.habitica.ui.views.preferences.PauseResumeDamageView
import com.habitrpg.android.habitica.ui.views.showAsBottomSheet
import com.habitrpg.common.habitica.helpers.AppTestingLevel
Expand Down Expand Up @@ -393,6 +392,13 @@ class PreferencesFragment : BasePreferencesFragment(),
}
)

val themePreference = findPreference("theme_name") as? ListPreference
if (themePreference?.value == "Default") themePreference.value = "purple"

val themeModePreference = findPreference("theme_mode") as? ListPreference
if (themeModePreference?.value == "Follow System") themeModePreference.value = "system"


if (10 <= (user?.stats?.lvl ?: 0)) {
if (user?.flags?.classSelected == true) {
if (user.preferences?.disableClasses == true) {
Expand Down Expand Up @@ -435,6 +441,9 @@ class PreferencesFragment : BasePreferencesFragment(),
resources.getStringArray(R.array.launch_screen_values).dropLast(1).toTypedArray()
}

val launchScreenPreference = findPreference<ListPreference>("launch_screen")
if (launchScreenPreference?.value == "habits") launchScreenPreference.value = "/user/tasks/habits"

val disablePMsPreference = findPreference("disablePMs") as? CheckBoxPreference
val inbox = user?.inbox
disablePMsPreference?.isChecked = inbox?.optOut ?: true
Expand Down

0 comments on commit becaf0b

Please sign in to comment.