diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java index 853802d2..4c18d98b 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java @@ -5,11 +5,9 @@ package com.wireguard.android.backend; +import com.wireguard.config.Config; import com.wireguard.util.NonNullForAll; -import com.wireguard.config.Config; - -import java.util.Collection; import java.util.Set; import androidx.annotation.Nullable; diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java index bf434cf5..54dc913a 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -5,14 +5,10 @@ package com.wireguard.android.backend; -import com.wireguard.util.NonNullForAll; - import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.ParcelFileDescriptor; -import androidx.annotation.Nullable; -import androidx.collection.ArraySet; import android.util.Log; import com.wireguard.android.backend.BackendException.Reason; @@ -23,6 +19,7 @@ import com.wireguard.config.InetNetwork; import com.wireguard.config.Peer; import com.wireguard.crypto.Key; import com.wireguard.crypto.KeyFormatException; +import com.wireguard.util.NonNullForAll; import java.net.InetAddress; import java.util.Collections; @@ -30,6 +27,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import androidx.annotation.Nullable; +import androidx.collection.ArraySet; import java9.util.concurrent.CompletableFuture; @NonNullForAll diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java index f878a1f0..54bbe912 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java @@ -5,12 +5,11 @@ package com.wireguard.android.backend; -import com.wireguard.util.NonNullForAll; - import android.os.SystemClock; import android.util.Pair; import com.wireguard.crypto.Key; +import com.wireguard.util.NonNullForAll; import java.util.HashMap; import java.util.Map; diff --git a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java index c4434e4d..d57a92f9 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java @@ -5,10 +5,6 @@ package com.wireguard.android.backend; -import com.wireguard.util.NonNullForAll; - -import androidx.annotation.Nullable; - import android.content.Context; import android.util.Log; import android.util.Pair; @@ -19,6 +15,7 @@ import com.wireguard.android.util.RootShell; import com.wireguard.android.util.ToolsInstaller; import com.wireguard.config.Config; import com.wireguard.crypto.Key; +import com.wireguard.util.NonNullForAll; import java.io.File; import java.io.FileOutputStream; @@ -26,14 +23,15 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.HashMap; +import androidx.annotation.Nullable; import java9.util.stream.Collectors; import java9.util.stream.Stream; diff --git a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java index 40645a43..519ad5cf 100644 --- a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java +++ b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java @@ -5,13 +5,12 @@ package com.wireguard.android.util; -import com.wireguard.util.NonNullForAll; - import android.content.Context; import android.system.OsConstants; import android.util.Base64; import com.wireguard.android.util.RootShell.RootShellException; +import com.wireguard.util.NonNullForAll; import net.i2p.crypto.eddsa.EdDSAEngine; import net.i2p.crypto.eddsa.EdDSAPublicKey; diff --git a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java index eccc61cb..9f941815 100644 --- a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java +++ b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java @@ -5,13 +5,11 @@ package com.wireguard.android.util; -import com.wireguard.util.NonNullForAll; - import android.content.Context; -import androidx.annotation.Nullable; import android.util.Log; import com.wireguard.android.util.RootShell.RootShellException.Reason; +import com.wireguard.util.NonNullForAll; import java.io.BufferedReader; import java.io.File; @@ -22,6 +20,8 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.UUID; +import androidx.annotation.Nullable; + /** * Helper class for running commands as root. */ diff --git a/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java b/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java index 3c2448fe..f4670b14 100644 --- a/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java +++ b/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java @@ -5,12 +5,12 @@ package com.wireguard.android.util; -import com.wireguard.util.NonNullForAll; - import android.content.Context; import android.os.Build; import android.util.Log; +import com.wireguard.util.NonNullForAll; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; diff --git a/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java b/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java index 1ce3fe80..f12e755f 100644 --- a/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java +++ b/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java @@ -5,14 +5,12 @@ package com.wireguard.android.util; -import com.wireguard.util.NonNullForAll; - import android.content.Context; -import androidx.annotation.Nullable; import android.system.OsConstants; import android.util.Log; import com.wireguard.android.util.RootShell.RootShellException; +import com.wireguard.util.NonNullForAll; import java.io.File; import java.io.FileNotFoundException; @@ -20,6 +18,8 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; +import androidx.annotation.Nullable; + /** * Helper to install WireGuard tools to the system partition. */ diff --git a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java index 89b3af2c..f1577e91 100644 --- a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java +++ b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java @@ -5,12 +5,11 @@ package com.wireguard.config; +import com.wireguard.crypto.KeyFormatException; import com.wireguard.util.NonNullForAll; import androidx.annotation.Nullable; -import com.wireguard.crypto.KeyFormatException; - @NonNullForAll public class BadConfigException extends Exception { private final Location location; diff --git a/tunnel/src/main/java/com/wireguard/config/Config.java b/tunnel/src/main/java/com/wireguard/config/Config.java index f86eb6fd..c45dccb6 100644 --- a/tunnel/src/main/java/com/wireguard/config/Config.java +++ b/tunnel/src/main/java/com/wireguard/config/Config.java @@ -5,13 +5,10 @@ package com.wireguard.config; -import com.wireguard.util.NonNullForAll; - -import androidx.annotation.Nullable; - import com.wireguard.config.BadConfigException.Location; import com.wireguard.config.BadConfigException.Reason; import com.wireguard.config.BadConfigException.Section; +import com.wireguard.util.NonNullForAll; import java.io.BufferedReader; import java.io.IOException; @@ -25,6 +22,8 @@ import java.util.List; import java.util.Objects; import java.util.Set; +import androidx.annotation.Nullable; + /** * Represents the contents of a wg-quick configuration file, made up of one or more "Interface" * sections (combined together), and zero or more "Peer" sections (treated individually). diff --git a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java index 69c60806..0120de0e 100644 --- a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java +++ b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java @@ -7,8 +7,6 @@ package com.wireguard.config; import com.wireguard.util.NonNullForAll; -import androidx.annotation.Nullable; - import org.threeten.bp.Duration; import org.threeten.bp.Instant; @@ -19,6 +17,7 @@ import java.net.URISyntaxException; import java.net.UnknownHostException; import java.util.regex.Pattern; +import androidx.annotation.Nullable; import java9.util.Optional; diff --git a/tunnel/src/main/java/com/wireguard/config/Interface.java b/tunnel/src/main/java/com/wireguard/config/Interface.java index efe00ce7..32621d2f 100644 --- a/tunnel/src/main/java/com/wireguard/config/Interface.java +++ b/tunnel/src/main/java/com/wireguard/config/Interface.java @@ -5,16 +5,13 @@ package com.wireguard.config; -import com.wireguard.util.NonNullForAll; - -import androidx.annotation.Nullable; - import com.wireguard.config.BadConfigException.Location; import com.wireguard.config.BadConfigException.Reason; import com.wireguard.config.BadConfigException.Section; import com.wireguard.crypto.Key; import com.wireguard.crypto.KeyFormatException; import com.wireguard.crypto.KeyPair; +import com.wireguard.util.NonNullForAll; import java.net.InetAddress; import java.util.Collection; @@ -25,6 +22,7 @@ import java.util.Locale; import java.util.Objects; import java.util.Set; +import androidx.annotation.Nullable; import java9.util.Lists; import java9.util.Optional; import java9.util.stream.Collectors; diff --git a/tunnel/src/main/java/com/wireguard/config/Peer.java b/tunnel/src/main/java/com/wireguard/config/Peer.java index ef91a306..984dbe9c 100644 --- a/tunnel/src/main/java/com/wireguard/config/Peer.java +++ b/tunnel/src/main/java/com/wireguard/config/Peer.java @@ -5,15 +5,12 @@ package com.wireguard.config; -import com.wireguard.util.NonNullForAll; - -import androidx.annotation.Nullable; - import com.wireguard.config.BadConfigException.Location; import com.wireguard.config.BadConfigException.Reason; import com.wireguard.config.BadConfigException.Section; import com.wireguard.crypto.Key; import com.wireguard.crypto.KeyFormatException; +import com.wireguard.util.NonNullForAll; import java.util.Collection; import java.util.Collections; @@ -22,6 +19,7 @@ import java.util.Locale; import java.util.Objects; import java.util.Set; +import androidx.annotation.Nullable; import java9.util.Optional; /** diff --git a/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java b/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java index 7628c566..efc22d6e 100644 --- a/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java +++ b/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java @@ -8,10 +8,10 @@ package com.wireguard.crypto; import com.wireguard.util.NonNullForAll; -import androidx.annotation.Nullable; - import java.util.Arrays; +import androidx.annotation.Nullable; + /** * Implementation of the Curve25519 elliptic curve algorithm. *
diff --git a/tunnel/src/main/java/com/wireguard/crypto/Key.java b/tunnel/src/main/java/com/wireguard/crypto/Key.java
index e46150bd..fe03fa2d 100644
--- a/tunnel/src/main/java/com/wireguard/crypto/Key.java
+++ b/tunnel/src/main/java/com/wireguard/crypto/Key.java
@@ -5,9 +5,8 @@
package com.wireguard.crypto;
-import com.wireguard.util.NonNullForAll;
-
import com.wireguard.crypto.KeyFormatException.Type;
+import com.wireguard.util.NonNullForAll;
import java.security.MessageDigest;
import java.security.SecureRandom;
diff --git a/ui/src/main/java/com/wireguard/android/Application.java b/ui/src/main/java/com/wireguard/android/Application.java
index d3e0aa5f..52d5e1ea 100644
--- a/ui/src/main/java/com/wireguard/android/Application.java
+++ b/ui/src/main/java/com/wireguard/android/Application.java
@@ -5,8 +5,6 @@
package com.wireguard.android;
-import com.wireguard.util.NonNullForAll;
-
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -17,10 +15,6 @@ import android.os.Looper;
import android.os.StrictMode;
import android.util.Log;
-import androidx.preference.PreferenceManager;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatDelegate;
-
import com.wireguard.android.backend.Backend;
import com.wireguard.android.backend.GoBackend;
import com.wireguard.android.backend.WgQuickBackend;
@@ -31,10 +25,14 @@ import com.wireguard.android.util.ExceptionLoggers;
import com.wireguard.android.util.ModuleLoader;
import com.wireguard.android.util.RootShell;
import com.wireguard.android.util.ToolsInstaller;
+import com.wireguard.util.NonNullForAll;
import java.lang.ref.WeakReference;
import java.util.Locale;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatDelegate;
+import androidx.preference.PreferenceManager;
import java9.util.concurrent.CompletableFuture;
@NonNullForAll
diff --git a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
index f5232d50..3f4bcd83 100644
--- a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
+++ b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
@@ -5,8 +5,6 @@
package com.wireguard.android;
-import com.wireguard.util.NonNullForAll;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -15,6 +13,7 @@ import android.util.Log;
import com.wireguard.android.backend.WgQuickBackend;
import com.wireguard.android.model.TunnelManager;
import com.wireguard.android.util.ExceptionLoggers;
+import com.wireguard.util.NonNullForAll;
@NonNullForAll
public class BootShutdownReceiver extends BroadcastReceiver {
diff --git a/ui/src/main/java/com/wireguard/android/QuickTileService.java b/ui/src/main/java/com/wireguard/android/QuickTileService.java
index f18d01b1..a485ae1e 100644
--- a/ui/src/main/java/com/wireguard/android/QuickTileService.java
+++ b/ui/src/main/java/com/wireguard/android/QuickTileService.java
@@ -5,11 +5,7 @@
package com.wireguard.android;
-import com.wireguard.util.NonNullForAll;
-
import android.content.Intent;
-import androidx.databinding.Observable;
-import androidx.databinding.Observable.OnPropertyChangedCallback;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Icon;
@@ -17,8 +13,6 @@ import android.os.Build;
import android.os.IBinder;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
-import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
import android.util.Log;
import com.wireguard.android.activity.MainActivity;
@@ -26,9 +20,15 @@ import com.wireguard.android.activity.TunnelToggleActivity;
import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.model.ObservableTunnel;
import com.wireguard.android.widget.SlashDrawable;
+import com.wireguard.util.NonNullForAll;
import java.util.Objects;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.databinding.Observable;
+import androidx.databinding.Observable.OnPropertyChangedCallback;
+
/**
* Service that maintains the application's custom Quick Settings tile. This service is bound by the
* system framework as necessary to update the appearance of the tile in the system UI, and to
diff --git a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
index 6c849412..704ca766 100644
--- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
@@ -5,18 +5,18 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
-import androidx.databinding.CallbackRegistry;
-import androidx.databinding.CallbackRegistry.NotifierCallback;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import com.wireguard.android.Application;
import com.wireguard.android.model.ObservableTunnel;
+import com.wireguard.util.NonNullForAll;
import java.util.Objects;
+import androidx.annotation.Nullable;
+import androidx.databinding.CallbackRegistry;
+import androidx.databinding.CallbackRegistry.NotifierCallback;
+
/**
* Base class for activities that need to remember the currently-selected tunnel.
*/
diff --git a/ui/src/main/java/com/wireguard/android/activity/MainActivity.java b/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
index 1e098809..d9bbee20 100644
--- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
@@ -5,16 +5,9 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.appcompat.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View.OnApplyWindowInsetsListener;
@@ -24,9 +17,16 @@ import com.wireguard.android.R;
import com.wireguard.android.fragment.TunnelDetailFragment;
import com.wireguard.android.fragment.TunnelEditorFragment;
import com.wireguard.android.model.ObservableTunnel;
+import com.wireguard.util.NonNullForAll;
import java.util.List;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.ActionBar;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
/**
* CRUD interface for WireGuard tunnels. This activity serves as the main entry point to the
* WireGuard application, and contains several fragments for listing, viewing details of, and
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
index 02f6b29a..4d13bfbf 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
@@ -5,17 +5,9 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceFragmentCompat;
-import androidx.preference.PreferenceScreen;
import android.util.SparseArray;
import android.view.MenuItem;
@@ -23,11 +15,19 @@ import com.wireguard.android.Application;
import com.wireguard.android.R;
import com.wireguard.android.backend.WgQuickBackend;
import com.wireguard.android.util.ModuleLoader;
+import com.wireguard.util.NonNullForAll;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import androidx.annotation.Nullable;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceScreen;
+
/**
* Interface for changing application-global persistent settings.
*/
diff --git a/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java b/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
index 114d6f13..abe053e9 100644
--- a/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
@@ -5,20 +5,16 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
+
+import com.wireguard.android.Application;
+import com.wireguard.util.NonNullForAll;
+
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
-import android.util.Log;
-
-import com.wireguard.android.Application;
-
-import java.lang.reflect.Field;
@NonNullForAll
public abstract class ThemeChangeAwareActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
index 3149988f..3dee0c00 100644
--- a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
@@ -5,13 +5,13 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
import android.os.Bundle;
-import androidx.annotation.Nullable;
import com.wireguard.android.fragment.TunnelEditorFragment;
import com.wireguard.android.model.ObservableTunnel;
+import com.wireguard.util.NonNullForAll;
+
+import androidx.annotation.Nullable;
/**
* Standalone activity for creating tunnels.
diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
index dbf156b8..82c79b6d 100644
--- a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
@@ -5,15 +5,9 @@
package com.wireguard.android.activity;
-import com.wireguard.util.NonNullForAll;
-
-import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
-import androidx.appcompat.app.AppCompatActivity;
-
import android.content.ComponentName;
-import android.os.Bundle;
import android.os.Build;
+import android.os.Bundle;
import android.service.quicksettings.TileService;
import android.util.Log;
import android.widget.Toast;
@@ -21,9 +15,14 @@ import android.widget.Toast;
import com.wireguard.android.Application;
import com.wireguard.android.QuickTileService;
import com.wireguard.android.R;
-import com.wireguard.android.model.ObservableTunnel;
import com.wireguard.android.backend.Tunnel.State;
+import com.wireguard.android.model.ObservableTunnel;
import com.wireguard.android.util.ErrorMessages;
+import com.wireguard.util.NonNullForAll;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
@RequiresApi(Build.VERSION_CODES.N)
@NonNullForAll
diff --git a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
index c4db4047..d709c1c1 100644
--- a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
+++ b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
@@ -5,9 +5,8 @@
package com.wireguard.android.configStore;
-import com.wireguard.util.NonNullForAll;
-
import com.wireguard.config.Config;
+import com.wireguard.util.NonNullForAll;
import java.util.Set;
diff --git a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index 9eb56bde..a97ed2d0 100644
--- a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -5,14 +5,13 @@
package com.wireguard.android.configStore;
-import com.wireguard.util.NonNullForAll;
-
import android.content.Context;
import android.util.Log;
import com.wireguard.android.R;
import com.wireguard.config.BadConfigException;
import com.wireguard.config.Config;
+import com.wireguard.util.NonNullForAll;
import java.io.File;
import java.io.FileInputStream;
diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
index 616f665d..6dfd7856 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
@@ -5,16 +5,6 @@
package com.wireguard.android.databinding;
-import com.wireguard.util.NonNullForAll;
-
-import androidx.databinding.BindingAdapter;
-import androidx.databinding.DataBindingUtil;
-import androidx.databinding.ObservableList;
-import androidx.databinding.ViewDataBinding;
-import androidx.databinding.adapters.ListenerUtil;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
import android.text.InputFilter;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
@@ -29,7 +19,16 @@ import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.wireguard.config.Attribute;
import com.wireguard.config.InetNetwork;
import com.wireguard.util.Keyed;
+import com.wireguard.util.NonNullForAll;
+import androidx.annotation.Nullable;
+import androidx.databinding.BindingAdapter;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ObservableList;
+import androidx.databinding.ViewDataBinding;
+import androidx.databinding.adapters.ListenerUtil;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
import java9.util.Optional;
/**
diff --git a/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java b/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
index 284f73b4..efccace1 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
@@ -5,21 +5,21 @@
package com.wireguard.android.databinding;
-import com.wireguard.util.NonNullForAll;
-
-import androidx.databinding.DataBindingUtil;
-import androidx.databinding.ObservableList;
-import androidx.databinding.ViewDataBinding;
-import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.wireguard.android.BR;
+import com.wireguard.util.NonNullForAll;
import java.lang.ref.WeakReference;
import java.util.Objects;
+import androidx.annotation.Nullable;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ObservableList;
+import androidx.databinding.ViewDataBinding;
+
/**
* Helper class for binding an ObservableList to the children of a ViewGroup.
*/
diff --git a/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java b/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
index 36d1917a..c8222cde 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
@@ -5,24 +5,24 @@
package com.wireguard.android.databinding;
-import com.wireguard.util.NonNullForAll;
-
import android.content.Context;
-import androidx.databinding.DataBindingUtil;
-import androidx.databinding.ObservableList;
-import androidx.databinding.ViewDataBinding;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.RecyclerView.Adapter;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.wireguard.android.BR;
import com.wireguard.android.util.ObservableKeyedList;
import com.wireguard.util.Keyed;
+import com.wireguard.util.NonNullForAll;
import java.lang.ref.WeakReference;
+import androidx.annotation.Nullable;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ObservableList;
+import androidx.databinding.ViewDataBinding;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView.Adapter;
+
/**
* A generic {@code RecyclerView.Adapter} backed by a {@code ObservableKeyedList}.
*/
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
index e806615c..ceb1725c 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
@@ -5,8 +5,6 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
@@ -14,10 +12,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.appcompat.app.AlertDialog;
import android.widget.Toast;
import com.wireguard.android.Application;
@@ -27,11 +21,16 @@ import com.wireguard.android.model.ApplicationData;
import com.wireguard.android.util.ErrorMessages;
import com.wireguard.android.util.ObservableKeyedArrayList;
import com.wireguard.android.util.ObservableKeyedList;
+import com.wireguard.util.NonNullForAll;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
import java9.util.Comparators;
import java9.util.stream.Collectors;
import java9.util.stream.StreamSupport;
diff --git a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
index 6fc6d25b..dfdcbac1 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
@@ -5,29 +5,29 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.content.Context;
import android.content.Intent;
-import androidx.databinding.DataBindingUtil;
-import androidx.databinding.ViewDataBinding;
-import androidx.annotation.Nullable;
-import com.google.android.material.snackbar.Snackbar;
-import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
+import com.google.android.material.snackbar.Snackbar;
import com.wireguard.android.Application;
import com.wireguard.android.R;
import com.wireguard.android.activity.BaseActivity;
import com.wireguard.android.activity.BaseActivity.OnSelectedTunnelChangedListener;
import com.wireguard.android.backend.GoBackend;
+import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.databinding.TunnelDetailFragmentBinding;
import com.wireguard.android.databinding.TunnelListItemBinding;
import com.wireguard.android.model.ObservableTunnel;
-import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.util.ErrorMessages;
+import com.wireguard.util.NonNullForAll;
+
+import androidx.annotation.Nullable;
+import androidx.databinding.DataBindingUtil;
+import androidx.databinding.ViewDataBinding;
+import androidx.fragment.app.Fragment;
/**
* Base class for fragments that need to know the currently-selected tunnel. Only does anything when
diff --git a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
index 113af0ab..aa152172 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
@@ -5,16 +5,11 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.appcompat.app.AlertDialog;
import android.view.inputmethod.InputMethodManager;
import com.wireguard.android.Application;
@@ -22,12 +17,17 @@ import com.wireguard.android.R;
import com.wireguard.android.databinding.ConfigNamingDialogFragmentBinding;
import com.wireguard.config.BadConfigException;
import com.wireguard.config.Config;
+import com.wireguard.util.NonNullForAll;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+
@NonNullForAll
public class ConfigNamingDialogFragment extends DialogFragment {
private static final String KEY_CONFIG_TEXT = "config_text";
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
index a7ebb5d1..762efc5d 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
@@ -5,12 +5,7 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.databinding.DataBindingUtil;
-
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -18,16 +13,20 @@ import android.view.View;
import android.view.ViewGroup;
import com.wireguard.android.R;
+import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.databinding.TunnelDetailFragmentBinding;
import com.wireguard.android.databinding.TunnelDetailPeerBinding;
import com.wireguard.android.model.ObservableTunnel;
-import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.ui.EdgeToEdge;
import com.wireguard.crypto.Key;
+import com.wireguard.util.NonNullForAll;
import java.util.Timer;
import java.util.TimerTask;
+import androidx.annotation.Nullable;
+import androidx.databinding.DataBindingUtil;
+
/**
* Fragment that shows details about a specific tunnel.
*/
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index 397882d1..811157cc 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -5,15 +5,9 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.app.Activity;
import android.content.Context;
-import androidx.databinding.ObservableList;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import com.google.android.material.snackbar.Snackbar;
-
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -24,6 +18,7 @@ import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
+import com.google.android.material.snackbar.Snackbar;
import com.wireguard.android.Application;
import com.wireguard.android.R;
import com.wireguard.android.databinding.TunnelEditorFragmentBinding;
@@ -34,11 +29,15 @@ import com.wireguard.android.ui.EdgeToEdge;
import com.wireguard.android.util.ErrorMessages;
import com.wireguard.android.viewmodel.ConfigProxy;
import com.wireguard.config.Config;
+import com.wireguard.util.NonNullForAll;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import androidx.annotation.Nullable;
+import androidx.databinding.ObservableList;
+
/**
* Fragment for editing a WireGuard configuration.
*/
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index 747f69fa..995a2d59 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -5,8 +5,6 @@
package com.wireguard.android.fragment;
-import com.wireguard.util.NonNullForAll;
-
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
@@ -16,13 +14,6 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.OpenableColumns;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import com.google.android.material.snackbar.Snackbar;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.view.ActionMode;
-import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -30,6 +21,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import com.google.android.material.snackbar.Snackbar;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.wireguard.android.Application;
@@ -44,6 +36,7 @@ import com.wireguard.android.util.ErrorMessages;
import com.wireguard.android.widget.MultiselectableRelativeLayout;
import com.wireguard.config.BadConfigException;
import com.wireguard.config.Config;
+import com.wireguard.util.NonNullForAll;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -59,6 +52,11 @@ import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.view.ActionMode;
+import androidx.recyclerview.widget.RecyclerView;
import java9.util.concurrent.CompletableFuture;
import java9.util.stream.StreamSupport;
diff --git a/ui/src/main/java/com/wireguard/android/model/ApplicationData.java b/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
index a64d9d71..f289f53d 100644
--- a/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
+++ b/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
@@ -5,14 +5,14 @@
package com.wireguard.android.model;
-import com.wireguard.util.NonNullForAll;
-
-import androidx.databinding.BaseObservable;
-import androidx.databinding.Bindable;
import android.graphics.drawable.Drawable;
import com.wireguard.android.BR;
import com.wireguard.util.Keyed;
+import com.wireguard.util.NonNullForAll;
+
+import androidx.databinding.BaseObservable;
+import androidx.databinding.Bindable;
@NonNullForAll
public class ApplicationData extends BaseObservable implements Keyed