Commit d304ff7a authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added a text to the dialog which shows the progress of the query export

parent 28db82d5
......@@ -54,7 +54,9 @@ class DnsQueryRepository(val dnsQueryDao: DnsQueryDao) {
}.await()
}
fun exportQueriesAsCsvAsync(context: Context, fileReadyCallback:(createdFile: File) ->Unit):Job {
fun exportQueriesAsCsvAsync(context: Context,
fileReadyCallback:(createdFile: File) ->Unit,
countUpdateCallback:(count:Long, total:Int) -> Unit):Job {
val exportDir = File(context.filesDir, "queryexport/")
exportDir.mkdirs()
val exportFile = File(exportDir, "queries.csv")
......@@ -85,6 +87,7 @@ class DnsQueryRepository(val dnsQueryDao: DnsQueryDao) {
outStream.newLine()
outStream.flush()
builder.clear()
if(total % 250 == 0L) countUpdateCallback(total, count)
}
}
outStream.close()
......
......@@ -174,7 +174,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
loadingDialog = LoadingDialog(requireContext(), R.string.dialog_query_export_title, R.string.dialog_query_export_message)
} else loadingDialog = null
loadingDialog?.show()
requireContext().getDatabase().dnsQueryRepository().exportQueriesAsCsvAsync(requireContext()) {file ->
requireContext().getDatabase().dnsQueryRepository().exportQueriesAsCsvAsync(requireContext(), {file ->
if(!isDetached && !isRemoving) {
val uri = FileProvider.getUriForFile(requireContext(), "com.frostnerd.smokescreen.LogZipProvider", file)
val exportIntent = Intent(Intent.ACTION_SEND)
......@@ -196,7 +196,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
startActivity(Intent.createChooser(exportIntent, getString(R.string.title_export_queries)))
}
loadingDialog?.dismiss()
}
}, { count, totalCount ->
activity?.runOnUiThread {
loadingDialog?.appendToMessage("\n\n$count/$totalCount")
}
})
true
}
generateQueries.setOnPreferenceClickListener {
......
Supports Markdown
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