Implemented starting and stopping tunnels
This commit is contained in:
@ -98,6 +98,8 @@
|
||||
<string name="i2ptunnel_new_tunnel">New Tunnel</string>
|
||||
<string name="i2ptunnel_msg_config_saved">Configuration changes saved</string>
|
||||
<string name="i2ptunnel_msg_config_save_failed">Failed to save configuration</string>
|
||||
<string name="i2ptunnel_msg_tunnel_starting">Starting tunnel</string>
|
||||
<string name="i2ptunnel_msg_tunnel_stopping">Stopping tunnel</string>
|
||||
<string name="i2ptunnel_delete_confirm_message">Delete tunnel?</string>
|
||||
<string name="i2ptunnel_delete_confirm_button">Delete tunnel</string>
|
||||
|
||||
|
@ -128,6 +128,24 @@ public class TunnelDetailFragment extends Fragment {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle presses on the action bar items
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_start_tunnel:
|
||||
mTunnel.getController().startTunnelBackground();
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
getResources().getString(R.string.i2ptunnel_msg_tunnel_starting)
|
||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||
// Reload the action bar to change the start/stop action
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
case R.id.action_stop_tunnel:
|
||||
mTunnel.getController().stopTunnel();
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
getResources().getString(R.string.i2ptunnel_msg_tunnel_stopping)
|
||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||
// Reload the action bar to change the start/stop action
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
case R.id.action_edit_tunnel:
|
||||
return true;
|
||||
case R.id.action_delete_tunnel:
|
||||
DialogFragment dg = new DialogFragment() {
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class TunnelListFragment extends ListFragment
|
||||
implements LoaderManager.LoaderCallbacks<List<TunnelEntry>> {
|
||||
@ -145,10 +146,21 @@ public class TunnelListFragment extends ListFragment
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle presses on the action bar items
|
||||
List<String> msgs;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add_tunnel:
|
||||
Intent wi = new Intent(getActivity(), TunnelWizardActivity.class);
|
||||
startActivityForResult(wi, TUNNEL_WIZARD_REQUEST);
|
||||
return true;
|
||||
case R.id.action_start_all_tunnels:
|
||||
msgs = mGroup.startAllControllers();
|
||||
break;
|
||||
case R.id.action_stop_all_tunnels:
|
||||
msgs = mGroup.stopAllControllers();
|
||||
break;
|
||||
case R.id.action_restart_all_tunnels:
|
||||
msgs = mGroup.restartAllControllers();
|
||||
break;
|
||||
case R.id.action_i2ptunnel_help:
|
||||
Intent hi = new Intent(getActivity(), HelpActivity.class);
|
||||
hi.putExtra(HelpActivity.REFERRER, "i2ptunnel");
|
||||
@ -157,6 +169,11 @@ public class TunnelListFragment extends ListFragment
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
// TODO: Do something with the other messages
|
||||
if (msgs.size() > 0)
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
msgs.get(0), Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user