global: Some more lint cleanup
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
cb6681b15a
commit
24572aa861
@ -18,18 +18,18 @@ import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
|||||||
* Static methods for use by generated code in the Android data binding library.
|
* Static methods for use by generated code in the Android data binding library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings({"unused"})
|
@SuppressWarnings("unused")
|
||||||
public final class BindingAdapters {
|
public final class BindingAdapters {
|
||||||
private BindingAdapters() {
|
private BindingAdapters() {
|
||||||
// Prevent instantiation.
|
// Prevent instantiation.
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter({"checked"})
|
@BindingAdapter("checked")
|
||||||
public static void setChecked(final ToggleSwitch view, final boolean checked) {
|
public static void setChecked(final ToggleSwitch view, final boolean checked) {
|
||||||
view.setCheckedInternal(checked);
|
view.setCheckedInternal(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter({"filter"})
|
@BindingAdapter("filter")
|
||||||
public static void setFilter(final TextView view, final InputFilter filter) {
|
public static void setFilter(final TextView view, final InputFilter filter) {
|
||||||
view.setFilters(new InputFilter[]{filter});
|
view.setFilters(new InputFilter[]{filter});
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ public final class BindingAdapters {
|
|||||||
adapter.setList(newList);
|
adapter.setList(newList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter({"onBeforeCheckedChanged"})
|
@BindingAdapter("onBeforeCheckedChanged")
|
||||||
public static void setOnBeforeCheckedChanged(final ToggleSwitch view,
|
public static void setOnBeforeCheckedChanged(final ToggleSwitch view,
|
||||||
final OnBeforeCheckedChangeListener listener) {
|
final OnBeforeCheckedChangeListener listener) {
|
||||||
view.setOnBeforeCheckedChangeListener(listener);
|
view.setOnBeforeCheckedChangeListener(listener);
|
||||||
|
@ -70,30 +70,28 @@ public class ZipExporterPreference extends Preference {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompletableFuture.allOf(futureConfigs.toArray(new CompletableFuture[futureConfigs.size()]))
|
CompletableFuture.allOf(futureConfigs.toArray(new CompletableFuture[futureConfigs.size()]))
|
||||||
.whenComplete((ignored1, exception) -> {
|
.whenComplete((ignored1, exception) -> asyncWorker.supplyAsync(() -> {
|
||||||
asyncWorker.supplyAsync(() -> {
|
if (exception != null)
|
||||||
if (exception != null)
|
throw exception;
|
||||||
throw exception;
|
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
final File file = new File(path, "wireguard-export.zip");
|
||||||
final File file = new File(path, "wireguard-export.zip");
|
if (!path.isDirectory() && !path.mkdirs())
|
||||||
if (!path.isDirectory() && !path.mkdirs())
|
throw new IOException("Cannot create output directory");
|
||||||
throw new IOException("Cannot create output directory");
|
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(file))) {
|
||||||
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(file))) {
|
for (int i = 0; i < futureConfigs.size(); ++i) {
|
||||||
for (int i = 0; i < futureConfigs.size(); ++i) {
|
zip.putNextEntry(new ZipEntry(tunnels.get(i).getName() + ".conf"));
|
||||||
zip.putNextEntry(new ZipEntry(tunnels.get(i).getName() + ".conf"));
|
zip.write(futureConfigs.get(i).getNow(null).
|
||||||
zip.write(futureConfigs.get(i).getNow(null).
|
toString().getBytes(StandardCharsets.UTF_8));
|
||||||
toString().getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
zip.closeEntry();
|
|
||||||
zip.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// noinspection ResultOfMethodCallIgnored
|
|
||||||
file.delete();
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
return file.getAbsolutePath();
|
zip.closeEntry();
|
||||||
}).whenComplete(this::exportZipComplete);
|
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) {
|
private void exportZipComplete(final String filePath, final Throwable throwable) {
|
||||||
@ -113,10 +111,9 @@ public class ZipExporterPreference extends Preference {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (exportedFilePath == null)
|
return exportedFilePath == null ?
|
||||||
return getContext().getString(R.string.export_summary);
|
getContext().getString(R.string.export_summary) :
|
||||||
else
|
getContext().getString(R.string.export_success, exportedFilePath);
|
||||||
return getContext().getString(R.string.export_success, exportedFilePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user