From e446870ac168b54844508935af7112b45ee8ec59 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Thu, 24 Aug 2017 01:27:56 -0500 Subject: [PATCH] AddActivity: Update for ConfigEditFragment changes Signed-off-by: Jason A. Donenfeld --- .../java/com/wireguard/android/AddActivity.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/wireguard/android/AddActivity.java b/app/src/main/java/com/wireguard/android/AddActivity.java index 7e31c876..080eecae 100644 --- a/app/src/main/java/com/wireguard/android/AddActivity.java +++ b/app/src/main/java/com/wireguard/android/AddActivity.java @@ -19,8 +19,13 @@ public class AddActivity extends BaseConfigActivity { @Override protected void onCurrentConfigChanged(final Config config) { - // This is the result of ConfigEditFragment signalling that a configuration was created. - if (config != null) + // Do nothing (this never happens). + } + + @Override + protected void onEditingStateChanged(final boolean isEditing) { + // Go back to the main activity once the new configuration is created. + if (!isEditing) finish(); } @@ -28,10 +33,14 @@ public class AddActivity extends BaseConfigActivity { protected void onServiceAvailable() { super.onServiceAvailable(); final FragmentManager fm = getFragmentManager(); - if (fm.findFragmentById(R.id.master_fragment) == null) { + ConfigEditFragment fragment = (ConfigEditFragment) fm.findFragmentById(R.id.master_fragment); + if (fragment == null) { + fragment = new ConfigEditFragment(); final FragmentTransaction transaction = fm.beginTransaction(); - transaction.add(R.id.master_fragment, new ConfigEditFragment()); + transaction.add(R.id.master_fragment, fragment); transaction.commit(); } + // Prime the state for the fragment to tell us it is finished. + setIsEditing(true); } }