diff options
Diffstat (limited to 'app')
3 files changed, 8 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java index 90392e0f..a2eddbe1 100644 --- a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java @@ -16,6 +16,8 @@ import java.util.Objects; */ public abstract class BaseActivity extends Activity { + private static final String KEY_SELECTED_TUNNEL = "selected_tunnel"; + private final SelectionChangeRegistry selectionChangeRegistry = new SelectionChangeRegistry(); private Tunnel selectedTunnel; @@ -33,9 +35,9 @@ public abstract class BaseActivity extends Activity { // Restore the saved tunnel if there is one; otherwise grab it from the arguments. String savedTunnelName = null; if (savedInstanceState != null) - savedTunnelName = savedInstanceState.getString(TunnelManager.KEY_SELECTED_TUNNEL); + savedTunnelName = savedInstanceState.getString(KEY_SELECTED_TUNNEL); else if (getIntent() != null) - savedTunnelName = getIntent().getStringExtra(TunnelManager.KEY_SELECTED_TUNNEL); + savedTunnelName = getIntent().getStringExtra(KEY_SELECTED_TUNNEL); if (savedTunnelName != null) { final TunnelManager manager = Application.getComponent().getTunnelManager(); selectedTunnel = manager.getTunnels().get(savedTunnelName); @@ -47,7 +49,7 @@ public abstract class BaseActivity extends Activity { @Override protected void onSaveInstanceState(final Bundle outState) { if (selectedTunnel != null) - outState.putString(TunnelManager.KEY_SELECTED_TUNNEL, selectedTunnel.getName()); + outState.putString(KEY_SELECTED_TUNNEL, selectedTunnel.getName()); super.onSaveInstanceState(outState); } diff --git a/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java index 7e2040ad..a4da80fd 100644 --- a/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/ConfigEditorFragment.java @@ -32,6 +32,7 @@ import com.wireguard.config.Config; public class ConfigEditorFragment 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 final ObservableField<String> localName = new ObservableField<>(""); @@ -79,7 +80,7 @@ public class ConfigEditorFragment extends BaseFragment { if (savedInstanceState != null) { localConfig = savedInstanceState.getParcelable(KEY_LOCAL_CONFIG); localName.set(savedInstanceState.getString(KEY_LOCAL_NAME)); - originalName = savedInstanceState.getString(TunnelManager.KEY_SELECTED_TUNNEL); + originalName = savedInstanceState.getString(KEY_ORIGINAL_NAME); } // Erase the remains of creating or editing a different tunnel. if (getSelectedTunnel() != null && !getSelectedTunnel().getName().equals(originalName)) { @@ -166,7 +167,7 @@ public class ConfigEditorFragment extends BaseFragment { public void onSaveInstanceState(final Bundle outState) { outState.putParcelable(KEY_LOCAL_CONFIG, localConfig); outState.putString(KEY_LOCAL_NAME, localName.get()); - outState.putString(TunnelManager.KEY_SELECTED_TUNNEL, originalName); + outState.putString(KEY_ORIGINAL_NAME, originalName); super.onSaveInstanceState(outState); } diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java index b0e6ead2..8b7ef208 100644 --- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java +++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java @@ -33,7 +33,6 @@ import java9.util.stream.StreamSupport; @ApplicationScope public final class TunnelManager { public static final String KEY_PRIMARY_TUNNEL = "primary_config"; - public static final String KEY_SELECTED_TUNNEL = "selected_tunnel"; private static final Comparator<String> COMPARATOR = Comparators.<String>thenComparing( String.CASE_INSENSITIVE_ORDER, Comparators.naturalOrder()); private static final String KEY_RESTORE_ON_BOOT = "restore_on_boot"; |