From c46ba4f24b1cc3dc1d67dfa96a997250bcb4bb85 Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Tue, 27 Aug 2013 03:36:27 +0000 Subject: [PATCH] Moved tunnel wizard model key strings into resource, dismiss submit dialog --- res/values/strings.xml | 15 ++++ .../activity/TunnelWizardActivity.java | 4 +- .../i2ptunnel/activity/TunnelWizardModel.java | 85 +++++++++++++------ 3 files changed, 78 insertions(+), 26 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 5ed2141fd..81ed8b75d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -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> diff --git a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java index 5bc9590f7..8a977ebcb 100644 --- a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java +++ b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardActivity.java @@ -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(); } }) diff --git a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardModel.java b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardModel.java index c1f938ce5..3a81afa62 100644 --- a/src/net/i2p/android/i2ptunnel/activity/TunnelWizardModel.java +++ b/src/net/i2p/android/i2ptunnel/activity/TunnelWizardModel.java @@ -1,6 +1,8 @@ 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) ); -- GitLab