Skip to content

Commit

Permalink
Merge pull request #1118 from PhenoApps/setting_to_reset_all_settings
Browse files Browse the repository at this point in the history
setting_to_reset_all_settings
  • Loading branch information
trife authored Dec 12, 2024
2 parents 1a4299c + 8d049bc commit 1b35216
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ public class GeneralKeys {
@NotNull
public static final String EXPERIMENTAL_NEW_BRAPI_UI = "com.tracker.fieldbook.preferences.keys.enable_enhanced_brapi_import";

@NotNull
public static final String RESET_PREFERENCES = "RESET_PREFERENCES";

private GeneralKeys() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ class SystemPreferencesFragment : PreferenceFragmentCompat(),
validateBrapiEnabledBeforeSetting(newValue.toString())
}

val resetPref = findPreference<Preference>(GeneralKeys.RESET_PREFERENCES)
resetPref?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
AlertDialog.Builder(context, R.style.AppAlertDialog)
.setTitle(R.string.reset_preferences_title)
.setMessage(R.string.reset_preferences_message)
.setPositiveButton(android.R.string.ok) { _, _ ->
preferences.edit().clear().apply()
activity?.finish()
}
.setNegativeButton(android.R.string.cancel, null)
.show()
true
}
}

override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@
<string name="database_reset_message">Database has been deleted</string>
<string name="share_file_title">Sending file…</string>


<string name="preferences_storage_settings_title">Settings</string>
<string name="preferences_system_defaults_reset">Reset Settings</string>
<string name="reset_preferences_title">Reset Settings to Default</string>
<string name="reset_preferences_message">Warning: this will reset all of Field Book\'s preferences.</string>

<!-- Experimental -->
<string name="preferences_experimental_title">Experimental</string>
<string name="preferences_experimental_stable_title">Stable</string>
Expand Down Expand Up @@ -1380,4 +1386,5 @@
<string name="pref_geonav_distance_threshold_summary">GeoNav automatically stops when distance from all plots exceeds this value in kilometers.</string>
<string name="pref_geonav_distance_threshold_title">Proximity Check</string>
<string name="activity_collect_proximity_warning">GeoNav Stopping, outside proximity of coordinates</string>

</resources>
11 changes: 11 additions & 0 deletions app/src/main/res/xml/preferences_system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@

</PreferenceCategory>

<PreferenceCategory
android:key="settings_operations"
android:title="@string/preferences_storage_settings_title"
app:iconSpaceReserved="false">

<Preference
android:icon="@drawable/ic_refresh"
android:key="RESET_PREFERENCES"
android:title="@string/preferences_system_defaults_reset" />
</PreferenceCategory>

<PreferenceCategory
android:key="crashlytics_category"
android:title="@string/preferences_profile_crashlytics"
Expand Down

0 comments on commit 1b35216

Please sign in to comment.