diff options
author | Jeremy Klein <jklein24@gmail.com> | 2015-10-06 13:01:04 -0700 |
---|---|---|
committer | Jeremy Klein <jklein24@gmail.com> | 2015-10-06 13:01:04 -0700 |
commit | 28a10c2e533942eb208d3bdf68902645cbf2e3f8 (patch) | |
tree | 117ac13eea08d862c027ac4eb263df0f71d006c0 | |
parent | 049ffdd646df63c9a705db0ad8b6ce24c6a76775 (diff) | |
parent | 835dac4485c52362a13f4895f8c687e301000d96 (diff) | |
download | connectbot-28a10c2e533942eb208d3bdf68902645cbf2e3f8.tar.gz connectbot-28a10c2e533942eb208d3bdf68902645cbf2e3f8.tar.bz2 connectbot-28a10c2e533942eb208d3bdf68902645cbf2e3f8.zip |
Merge pull request #240 from rhansby/fix-validation-in-portforward-creation
Fixed error when not filling in all fields of port forward creation dialog
-rw-r--r-- | app/src/main/java/org/connectbot/PortForwardListActivity.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/src/main/java/org/connectbot/PortForwardListActivity.java b/app/src/main/java/org/connectbot/PortForwardListActivity.java index c7f0e7c..e5d3210 100644 --- a/app/src/main/java/org/connectbot/PortForwardListActivity.java +++ b/app/src/main/java/org/connectbot/PortForwardListActivity.java @@ -188,11 +188,23 @@ public class PortForwardListActivity extends AppCompatListActivity { break; } + // Why length(), not isEmpty(), is used: http://stackoverflow.com/q/10606725 + String sourcePort = sourcePortEdit.getText().toString(); + if (sourcePort.length() == 0) { + sourcePort = sourcePortEdit.getHint().toString(); + } + + String destination = destEdit.getText().toString(); + if (destination.length() == 0) { + destination = destEdit.getHint().toString(); + } + PortForwardBean portForward = new PortForwardBean( host != null ? host.getId() : -1, - nicknameEdit.getText().toString(), type, - sourcePortEdit.getText().toString(), - destEdit.getText().toString()); + nicknameEdit.getText().toString(), + type, + sourcePort, + destination); if (hostBridge != null) { hostBridge.addPortForward(portForward); |