diff options
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
46 files changed, 137 insertions, 0 deletions
diff --git a/ui/src/main/java/com/wireguard/android/Application.java b/ui/src/main/java/com/wireguard/android/Application.java index e32c3755..d3e0aa5f 100644 --- a/ui/src/main/java/com/wireguard/android/Application.java +++ b/ui/src/main/java/com/wireguard/android/Application.java @@ -5,6 +5,8 @@ package com.wireguard.android; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -35,6 +37,7 @@ import java.util.Locale; import java9.util.concurrent.CompletableFuture; +@NonNullForAll public class Application extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "WireGuard/" + Application.class.getSimpleName(); public static final String USER_AGENT = String.format(Locale.ENGLISH, "WireGuard/%s (Android %d; %s; %s; %s %s; %s)", BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT, Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "unknown ABI", Build.BOARD, Build.MANUFACTURER, Build.MODEL, Build.FINGERPRINT); diff --git a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java index e3ffce7a..f5232d50 100644 --- a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java +++ b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java @@ -5,6 +5,8 @@ package com.wireguard.android; +import com.wireguard.util.NonNullForAll; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -14,6 +16,7 @@ import com.wireguard.android.backend.WgQuickBackend; import com.wireguard.android.model.TunnelManager; import com.wireguard.android.util.ExceptionLoggers; +@NonNullForAll public class BootShutdownReceiver extends BroadcastReceiver { private static final String TAG = "WireGuard/" + BootShutdownReceiver.class.getSimpleName(); diff --git a/ui/src/main/java/com/wireguard/android/QuickTileService.java b/ui/src/main/java/com/wireguard/android/QuickTileService.java index 66aecec3..f18d01b1 100644 --- a/ui/src/main/java/com/wireguard/android/QuickTileService.java +++ b/ui/src/main/java/com/wireguard/android/QuickTileService.java @@ -5,6 +5,8 @@ package com.wireguard.android; +import com.wireguard.util.NonNullForAll; + import android.content.Intent; import androidx.databinding.Observable; import androidx.databinding.Observable.OnPropertyChangedCallback; @@ -34,6 +36,7 @@ import java.util.Objects; */ @RequiresApi(Build.VERSION_CODES.N) +@NonNullForAll public class QuickTileService extends TileService { private static final String TAG = "WireGuard/" + QuickTileService.class.getSimpleName(); 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 8ec58ee8..6c849412 100644 --- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.CallbackRegistry; import androidx.databinding.CallbackRegistry.NotifierCallback; import android.os.Bundle; @@ -19,6 +21,7 @@ import java.util.Objects; * Base class for activities that need to remember the currently-selected tunnel. */ +@NonNullForAll public abstract class BaseActivity extends ThemeChangeAwareActivity { private static final String KEY_SELECTED_TUNNEL = "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 4c33f000..1e098809 100644 --- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; @@ -31,6 +33,7 @@ import java.util.List; * editing the configuration and interface state of WireGuard tunnels. */ +@NonNullForAll public class MainActivity extends BaseActivity implements FragmentManager.OnBackStackChangedListener { @Nullable private ActionBar actionBar; 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 b597a9b1..02f6b29a 100644 --- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; @@ -30,6 +32,7 @@ import java.util.List; * Interface for changing application-global persistent settings. */ +@NonNullForAll public class SettingsActivity extends ThemeChangeAwareActivity { private final SparseArray<PermissionRequestCallback> permissionRequestCallbacks = new SparseArray<>(); private int permissionRequestCounter; 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 c553e417..114d6f13 100644 --- a/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; @@ -18,6 +20,7 @@ import com.wireguard.android.Application; import java.lang.reflect.Field; +@NonNullForAll public abstract class ThemeChangeAwareActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "WireGuard/" + ThemeChangeAwareActivity.class.getSimpleName(); 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 c87ec537..3149988f 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import android.os.Bundle; import androidx.annotation.Nullable; @@ -15,6 +17,7 @@ import com.wireguard.android.model.ObservableTunnel; * Standalone activity for creating tunnels. */ +@NonNullForAll public class TunnelCreatorActivity extends BaseActivity { @Override @SuppressWarnings("UnnecessaryFullyQualifiedName") 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 09a34bf7..dbf156b8 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java +++ b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java @@ -5,6 +5,8 @@ package com.wireguard.android.activity; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; @@ -24,6 +26,7 @@ import com.wireguard.android.backend.Tunnel.State; import com.wireguard.android.util.ErrorMessages; @RequiresApi(Build.VERSION_CODES.N) +@NonNullForAll public class TunnelToggleActivity extends AppCompatActivity { private static final String TAG = "WireGuard/" + TunnelToggleActivity.class.getSimpleName(); 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 d4761464..c4db4047 100644 --- a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java +++ b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java @@ -5,6 +5,8 @@ package com.wireguard.android.configStore; +import com.wireguard.util.NonNullForAll; + import com.wireguard.config.Config; import java.util.Set; @@ -13,6 +15,7 @@ import java.util.Set; * Interface for persistent storage providers for WireGuard configurations. */ +@NonNullForAll public interface ConfigStore { /** * Create a persistent tunnel, which must have a unique name within the persistent storage 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 45f2f759..9eb56bde 100644 --- a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java +++ b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java @@ -5,6 +5,8 @@ package com.wireguard.android.configStore; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.util.Log; @@ -27,6 +29,7 @@ import java9.util.stream.Stream; * Configuration store that uses a {@code wg-quick}-style file for each configured tunnel. */ +@NonNullForAll public final class FileConfigStore implements ConfigStore { private static final String TAG = "WireGuard/" + FileConfigStore.class.getSimpleName(); 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 ee216d4c..616f665d 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java @@ -5,6 +5,8 @@ package com.wireguard.android.databinding; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.BindingAdapter; import androidx.databinding.DataBindingUtil; import androidx.databinding.ObservableList; @@ -35,6 +37,7 @@ import java9.util.Optional; */ @SuppressWarnings("unused") +@NonNullForAll public final class BindingAdapters { private BindingAdapters() { // Prevent instantiation. 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 e7303eae..284f73b4 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java +++ b/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java @@ -5,6 +5,8 @@ package com.wireguard.android.databinding; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.DataBindingUtil; import androidx.databinding.ObservableList; import androidx.databinding.ViewDataBinding; @@ -22,6 +24,7 @@ import java.util.Objects; * Helper class for binding an ObservableList to the children of a ViewGroup. */ +@NonNullForAll class ItemChangeListener<T> { private final OnListChangedCallback<T> callback = new OnListChangedCallback<>(this); private final ViewGroup container; 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 8b40dd91..36d1917a 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java +++ b/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java @@ -5,6 +5,8 @@ package com.wireguard.android.databinding; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import androidx.databinding.DataBindingUtil; import androidx.databinding.ObservableList; @@ -25,6 +27,7 @@ import java.lang.ref.WeakReference; * A generic {@code RecyclerView.Adapter} backed by a {@code ObservableKeyedList}. */ +@NonNullForAll public class ObservableKeyedRecyclerViewAdapter<K, E extends Keyed<? extends K>> extends Adapter<ObservableKeyedRecyclerViewAdapter.ViewHolder> { private final OnListChangedCallback<E> callback = new OnListChangedCallback<>(this); 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 43178665..e806615c 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; @@ -34,6 +36,7 @@ import java9.util.Comparators; import java9.util.stream.Collectors; import java9.util.stream.StreamSupport; +@NonNullForAll public class AppListDialogFragment extends DialogFragment { private static final String KEY_EXCLUDED_APPS = "excludedApps"; 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 23bf44e7..6fc6d25b 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.content.Intent; import androidx.databinding.DataBindingUtil; @@ -32,6 +34,7 @@ import com.wireguard.android.util.ErrorMessages; * attached to a {@code BaseActivity}. */ +@NonNullForAll public abstract class BaseFragment extends Fragment implements OnSelectedTunnelChangedListener { private static final int REQUEST_CODE_VPN_PERMISSION = 23491; private static final String TAG = "WireGuard/" + BaseFragment.class.getSimpleName(); 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 effa0593..113af0ab 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.app.Activity; import android.app.Dialog; import android.content.Context; @@ -26,6 +28,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Objects; +@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 8d90fa7e..a7ebb5d1 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.os.Bundle; import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; @@ -30,6 +32,7 @@ import java.util.TimerTask; * Fragment that shows details about a specific tunnel. */ +@NonNullForAll public class TunnelDetailFragment extends BaseFragment { @Nullable private TunnelDetailFragmentBinding binding; @Nullable private Timer timer; 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 92aeb52a..397882d1 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.app.Activity; import android.content.Context; import androidx.databinding.ObservableList; @@ -41,6 +43,7 @@ import java.util.Objects; * Fragment for editing a WireGuard configuration. */ +@NonNullForAll public class TunnelEditorFragment extends BaseFragment implements AppExclusionListener { private static final String KEY_LOCAL_CONFIG = "local_config"; private static final String KEY_ORIGINAL_NAME = "original_name"; 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 21618e60..747f69fa 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java @@ -5,6 +5,8 @@ package com.wireguard.android.fragment; +import com.wireguard.util.NonNullForAll; + import android.annotation.SuppressLint; import android.app.Activity; import android.content.ContentResolver; @@ -64,6 +66,7 @@ import java9.util.stream.StreamSupport; * Fragment containing a list of known WireGuard tunnels. It allows creating and deleting tunnels. */ +@NonNullForAll public class TunnelListFragment extends BaseFragment { public static final int REQUEST_IMPORT = 1; private static final int REQUEST_TARGET_FRAGMENT = 2; 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 65edff90..a64d9d71 100644 --- a/ui/src/main/java/com/wireguard/android/model/ApplicationData.java +++ b/ui/src/main/java/com/wireguard/android/model/ApplicationData.java @@ -5,6 +5,8 @@ package com.wireguard.android.model; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.BaseObservable; import androidx.databinding.Bindable; import android.graphics.drawable.Drawable; @@ -12,6 +14,7 @@ import android.graphics.drawable.Drawable; import com.wireguard.android.BR; import com.wireguard.util.Keyed; +@NonNullForAll public class ApplicationData extends BaseObservable implements Keyed<String> { private final Drawable icon; private final String name; diff --git a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java index edd8bd68..70e3bac9 100644 --- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java +++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java @@ -5,6 +5,8 @@ package com.wireguard.android.model; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.BaseObservable; import androidx.databinding.Bindable; import androidx.annotation.Nullable; @@ -23,6 +25,7 @@ import java9.util.concurrent.CompletionStage; * Encapsulates the volatile and nonvolatile state of a WireGuard tunnel. */ +@NonNullForAll public class ObservableTunnel extends BaseObservable implements Keyed<String>, Tunnel { private final TunnelManager manager; @Nullable private Config config; diff --git a/ui/src/main/java/com/wireguard/android/model/TunnelManager.java b/ui/src/main/java/com/wireguard/android/model/TunnelManager.java index 35d56c81..77304091 100644 --- a/ui/src/main/java/com/wireguard/android/model/TunnelManager.java +++ b/ui/src/main/java/com/wireguard/android/model/TunnelManager.java @@ -5,6 +5,8 @@ package com.wireguard.android.model; +import com.wireguard.util.NonNullForAll; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -39,6 +41,7 @@ import java9.util.stream.StreamSupport; * Maintains and mediates changes to the set of available WireGuard tunnels, */ +@NonNullForAll public final class TunnelManager extends BaseObservable { private static final Comparator<String> COMPARATOR = Comparators.<String>thenComparing( String.CASE_INSENSITIVE_ORDER, Comparators.naturalOrder()); diff --git a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java index 565854b4..69608e4d 100644 --- a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java +++ b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java @@ -5,6 +5,8 @@ package com.wireguard.android.preference; +import com.wireguard.util.NonNullForAll; + import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; @@ -29,6 +31,7 @@ import java.io.InputStreamReader; * Preference implementing a button that asynchronously exports logs. */ +@NonNullForAll public class LogExporterPreference extends Preference { private static final String TAG = "WireGuard/" + LogExporterPreference.class.getSimpleName(); diff --git a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java index 5c83f1dc..8858c725 100644 --- a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java +++ b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java @@ -5,6 +5,8 @@ package com.wireguard.android.preference; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.content.Intent; import android.system.OsConstants; @@ -18,6 +20,7 @@ import com.wireguard.android.util.ErrorMessages; import androidx.annotation.Nullable; import androidx.preference.Preference; +@NonNullForAll public class ModuleDownloaderPreference extends Preference { private State state = State.INITIAL; diff --git a/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java b/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java index 78a7497b..61752598 100644 --- a/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java +++ b/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java @@ -5,6 +5,8 @@ package com.wireguard.android.preference; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import androidx.annotation.Nullable; import androidx.preference.Preference; @@ -19,6 +21,7 @@ import com.wireguard.android.util.ToolsInstaller; * result as the preference summary. */ +@NonNullForAll public class ToolsInstallerPreference extends Preference { private State state = State.INITIAL; diff --git a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java index 7e95a8ae..542fe2d2 100644 --- a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java +++ b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java @@ -5,6 +5,8 @@ package com.wireguard.android.preference; +import com.wireguard.util.NonNullForAll; + import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; @@ -22,6 +24,7 @@ import com.wireguard.android.backend.WgQuickBackend; import java.util.Locale; +@NonNullForAll public class VersionPreference extends Preference { @Nullable private String versionSummary; diff --git a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java index 3af412a5..8f86fec7 100644 --- a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java +++ b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java @@ -5,6 +5,8 @@ package com.wireguard.android.preference; +import com.wireguard.util.NonNullForAll; + import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; @@ -35,6 +37,7 @@ import java9.util.concurrent.CompletableFuture; * Preference implementing a button that asynchronously exports config zips. */ +@NonNullForAll public class ZipExporterPreference extends Preference { private static final String TAG = "WireGuard/" + ZipExporterPreference.class.getSimpleName(); diff --git a/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java b/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java index 1d041851..f8341976 100644 --- a/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java +++ b/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import android.os.Handler; import java.util.concurrent.Executor; @@ -16,6 +18,7 @@ import java9.util.concurrent.CompletionStage; * Helper class for running asynchronous tasks and ensuring they are completed on the main thread. */ +@NonNullForAll public class AsyncWorker { private final Executor executor; private final Handler handler; diff --git a/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java b/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java index 0df5e96a..649fe261 100644 --- a/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java +++ b/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -16,6 +18,7 @@ import android.widget.TextView; * Standalone utilities for interacting with the system clipboard. */ +@NonNullForAll public final class ClipboardUtils { private ClipboardUtils() { // Prevent instantiation diff --git a/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java b/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java index 7db46fa9..3f80a562 100644 --- a/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java +++ b/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; @@ -22,6 +24,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +@NonNullForAll public class DownloadsFileSaver { public static class DownloadsFile { diff --git a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java index 481a6ffb..3b818251 100644 --- a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java +++ b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import android.content.res.Resources; import android.os.RemoteException; @@ -29,6 +31,7 @@ import java.util.Map; import java9.util.Maps; +@NonNullForAll public final class ErrorMessages { private static final Map<BadConfigException.Reason, Integer> BCE_REASON_MAP = new EnumMap<>(Maps.of( BadConfigException.Reason.INVALID_KEY, R.string.bad_config_reason_invalid_key, diff --git a/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java b/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java index 5c7a38c0..3e56bd55 100644 --- a/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java +++ b/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import android.util.Log; diff --git a/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java b/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java index 5fb9a3bc..50a49fa1 100644 --- a/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java +++ b/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java @@ -4,12 +4,15 @@ */ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import androidx.preference.Preference; import android.view.ContextThemeWrapper; import com.wireguard.android.activity.SettingsActivity; +@NonNullForAll public final class FragmentUtils { private FragmentUtils() { // Prevent instantiation diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java index 0ba02184..bf16d921 100644 --- a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java +++ b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.ObservableArrayList; import androidx.annotation.Nullable; @@ -21,6 +23,7 @@ import java.util.Objects; * operations, require O(n) time. */ +@NonNullForAll public class ObservableKeyedArrayList<K, E extends Keyed<? extends K>> extends ObservableArrayList<E> implements ObservableKeyedList<K, E> { @Override diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java index be8ceb9b..1c430493 100644 --- a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java +++ b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.ObservableList; import com.wireguard.util.Keyed; @@ -14,6 +16,7 @@ import com.wireguard.util.KeyedList; * A list that is both keyed and observable. */ +@NonNullForAll public interface ObservableKeyedList<K, E extends Keyed<? extends K>> extends KeyedList<K, E>, ObservableList<E> { } diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java index 1d585856..77d6bbf3 100644 --- a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java +++ b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import com.wireguard.util.Keyed; @@ -26,6 +28,7 @@ import java.util.Spliterator; * key still require O(n) time. */ +@NonNullForAll public class ObservableSortedKeyedArrayList<K, E extends Keyed<? extends K>> extends ObservableKeyedArrayList<K, E> implements ObservableSortedKeyedList<K, E> { @Nullable private final Comparator<? super K> comparator; diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java index d796704e..59531408 100644 --- a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java +++ b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java @@ -5,6 +5,8 @@ package com.wireguard.android.util; +import com.wireguard.util.NonNullForAll; + import com.wireguard.util.Keyed; import com.wireguard.util.SortedKeyedList; @@ -12,6 +14,7 @@ import com.wireguard.util.SortedKeyedList; * A list that is both sorted/keyed and observable. */ +@NonNullForAll public interface ObservableSortedKeyedList<K, E extends Keyed<? extends K>> extends ObservableKeyedList<K, E>, SortedKeyedList<K, E> { } diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java index bcfe14e3..cc7bc082 100644 --- a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java +++ b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java @@ -5,6 +5,8 @@ package com.wireguard.android.viewmodel; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableList; import android.os.Parcel; @@ -17,6 +19,7 @@ import com.wireguard.config.Peer; import java.util.ArrayList; import java.util.Collection; +@NonNullForAll public class ConfigProxy implements Parcelable { public static final Parcelable.Creator<ConfigProxy> CREATOR = new ConfigProxyCreator(); diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java index cc9f2dd8..da9c4f10 100644 --- a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java +++ b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java @@ -5,6 +5,8 @@ package com.wireguard.android.viewmodel; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.BaseObservable; import androidx.databinding.Bindable; import androidx.databinding.ObservableArrayList; @@ -26,6 +28,7 @@ import java.util.List; import java9.util.stream.Collectors; import java9.util.stream.StreamSupport; +@NonNullForAll public class InterfaceProxy extends BaseObservable implements Parcelable { public static final Parcelable.Creator<InterfaceProxy> CREATOR = new InterfaceProxyCreator(); diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java index 7dc50f09..7fc614a1 100644 --- a/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java +++ b/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java @@ -5,6 +5,8 @@ package com.wireguard.android.viewmodel; +import com.wireguard.util.NonNullForAll; + import androidx.databinding.BaseObservable; import androidx.databinding.Bindable; import androidx.databinding.Observable; @@ -32,6 +34,7 @@ import java9.util.Sets; import java9.util.stream.Collectors; import java9.util.stream.Stream; +@NonNullForAll public class PeerProxy extends BaseObservable implements Parcelable { public static final Parcelable.Creator<PeerProxy> CREATOR = new PeerProxyCreator(); private static final Set<String> IPV4_PUBLIC_NETWORKS = new LinkedHashSet<>(Lists.of( diff --git a/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java b/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java index 79572aa3..c91b12ff 100644 --- a/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java +++ b/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java @@ -5,6 +5,8 @@ package com.wireguard.android.widget; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import android.text.InputFilter; import android.text.SpannableStringBuilder; @@ -16,6 +18,7 @@ import com.wireguard.crypto.Key; * InputFilter for entering WireGuard private/public keys encoded with base64. */ +@NonNullForAll public class KeyInputFilter implements InputFilter { private static boolean isAllowed(final char c) { return Character.isLetterOrDigit(c) || c == '+' || c == '/'; diff --git a/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java b/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java index 2fe9c924..16742ae8 100644 --- a/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java +++ b/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java @@ -5,12 +5,15 @@ package com.wireguard.android.widget; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.util.AttributeSet; import android.widget.RelativeLayout; import com.wireguard.android.R; +@NonNullForAll public class MultiselectableRelativeLayout extends RelativeLayout { private static final int[] STATE_MULTISELECTED = {R.attr.state_multiselected}; private boolean multiselected; diff --git a/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java b/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java index 030be25a..1ec14ac0 100644 --- a/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java +++ b/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java @@ -5,6 +5,8 @@ package com.wireguard.android.widget; +import com.wireguard.util.NonNullForAll; + import androidx.annotation.Nullable; import android.text.InputFilter; import android.text.SpannableStringBuilder; @@ -16,6 +18,7 @@ import com.wireguard.android.backend.Tunnel; * InputFilter for entering WireGuard configuration names (Linux interface names). */ +@NonNullForAll public class NameInputFilter implements InputFilter { private static boolean isAllowed(final char c) { return Character.isLetterOrDigit(c) || "_=+.-".indexOf(c) >= 0; diff --git a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java index e020aa81..4a3142ea 100644 --- a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java +++ b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java @@ -6,6 +6,8 @@ package com.wireguard.android.widget; +import com.wireguard.util.NonNullForAll; + import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.res.ColorStateList; @@ -29,6 +31,7 @@ import androidx.annotation.RequiresApi; import android.util.FloatProperty; @RequiresApi(Build.VERSION_CODES.N) +@NonNullForAll public class SlashDrawable extends Drawable { private static final float CENTER_X = 10.65f; diff --git a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java index dcb9aceb..3aec3329 100644 --- a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java +++ b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java @@ -6,12 +6,15 @@ package com.wireguard.android.widget; +import com.wireguard.util.NonNullForAll; + import android.content.Context; import android.os.Parcelable; import androidx.annotation.Nullable; import android.util.AttributeSet; import android.widget.Switch; +@NonNullForAll public class ToggleSwitch extends Switch { private boolean isRestoringState; @Nullable private OnBeforeCheckedChangeListener listener; |