From 9e278c88e6a261f51ecdcf8f5788a9d0d6902b19 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 2 Jun 2018 18:38:56 +0200 Subject: [PATCH] ExporterPreferences: disable control immediately Signed-off-by: Jason A. Donenfeld --- .../wireguard/android/preference/LogExporterPreference.java | 6 ++++-- .../wireguard/android/preference/ZipExporterPreference.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java b/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java index d73c41bc..cba30522 100644 --- a/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java +++ b/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java @@ -91,9 +91,9 @@ public class LogExporterPreference extends Preference { Snackbar.make( getPrefActivity(this).findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG).show(); + setEnabled(true); } else { exportedFilePath = filePath; - setEnabled(false); notifyChanged(); } } @@ -115,8 +115,10 @@ public class LogExporterPreference extends Preference { getPrefActivity(this).ensurePermissions( new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, (permissions, granted) -> { - if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) + if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) { + setEnabled(false); exportLog(); + } }); } diff --git a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java index 70357e44..b2f22a67 100644 --- a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java +++ b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java @@ -99,9 +99,9 @@ public class ZipExporterPreference extends Preference { Snackbar.make( getPrefActivity(this).findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG).show(); + setEnabled(true); } else { exportedFilePath = filePath; - setEnabled(false); notifyChanged(); } } @@ -123,8 +123,10 @@ public class ZipExporterPreference extends Preference { getPrefActivity(this).ensurePermissions( new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, (permissions, granted) -> { - if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) + if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) { + setEnabled(false); exportZip(); + } }); }