summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android/preference
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-10-02 12:11:48 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-10-02 12:11:48 +0200
commita31f0cf788d98d041943d0c36c7209b25a1356df (patch)
tree6900529cc181904c9d18e48a28ed9ebb68362025 /ui/src/main/java/com/wireguard/android/preference
parent1dc74b171c690dd480953d49dfb19b04056e30db (diff)
DownloadsFileSaver: initialize callback in constructor, not on the fly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/preference')
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt
index aaea7703..b8a1da75 100644
--- a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt
+++ b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt
@@ -32,6 +32,8 @@ import java.util.zip.ZipOutputStream
*/
class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
private var exportedFilePath: String? = null
+ private val downloadsFileSaver = DownloadsFileSaver(activity)
+
private fun exportZip() {
lifecycleScope.launch {
val tunnels = Application.getTunnelManager().getTunnels()
@@ -41,7 +43,7 @@ class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference
if (configs.isEmpty()) {
throw IllegalArgumentException(context.getString(R.string.no_tunnels_error))
}
- val outputFile = DownloadsFileSaver.save(activity, "wireguard-export.zip", "application/zip", true)
+ val outputFile = downloadsFileSaver.save("wireguard-export.zip", "application/zip", true)
if (outputFile == null) {
withContext(Dispatchers.Main.immediate) {
isEnabled = true