I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit c46ba4f2 authored by str4d's avatar str4d
Browse files

Moved tunnel wizard model key strings into resource, dismiss submit dialog

parent 52217859
No related branches found
No related tags found
No related merge requests found
......@@ -86,9 +86,24 @@
<string name="i2ptunnel_type_streamrclient">Streamr client</string>
<string name="i2ptunnel_type_streamrserver">Streamr server</string>
<string name="i2ptunnel_type_httpbidirserver">HTTP bidir</string>
<string name="i2ptunnel_not_initialized">Tunnels are not initialized yet, please reload in two minutes.</string>
<string name="i2ptunnel_new_tunnel">New Tunnel</string>
<string name="i2ptunnel_wizard_k_client_server">Client or Server</string>
<string name="i2ptunnel_wizard_v_client">Client tunnel</string>
<string name="i2ptunnel_wizard_v_server">Server tunnel</string>
<string name="i2ptunnel_wizard_k_type">Tunnel type</string>
<string name="i2ptunnel_wizard_k_name">Name</string>
<string name="i2ptunnel_wizard_k_desc">Description</string>
<string name="i2ptunnel_wizard_k_dest">Destination</string>
<string name="i2ptunnel_wizard_k_outproxies">Outproxies</string>
<string name="i2ptunnel_wizard_k_target_host">Target host</string>
<string name="i2ptunnel_wizard_k_target_port">Target port</string>
<string name="i2ptunnel_wizard_k_reachable_on">Reachable on</string>
<string name="i2ptunnel_wizard_k_binding_port">Binding port</string>
<string name="i2ptunnel_wizard_k_auto_start">Auto start</string>
<string name="next">Next</string>
<string name="prev">Previous</string>
<string name="finish">Submit</string>
......
......@@ -36,7 +36,7 @@ public class TunnelWizardActivity extends FragmentActivity implements
private boolean mEditingAfterReview;
private AbstractWizardModel mWizardModel = new TunnelWizardModel(this);
private AbstractWizardModel mWizardModel;
private boolean mConsumePageSelectedEvent;
......@@ -50,6 +50,7 @@ public class TunnelWizardActivity extends FragmentActivity implements
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wizard);
mWizardModel = new TunnelWizardModel(this);
if (savedInstanceState != null)
mWizardModel.load(savedInstanceState.getBundle("model"));
......@@ -101,6 +102,7 @@ public class TunnelWizardActivity extends FragmentActivity implements
Intent result = new Intent();
result.putExtra(TunnelListFragment.TUNNEL_WIZARD_DATA, mWizardModel.save());
setResult(Activity.RESULT_OK, result);
dialog.dismiss();
finish();
}
})
......
package net.i2p.android.i2ptunnel.activity;
import android.content.Context;
import android.content.res.Resources;
import net.i2p.android.router.R;
import net.i2p.android.wizard.model.AbstractWizardModel;
import net.i2p.android.wizard.model.BranchPage;
import net.i2p.android.wizard.model.Conditional;
......@@ -16,69 +18,102 @@ public class TunnelWizardModel extends AbstractWizardModel {
@Override
protected PageList onNewRootPageList() {
Resources res = mContext.getResources();
Conditional cTunnelType = new Conditional();
Conditional cClientType = new Conditional();
Conditional cServerType = new Conditional();
return new PageList(
new BranchPage(this, "Client or Server")
.addBranch("Client tunnel",
new SingleFixedChoicePage(this, "Tunnel type")
.setChoices("Standard", "HTTP", "IRC", "SOCKS 4/4a/5", "SOCKS IRC", "CONNECT", "Streamr")
new BranchPage(this, res.getString(R.string.i2ptunnel_wizard_k_client_server))
.addBranch(res.getString(R.string.i2ptunnel_wizard_v_client),
new SingleFixedChoicePage(this, res.getString(R.string.i2ptunnel_wizard_k_type))
.setChoices(
res.getString(R.string.i2ptunnel_type_client),
res.getString(R.string.i2ptunnel_type_httpclient),
res.getString(R.string.i2ptunnel_type_ircclient),
res.getString(R.string.i2ptunnel_type_sockstunnel),
res.getString(R.string.i2ptunnel_type_socksirctunnel),
res.getString(R.string.i2ptunnel_type_connectclient),
res.getString(R.string.i2ptunnel_type_streamrclient))
.setRequired(true)
.makeConditional(cClientType))
.addBranch("Server tunnel",
new SingleFixedChoicePage(this, "Tunnel type")
.setChoices("Standard", "HTTP", "HTTP bidir", "IRC", "Streamr")
.addBranch(res.getString(R.string.i2ptunnel_wizard_v_server),
new SingleFixedChoicePage(this, res.getString(R.string.i2ptunnel_wizard_k_type))
.setChoices(
res.getString(R.string.i2ptunnel_type_server),
res.getString(R.string.i2ptunnel_type_httpserver),
res.getString(R.string.i2ptunnel_type_httpbidirserver),
res.getString(R.string.i2ptunnel_type_ircserver),
res.getString(R.string.i2ptunnel_type_streamrserver))
.setRequired(true)
.makeConditional(cServerType))
.setRequired(true)
.makeConditional(cTunnelType),
new SingleTextFieldPage(this, "Name")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_name))
.setDescription("The name of the tunnel, for identification in the tunnel list.")
.setRequired(true),
new SingleTextFieldPage(this, "Description")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_desc))
.setDescription("A description of the tunnel. This is optional and purely informative."),
new SingleTextFieldPage(this, "Destination")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_dest))
.setDescription("Type in the I2P destination of the service that this client tunnel should connect to. This could be the full base 64 destination key, or an I2P URL from your address book.")
.setRequired(true)
.setEqualAnyCondition(cClientType, "Standard", "IRC", "Streamr"),
.setEqualAnyCondition(cClientType,
res.getString(R.string.i2ptunnel_type_client),
res.getString(R.string.i2ptunnel_type_ircclient),
res.getString(R.string.i2ptunnel_type_streamrclient)),
new SingleTextFieldPage(this, "Outproxies")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_outproxies))
.setDescription("If you know of any outproxies for this type of tunnel (either HTTP or SOCKS), fill them in. Separate multiple proxies with commas.")
.setEqualAnyCondition(cClientType, "HTTP", "CONNECT", "SOCKS 4/4a/5", "SOCKS IRC"),
.setEqualAnyCondition(cClientType,
res.getString(R.string.i2ptunnel_type_httpclient),
res.getString(R.string.i2ptunnel_type_connectclient),
res.getString(R.string.i2ptunnel_type_sockstunnel),
res.getString(R.string.i2ptunnel_type_socksirctunnel)),
// Not set required because a default is specified.
// Otherwise user would need to edit the field to
// enable the Next button.
new SingleTextFieldPage(this, "Target host")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_target_host))
.setDefault("127.0.0.1")
.setDescription("This is the IP that your service is running on, this is usually on the same machine so 127.0.0.1 is autofilled.")
.setEqualCondition(cClientType, "Streamr")
.setEqualAnyCondition(cServerType, "Standard", "HTTP", "HTTP bidir", "IRC"),
.setEqualCondition(cClientType,
res.getString(R.string.i2ptunnel_type_streamrclient))
.setEqualAnyCondition(cServerType,
res.getString(R.string.i2ptunnel_type_server),
res.getString(R.string.i2ptunnel_type_httpserver),
res.getString(R.string.i2ptunnel_type_httpbidirserver),
res.getString(R.string.i2ptunnel_type_ircserver)),
new SingleTextFieldPage(this, "Target port")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_target_port))
.setDescription("This is the port that the service is accepting connections on.")
.setRequired(true)
.setEqualCondition(cTunnelType, "Server tunnel"),
.setEqualCondition(cTunnelType, res.getString(R.string.i2ptunnel_wizard_v_server)),
// Not set required because a default is specified.
new SingleTextFieldPage(this, "Reachable on")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_reachable_on))
.setDefault("127.0.0.1")
.setDescription("This limits what computers or smartphones can access this tunnel.")
.setEqualAnyCondition(cClientType, "Standard", "HTTP", "IRC", "SOCKS 4/4a/5", "SOCKS IRC", "CONNECT")
.setEqualAnyCondition(cServerType, "HTTP bidir", "Streamr"),
.setEqualAnyCondition(cClientType,
res.getString(R.string.i2ptunnel_type_client),
res.getString(R.string.i2ptunnel_type_httpclient),
res.getString(R.string.i2ptunnel_type_ircclient),
res.getString(R.string.i2ptunnel_type_sockstunnel),
res.getString(R.string.i2ptunnel_type_socksirctunnel),
res.getString(R.string.i2ptunnel_type_connectclient))
.setEqualAnyCondition(cServerType,
res.getString(R.string.i2ptunnel_type_httpbidirserver),
res.getString(R.string.i2ptunnel_type_streamrserver)),
new SingleTextFieldPage(this, "Binding port")
new SingleTextFieldPage(this, res.getString(R.string.i2ptunnel_wizard_k_binding_port))
.setDescription("This is the port that the client tunnel will be accessed from locally. This is also the client port for the HTTP bidir server tunnel.")
.setRequired(true)
.setEqualCondition(cTunnelType, "Client tunnel")
.setEqualCondition(cServerType, "HTTP bidir"),
.setEqualCondition(cTunnelType, res.getString(R.string.i2ptunnel_wizard_v_client))
.setEqualCondition(cServerType, res.getString(R.string.i2ptunnel_type_httpbidirserver)),
new SingleFixedBooleanPage(this, "Auto start")
new SingleFixedBooleanPage(this, res.getString(R.string.i2ptunnel_wizard_k_auto_start))
.setDescription("Should the tunnel automatically start when the router starts?")
.setRequired(true)
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment