ExporterPreferences: disable control immediately

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-06-02 18:38:56 +02:00
parent c3246060f5
commit 9e278c88e6
2 changed files with 8 additions and 4 deletions

View File

@ -91,9 +91,9 @@ public class LogExporterPreference extends Preference {
Snackbar.make( Snackbar.make(
getPrefActivity(this).findViewById(android.R.id.content), getPrefActivity(this).findViewById(android.R.id.content),
message, Snackbar.LENGTH_LONG).show(); message, Snackbar.LENGTH_LONG).show();
setEnabled(true);
} else { } else {
exportedFilePath = filePath; exportedFilePath = filePath;
setEnabled(false);
notifyChanged(); notifyChanged();
} }
} }
@ -115,8 +115,10 @@ public class LogExporterPreference extends Preference {
getPrefActivity(this).ensurePermissions( getPrefActivity(this).ensurePermissions(
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
(permissions, granted) -> { (permissions, granted) -> {
if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) {
setEnabled(false);
exportLog(); exportLog();
}
}); });
} }

View File

@ -99,9 +99,9 @@ public class ZipExporterPreference extends Preference {
Snackbar.make( Snackbar.make(
getPrefActivity(this).findViewById(android.R.id.content), getPrefActivity(this).findViewById(android.R.id.content),
message, Snackbar.LENGTH_LONG).show(); message, Snackbar.LENGTH_LONG).show();
setEnabled(true);
} else { } else {
exportedFilePath = filePath; exportedFilePath = filePath;
setEnabled(false);
notifyChanged(); notifyChanged();
} }
} }
@ -123,8 +123,10 @@ public class ZipExporterPreference extends Preference {
getPrefActivity(this).ensurePermissions( getPrefActivity(this).ensurePermissions(
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
(permissions, granted) -> { (permissions, granted) -> {
if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) if (granted.length > 0 && granted[0] == PackageManager.PERMISSION_GRANTED) {
setEnabled(false);
exportZip(); exportZip();
}
}); });
} }