diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0b44214e..37485ef0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,7 +37,7 @@ + android:label="@string/create_activity_title" /> diff --git a/app/src/main/java/com/wireguard/android/activity/MainActivity.java b/app/src/main/java/com/wireguard/android/activity/MainActivity.java index a905156c..9e69ca89 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -9,8 +9,8 @@ import android.view.Menu; import android.view.MenuItem; import com.wireguard.android.R; -import com.wireguard.android.fragment.ConfigEditorFragment; import com.wireguard.android.fragment.TunnelDetailFragment; +import com.wireguard.android.fragment.TunnelEditorFragment; import com.wireguard.android.fragment.TunnelListFragment; import com.wireguard.android.model.Tunnel; @@ -129,7 +129,7 @@ public class MainActivity extends BaseActivity { EMPTY(null, 0), LIST(TunnelListFragment.class, 1), DETAIL(TunnelDetailFragment.class, 2), - EDITOR(ConfigEditorFragment.class, 3); + EDITOR(TunnelEditorFragment.class, 3); private final String fragment; private final int layer; diff --git a/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java b/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java index 9a5f4e0a..986054df 100644 --- a/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java @@ -2,7 +2,7 @@ package com.wireguard.android.activity; import android.os.Bundle; -import com.wireguard.android.fragment.ConfigEditorFragment; +import com.wireguard.android.fragment.TunnelEditorFragment; import com.wireguard.android.model.Tunnel; /** @@ -15,7 +15,7 @@ public class TunnelCreatorActivity extends BaseActivity { super.onCreate(savedInstanceState); if (getFragmentManager().findFragmentById(android.R.id.content) == null) { getFragmentManager().beginTransaction() - .add(android.R.id.content, new ConfigEditorFragment()) + .add(android.R.id.content, new TunnelEditorFragment()) .commit(); } } diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java index 0bca1bd7..c2734fa1 100644 --- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java @@ -11,8 +11,8 @@ import com.wireguard.config.Config; import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; diff --git a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java index 34ddb010..4613257b 100644 --- a/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java +++ b/app/src/main/java/com/wireguard/android/databinding/BindingAdapters.java @@ -3,7 +3,6 @@ package com.wireguard.android.databinding; import android.databinding.BindingAdapter; import android.databinding.ObservableList; import android.databinding.adapters.ListenerUtil; -import android.graphics.Typeface; import android.text.InputFilter; import android.widget.LinearLayout; import android.widget.ListView; @@ -15,11 +14,6 @@ import com.wireguard.android.util.ObservableKeyedList; import com.wireguard.android.widget.ToggleSwitch; import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; - /** * Static methods for use by generated code in the Android data binding library. */ @@ -96,20 +90,4 @@ public final class BindingAdapters { final OnBeforeCheckedChangeListener listener) { view.setOnBeforeCheckedChangeListener(listener); } - - @BindingAdapter({"android:text"}) - public static void setText(final TextView view, final Instant instant) { - if (instant == null || Instant.EPOCH.equals(instant)) { - view.setText(R.string.never); - } else { - final ZoneId defaultZone = ZoneId.systemDefault(); - final ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, defaultZone); - view.setText(zonedDateTime.format(DateTimeFormatter.RFC_1123_DATE_TIME)); - } - } - - @BindingAdapter({"android:textStyle"}) - public static void setTextStyle(final TextView view, final Typeface typeface) { - view.setTypeface(typeface); - } } diff --git a/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java similarity index 96% rename from app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java rename to app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java index a4da80fd..b5f21ece 100644 --- a/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java @@ -19,7 +19,7 @@ import com.commonsware.cwac.crossport.design.widget.CoordinatorLayout; import com.commonsware.cwac.crossport.design.widget.Snackbar; import com.wireguard.android.Application; import com.wireguard.android.R; -import com.wireguard.android.databinding.ConfigEditorFragmentBinding; +import com.wireguard.android.databinding.TunnelEditorFragmentBinding; import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.TunnelManager; import com.wireguard.android.util.ExceptionLoggers; @@ -29,14 +29,14 @@ import com.wireguard.config.Config; * Fragment for editing a WireGuard configuration. */ -public class ConfigEditorFragment extends BaseFragment { +public class TunnelEditorFragment extends BaseFragment { private static final String KEY_LOCAL_CONFIG = "local_config"; private static final String KEY_LOCAL_NAME = "local_name"; private static final String KEY_ORIGINAL_NAME = "original_name"; - private static final String TAG = ConfigEditorFragment.class.getSimpleName(); + private static final String TAG = TunnelEditorFragment.class.getSimpleName(); private final ObservableField localName = new ObservableField<>(""); - private ConfigEditorFragmentBinding binding; + private TunnelEditorFragmentBinding binding; private boolean isViewStateRestored; private Config localConfig = new Config(); private Tunnel localTunnel; @@ -107,7 +107,7 @@ public class ConfigEditorFragment extends BaseFragment { public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); - binding = ConfigEditorFragmentBinding.inflate(inflater, container, false); + binding = TunnelEditorFragmentBinding.inflate(inflater, container, false); binding.executePendingBindings(); return binding.getRoot(); } diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java index e174634d..0a374555 100644 --- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java @@ -82,7 +82,7 @@ public class TunnelListFragment extends BaseFragment { asyncWorker.supplyAsync(() -> Config.from(contentResolver.openInputStream(uri))) .thenCombine(nameStage, (config, name) -> tunnelManager.create(name, config)) .thenCompose(Function.identity()) - .handle(this::onTunnelImportFinished); + .whenComplete(this::onTunnelImportFinished); } @Override @@ -142,7 +142,7 @@ public class TunnelListFragment extends BaseFragment { // Do nothing. } - private Void onTunnelDeletionFinished(final Integer count, final Throwable throwable) { + private void onTunnelDeletionFinished(final Integer count, final Throwable throwable) { final String message; if (throwable == null) { message = "Successfully deleted " + count + " tunnels"; @@ -155,10 +155,9 @@ public class TunnelListFragment extends BaseFragment { final CoordinatorLayout container = binding.mainContainer; Snackbar.make(container, message, Snackbar.LENGTH_LONG).show(); } - return null; } - private Void onTunnelImportFinished(final Tunnel tunnel, final Throwable throwable) { + private void onTunnelImportFinished(final Tunnel tunnel, final Throwable throwable) { final String message; if (throwable == null) { message = "Successfully imported tunnel '" + tunnel.getName() + '\''; @@ -171,7 +170,6 @@ public class TunnelListFragment extends BaseFragment { final CoordinatorLayout container = binding.mainContainer; Snackbar.make(container, message, Snackbar.LENGTH_LONG).show(); } - return null; } @Override @@ -202,7 +200,7 @@ public class TunnelListFragment extends BaseFragment { .toArray(CompletableFuture[]::new); CompletableFuture.allOf(futures) .thenApply(x -> futures.length) - .handle(TunnelListFragment.this::onTunnelDeletionFinished); + .whenComplete(TunnelListFragment.this::onTunnelDeletionFinished); mode.finish(); return true; default: diff --git a/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java b/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java index a11529f4..71c949ca 100644 --- a/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java +++ b/app/src/main/java/com/wireguard/android/util/ExceptionLoggers.java @@ -7,7 +7,7 @@ import java9.util.function.BiConsumer; /** * Helpers for logging exceptions from asynchronous tasks. These can be passed to - * {@code CompletionStage.handle()} at the end of an asynchronous future chain. + * {@code CompletionStage.whenComplete()} at the end of an asynchronous future chain. */ public enum ExceptionLoggers implements BiConsumer { diff --git a/app/src/main/java/com/wireguard/crypto/Keypair.java b/app/src/main/java/com/wireguard/crypto/Keypair.java index e0d35d64..25327182 100644 --- a/app/src/main/java/com/wireguard/crypto/Keypair.java +++ b/app/src/main/java/com/wireguard/crypto/Keypair.java @@ -7,22 +7,6 @@ import java.security.SecureRandom; */ public class Keypair { - private static byte[] generatePrivateKey() { - final SecureRandom secureRandom = new SecureRandom(); - final byte[] privateKey = new byte[KeyEncoding.KEY_LENGTH]; - secureRandom.nextBytes(privateKey); - privateKey[0] &= 248; - privateKey[31] &= 127; - privateKey[31] |= 64; - return privateKey; - } - - private static byte[] generatePublicKey(final byte[] privateKey) { - final byte[] publicKey = new byte[KeyEncoding.KEY_LENGTH]; - Curve25519.eval(publicKey, 0, privateKey, null); - return publicKey; - } - private final byte[] privateKey; private final byte[] publicKey; @@ -39,6 +23,22 @@ public class Keypair { this(KeyEncoding.keyFromBase64(privateKey)); } + private static byte[] generatePrivateKey() { + final SecureRandom secureRandom = new SecureRandom(); + final byte[] privateKey = new byte[KeyEncoding.KEY_LENGTH]; + secureRandom.nextBytes(privateKey); + privateKey[0] &= 248; + privateKey[31] &= 127; + privateKey[31] |= 64; + return privateKey; + } + + private static byte[] generatePublicKey(final byte[] privateKey) { + final byte[] publicKey = new byte[KeyEncoding.KEY_LENGTH]; + Curve25519.eval(publicKey, 0, privateKey, null); + return publicKey; + } + public String getPrivateKey() { return KeyEncoding.keyToBase64(privateKey); } diff --git a/app/src/main/res/drawable/ic_action_add.xml b/app/src/main/res/drawable/ic_action_add.xml index cc03f232..d4e66388 100644 --- a/app/src/main/res/drawable/ic_action_add.xml +++ b/app/src/main/res/drawable/ic_action_add.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + android:fillColor="#FFFFFF" + android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> diff --git a/app/src/main/res/drawable/ic_action_delete.xml b/app/src/main/res/drawable/ic_action_delete.xml index b45a975d..617ba001 100644 --- a/app/src/main/res/drawable/ic_action_delete.xml +++ b/app/src/main/res/drawable/ic_action_delete.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + android:fillColor="#FFFFFF" + android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" /> diff --git a/app/src/main/res/drawable/ic_action_delete_black.xml b/app/src/main/res/drawable/ic_action_delete_black.xml index 8566a379..8fc53e7b 100644 --- a/app/src/main/res/drawable/ic_action_delete_black.xml +++ b/app/src/main/res/drawable/ic_action_delete_black.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + android:fillColor="#000000" + android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" /> diff --git a/app/src/main/res/drawable/ic_action_edit.xml b/app/src/main/res/drawable/ic_action_edit.xml index 95d5392c..a0607f54 100644 --- a/app/src/main/res/drawable/ic_action_edit.xml +++ b/app/src/main/res/drawable/ic_action_edit.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + android:fillColor="#FFFFFF" + android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" /> diff --git a/app/src/main/res/drawable/ic_action_open.xml b/app/src/main/res/drawable/ic_action_open.xml index b4fb5a65..ea777109 100644 --- a/app/src/main/res/drawable/ic_action_open.xml +++ b/app/src/main/res/drawable/ic_action_open.xml @@ -1,7 +1,9 @@ - - \ No newline at end of file + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + + diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml index f1f4154f..8025452c 100644 --- a/app/src/main/res/drawable/ic_settings.xml +++ b/app/src/main/res/drawable/ic_settings.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + android:fillColor="#FFFFFF" + android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z" /> diff --git a/app/src/main/res/drawable/ic_tile.xml b/app/src/main/res/drawable/ic_tile.xml index e231b7a5..eaf784c1 100644 --- a/app/src/main/res/drawable/ic_tile.xml +++ b/app/src/main/res/drawable/ic_tile.xml @@ -1,24 +1,24 @@ + android:width="400dp" + android:height="400dp" + android:viewportHeight="400.0" + android:viewportWidth="400.0"> + android:strokeWidth="1.33333325" /> + android:strokeWidth="1.33333325" /> + android:pathData="m134.3,124c41.3,-25.3 94,-9.8 113.8,28.2 3.7,7.2 4.2,18.3 1.8,25.8 -8.2,26.1 -27.5,40.7 -54.1,46.9 7.8,-6.7 14.1,-14.3 16,-24.8 2,-10.6 -0.1,-20.1 -6.2,-28.8 -9.3,-13.2 -27.3,-18.6 -42.4,-12.9 -16.3,6.2 -25.3,21.1 -23.7,39.4 1.5,17 14.4,28.1 38.6,32.2 -3.6,1.9 -6.4,3.3 -9.1,4.8 -11.1,6.2 -20.7,14.3 -28.2,24.6 -2.5,3.3 -4.1,3.6 -7.9,1.3 -48.6,-29.7 -51.7,-104.3 1.4,-136.8" + android:strokeColor="#00000000" + android:strokeWidth="1.33333325" /> diff --git a/app/src/main/res/drawable/ic_tile_disabled.xml b/app/src/main/res/drawable/ic_tile_disabled.xml index e99f0ee3..3109c39a 100644 --- a/app/src/main/res/drawable/ic_tile_disabled.xml +++ b/app/src/main/res/drawable/ic_tile_disabled.xml @@ -1,29 +1,29 @@ + android:width="400dp" + android:height="400dp" + android:viewportHeight="400.0" + android:viewportWidth="400.0"> + android:strokeWidth="1.3750788" /> + android:strokeWidth="1.3750788" /> + android:strokeWidth="1.3750788" /> + android:pathData="M78.4,59.6l262,262l-21.3,21.3l-262,-262z" + android:strokeWidth="0.82064575" /> diff --git a/app/src/main/res/layout/tunnel_detail_fragment.xml b/app/src/main/res/layout/tunnel_detail_fragment.xml index 4487c9cc..e10bc4e1 100644 --- a/app/src/main/res/layout/tunnel_detail_fragment.xml +++ b/app/src/main/res/layout/tunnel_detail_fragment.xml @@ -43,7 +43,7 @@ android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_toStartOf="@+id/tunnel_switch" - android:text="@string/iface" /> + android:text="@string/interface_title" /> + android:text="@string/interface_title" />