From 522178598b749589743d9269d4c53049c529c4a3 Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Mon, 26 Aug 2013 11:50:12 +0000 Subject: [PATCH] Pass tunnel wizard data back to TunnelListFragment --- .../i2ptunnel/activity/TunnelWizardActivity.java | 10 ++++++++-- .../i2ptunnel/fragment/TunnelListFragment.java | 14 +++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java index 70c9e16d7..5bc9590f7 100644 --- a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java +++ b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java @@ -2,6 +2,7 @@ package net.i2p.android.i2ptunnel.activity; import java.util.List; +import net.i2p.android.i2ptunnel.fragment.TunnelListFragment; import net.i2p.android.router.R; import net.i2p.android.wizard.model.AbstractWizardModel; import net.i2p.android.wizard.model.ModelCallbacks; @@ -9,9 +10,11 @@ import net.i2p.android.wizard.model.Page; import net.i2p.android.wizard.ui.PageFragmentCallbacks; import net.i2p.android.wizard.ui.ReviewFragment; import net.i2p.android.wizard.ui.StepPagerStrip; +import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; @@ -95,14 +98,17 @@ public class TunnelWizardActivity extends FragmentActivity implements new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - + Intent result = new Intent(); + result.putExtra(TunnelListFragment.TUNNEL_WIZARD_DATA, mWizardModel.save()); + setResult(Activity.RESULT_OK, result); + finish(); } }) .setNegativeButton(android.R.string.cancel, null) .create(); } }; - dg.show(getSupportFragmentManager(), "place_order_dialog"); + dg.show(getSupportFragmentManager(), "create_tunnel_dialog"); } else { if (mEditingAfterReview) { mPager.setCurrentItem(mPagerAdapter.getCount() - 1); diff --git a/src/net/i2p/android/i2ptunnel/fragment/TunnelListFragment.java b/src/net/i2p/android/i2ptunnel/fragment/TunnelListFragment.java index 696145a20..4bb2d0035 100644 --- a/src/net/i2p/android/i2ptunnel/fragment/TunnelListFragment.java +++ b/src/net/i2p/android/i2ptunnel/fragment/TunnelListFragment.java @@ -23,6 +23,9 @@ import android.widget.ListView; public class TunnelListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<TunnelEntry>> { public static final String SHOW_CLIENT_TUNNELS = "show_client_tunnels"; + public static final String TUNNEL_WIZARD_DATA = "tunnel_wizard_data"; + + static final int TUNNEL_WIZARD_REQUEST = 1; private static final int CLIENT_LOADER_ID = 1; private static final int SERVER_LOADER_ID = 2; @@ -143,12 +146,21 @@ public class TunnelListFragment extends ListFragment switch (item.getItemId()) { case R.id.action_add_tunnel: Intent wi = new Intent(getActivity(), TunnelWizardActivity.class); - startActivity(wi); + startActivityForResult(wi, TUNNEL_WIZARD_REQUEST); default: return super.onOptionsItemSelected(item); } } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == TUNNEL_WIZARD_REQUEST) { + if (resultCode == Activity.RESULT_OK) { + Bundle tunnelData = data.getExtras().getBundle(TUNNEL_WIZARD_DATA); + } + } + } + /** * Turns on activate-on-click mode. When this mode is on, list items will be * given the 'activated' state when touched. -- GitLab