From d645d698475f986d8be8a0c9c96f2cd9b5dd153d Mon Sep 17 00:00:00 2001
From: Samuel Holland
Date: Mon, 8 Jan 2018 02:19:13 -0600
Subject: [PATCH] project: Global cleanup
Signed-off-by: Samuel Holland
---
app/src/main/AndroidManifest.xml | 2 +-
.../android/activity/MainActivity.java | 4 +--
.../activity/TunnelCreatorActivity.java | 4 +--
.../android/backend/WgQuickBackend.java | 2 +-
.../android/databinding/BindingAdapters.java | 22 -------------
...ragment.java => TunnelEditorFragment.java} | 10 +++---
.../android/fragment/TunnelListFragment.java | 10 +++---
.../android/util/ExceptionLoggers.java | 2 +-
.../java/com/wireguard/crypto/Keypair.java | 32 +++++++++----------
app/src/main/res/drawable/ic_action_add.xml | 12 +++----
.../main/res/drawable/ic_action_delete.xml | 12 +++----
.../res/drawable/ic_action_delete_black.xml | 12 +++----
app/src/main/res/drawable/ic_action_edit.xml | 12 +++----
app/src/main/res/drawable/ic_action_open.xml | 12 ++++---
app/src/main/res/drawable/ic_settings.xml | 12 +++----
app/src/main/res/drawable/ic_tile.xml | 26 +++++++--------
.../main/res/drawable/ic_tile_disabled.xml | 30 ++++++++---------
.../res/layout/tunnel_detail_fragment.xml | 2 +-
...ragment.xml => tunnel_editor_fragment.xml} | 4 +--
...editor_peer.xml => tunnel_editor_peer.xml} | 0
app/src/main/res/values/strings.xml | 32 +++++++------------
app/src/main/res/xml/preferences.xml | 2 +-
22 files changed, 112 insertions(+), 144 deletions(-)
rename app/src/main/java/com/wireguard/android/fragment/{ConfigEditorFragment.java => TunnelEditorFragment.java} (96%)
rename app/src/main/res/layout/{config_editor_fragment.xml => tunnel_editor_fragment.xml} (98%)
rename app/src/main/res/layout/{config_editor_peer.xml => tunnel_editor_peer.xml} (100%)
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
Fortunately, we are in the process of implementing support for WireGuard in a way that
will work on all devices, without any need for the kernel module. This means that while you
may not be able to use WireGuard today, you will very likely be able to use WireGuard in
- several weeks. Things are looking up!
+ several weeks. Things are looking up!
Sorry for the wait. In the mean time, you may stay up to date on the latest project news
by subscribing to our mailing
- list. General information about the project is available from
+ list. General information about the project is available at
WireGuard.com.
]]>
+ WireGuard not installed
+ OKPeerPersistent keepalive
- No configuration selectedPre-shared keyPrivate keyPublic key
- Public key copied to clipboardPublic key
- Restore on boot
- Restore previously enabled configurations on boot
+ Bring up previously-enabled tunnels on boot
+ Restore on bootSaveSettings
- Status
- Togglewg and wg-quick are already installedCommand line tools could not be installed (no root?)Install optional tools for scripting into the system partitionwg and wg-quick installed into the system partitionInstall command line toolsInstalling wg and wg-quick into the system partition
- Last change
- never
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 290f7086..17fd4fc8 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -4,6 +4,6 @@
android:defaultValue="false"
android:key="restore_on_boot"
android:summary="@string/restore_on_boot_summary"
- android:title="@string/restore_on_boot" />
+ android:title="@string/restore_on_boot_title" />