diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-24 01:27:56 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-24 01:31:19 -0500 |
commit | e446870ac168b54844508935af7112b45ee8ec59 (patch) | |
tree | 22a8b5412ff47a820c81cb55de81e3de0b33e2d1 /app/src | |
parent | e2df9931ac8fc9eaffd427420262e0de5686a325 (diff) |
AddActivity: Update for ConfigEditFragment changes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/wireguard/android/AddActivity.java | 17 |
1 files 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); } } |