summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2018-05-02 10:50:06 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-02 17:14:35 +0200
commit24572aa861c73e87d879bfed5cbbc1ad5ea43f84 (patch)
treeebaddd59769b7a17fea4dade31b32216a1e04c39 /app
parentcb6681b15a9a489c2d572a5f3d73bdc6f376e79e (diff)
global: Some more lint cleanup
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java8
-rw-r--r--app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java51
2 files changed, 28 insertions, 31 deletions
diff --git a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
index 4613257b..d4dd3726 100644
--- a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
+++ b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
@@ -18,18 +18,18 @@ import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
* Static methods for use by generated code in the Android data binding library.
*/
-@SuppressWarnings({"unused"})
+@SuppressWarnings("unused")
public final class BindingAdapters {
private BindingAdapters() {
// Prevent instantiation.
}
- @BindingAdapter({"checked"})
+ @BindingAdapter("checked")
public static void setChecked(final ToggleSwitch view, final boolean checked) {
view.setCheckedInternal(checked);
}
- @BindingAdapter({"filter"})
+ @BindingAdapter("filter")
public static void setFilter(final TextView view, final InputFilter filter) {
view.setFilters(new InputFilter[]{filter});
}
@@ -85,7 +85,7 @@ public final class BindingAdapters {
adapter.setList(newList);
}
- @BindingAdapter({"onBeforeCheckedChanged"})
+ @BindingAdapter("onBeforeCheckedChanged")
public static void setOnBeforeCheckedChanged(final ToggleSwitch view,
final OnBeforeCheckedChangeListener listener) {
view.setOnBeforeCheckedChangeListener(listener);
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 b8e89985..53c19b3c 100644
--- a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
+++ b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
@@ -70,30 +70,28 @@ public class ZipExporterPreference extends Preference {
return;
}
CompletableFuture.allOf(futureConfigs.toArray(new CompletableFuture[futureConfigs.size()]))
- .whenComplete((ignored1, exception) -> {
- asyncWorker.supplyAsync(() -> {
- if (exception != null)
- throw exception;
- final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
- final File file = new File(path, "wireguard-export.zip");
- if (!path.isDirectory() && !path.mkdirs())
- throw new IOException("Cannot create output directory");
- try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(file))) {
- for (int i = 0; i < futureConfigs.size(); ++i) {
- zip.putNextEntry(new ZipEntry(tunnels.get(i).getName() + ".conf"));
- zip.write(futureConfigs.get(i).getNow(null).
- toString().getBytes(StandardCharsets.UTF_8));
- }
- zip.closeEntry();
- zip.close();
- } catch (Exception e) {
- // noinspection ResultOfMethodCallIgnored
- file.delete();
- throw e;
+ .whenComplete((ignored1, exception) -> asyncWorker.supplyAsync(() -> {
+ if (exception != null)
+ throw exception;
+ final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+ final File file = new File(path, "wireguard-export.zip");
+ if (!path.isDirectory() && !path.mkdirs())
+ throw new IOException("Cannot create output directory");
+ try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(file))) {
+ for (int i = 0; i < futureConfigs.size(); ++i) {
+ zip.putNextEntry(new ZipEntry(tunnels.get(i).getName() + ".conf"));
+ zip.write(futureConfigs.get(i).getNow(null).
+ toString().getBytes(StandardCharsets.UTF_8));
}
- return file.getAbsolutePath();
- }).whenComplete(this::exportZipComplete);
- });
+ zip.closeEntry();
+ zip.close();
+ } catch (Exception e) {
+ // noinspection ResultOfMethodCallIgnored
+ file.delete();
+ throw e;
+ }
+ return file.getAbsolutePath();
+ }).whenComplete(this::exportZipComplete));
}
private void exportZipComplete(final String filePath, final Throwable throwable) {
@@ -113,10 +111,9 @@ public class ZipExporterPreference extends Preference {
@Override
public CharSequence getSummary() {
- if (exportedFilePath == null)
- return getContext().getString(R.string.export_summary);
- else
- return getContext().getString(R.string.export_success, exportedFilePath);
+ return exportedFilePath == null ?
+ getContext().getString(R.string.export_summary) :
+ getContext().getString(R.string.export_success, exportedFilePath);
}
@Override