global: get rid of nonnull gradle hack
Hacking things up via gradle is not right, and package-info.java poses problems with two modules, so instead we just apply it manually to every class. Remember to add this to new classes! Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: rootProject.file('nonnull.gradle')
|
||||
|
||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||
// keystore.properties file, in the rootProject folder.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 == '/';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
/**
|
||||
* Interface for objects that have a identifying key of the given type.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface Keyed<K> {
|
||||
K getKey();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -15,6 +17,7 @@ import java.util.List;
|
||||
* {@code null} elements.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface KeyedList<K, E extends Keyed<? extends K>> extends List<E> {
|
||||
boolean containsAllKeys(Collection<K> keys);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -16,6 +18,7 @@ import java.util.Set;
|
||||
* applied to their keys.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface SortedKeyedList<K, E extends Keyed<? extends K>> extends KeyedList<K, E> {
|
||||
Comparator<? super K> comparator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user