Commit 3645a922 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added a preference to clear all logged queries

Implements #57
parent 91647649
Pipeline #4208 passed with stage
in 4 minutes and 50 seconds
......@@ -163,6 +163,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
val queryLogging = findPreference("log_dns_queries")
val exportQueries = findPreference("export_dns_queries")
val generateQueries = findPreference("generate_queries")
val clearQueries = findPreference("clear_dns_queries")
generateQueries.isVisible = BuildConfig.DEBUG || BuildConfig.VERSION_NAME.contains("debug", true)
......@@ -217,6 +218,22 @@ class SettingsFragment : PreferenceFragmentCompat() {
QueryGeneratorDialog(requireContext())
true
}
clearQueries.setOnPreferenceClickListener {
val dialog = AlertDialog.Builder(requireContext(), requireContext().getPreferences().theme.dialogStyle)
dialog.setMessage(R.string.dialog_clearqueries_message)
dialog.setTitle(R.string.dialog_clearqueries_title)
dialog.setPositiveButton(R.string.all_yes) { d, _ ->
requireContext().getDatabase().dnsQueryDao().deleteAll()
exportQueries.summary =
getString(R.string.summary_export_queries, 0)
d.dismiss()
}
dialog.setNegativeButton(R.string.cancel) { d, _ ->
d.dismiss()
}
dialog.show()
true
}
}
@SuppressLint("NewApi")
......
......@@ -58,5 +58,6 @@
<item>Added automatic crash reporting (opt-in)</item>
<item>Added privacy policy</item>
<item>Fixed a lot of crashes</item>
<item>Added a setting to clear logged queries</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -109,4 +109,7 @@
<item>Kernel version</item>
<item>Rooted (yes/no)</item>
</string-array>
<string name="dialog_clearqueries_title">Clear all queries</string>
<string name="dialog_clearqueries_message">Are you sure you want to clear the logged queries? This cannot be reversed.</string>
</resources>
\ No newline at end of file
......@@ -119,4 +119,7 @@
<string name="title_export_queries">Export queries</string>
<string name="summary_export_queries">Export queries as CSV (%1d queries)</string>
<string name="title_delete_queries">Clear queries</string>
<string name="summary_delete_queries">Click here to delete all logged queries.</string>
</resources>
\ No newline at end of file
......@@ -219,5 +219,12 @@
android:title="@string/title_export_queries"
android:dependency="log_dns_queries"
android:summary="@string/summary_export_queries"/>
<Preference
android:key="clear_dns_queries"
android:title="@string/title_delete_queries"
android:summary="@string/summary_delete_queries"
android:dependency="log_dns_queries"
/>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment