summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index eec5c098..aa4321e8 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -146,18 +146,19 @@ public class TunnelEditorFragment extends BaseFragment {
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_action_save:
- if (getSelectedTunnel() == null) {
+ final Tunnel selectedTunnel = getSelectedTunnel();
+ if (selectedTunnel == null) {
Log.d(TAG, "Attempting to create new tunnel " + localName.get());
final TunnelManager manager = Application.getComponent().getTunnelManager();
manager.create(localName.get(), localConfig)
.whenComplete(this::onTunnelCreated);
- } else if (!getSelectedTunnel().getName().equals(localName.get())) {
+ } else if (!selectedTunnel.getName().equals(localName.get())) {
Log.d(TAG, "Attempting to rename tunnel to " + localName.get());
- getSelectedTunnel().rename(localName.get())
+ selectedTunnel.rename(localName.get())
.whenComplete(this::onTunnelRenamed);
- } else {
- Log.d(TAG, "Attempting to save config of " + getSelectedTunnel().getName());
- getSelectedTunnel().setConfig(localConfig)
+ } else if (localConfig != null) {
+ Log.d(TAG, "Attempting to save config of " + selectedTunnel.getName());
+ selectedTunnel.setConfig(localConfig)
.whenComplete(this::onConfigSaved);
}
return true;