diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-11-14 20:34:54 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-11-15 17:14:08 +0100 |
commit | 533076813ba0c903dda7f12359f71a886386b45f (patch) | |
tree | 41c9a82ef9bcb45a0fb8165c4d93045344db896c /src/main/java/de/pixart/messenger/ui | |
parent | f42f00b40eaa0ba9ed03592deea2651cab8ed4a0 (diff) |
do not validate port if hostname is empty
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/EditAccountActivity.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 801dc3767..f32ecf14f 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -212,20 +212,21 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat removeErrorsOnAllBut(binding.hostnameLayout); return; } - try { - numericPort = Integer.parseInt(port); - if (numericPort < 0 || numericPort > 65535) { + if (!hostname.isEmpty()) { + try { + numericPort = Integer.parseInt(port); + if (numericPort < 0 || numericPort > 65535) { + binding.portLayout.setError(getString(R.string.not_a_valid_port)); + removeErrorsOnAllBut(binding.portLayout); + binding.port.requestFocus(); + return; + } + } catch (NumberFormatException e) { binding.portLayout.setError(getString(R.string.not_a_valid_port)); removeErrorsOnAllBut(binding.portLayout); binding.port.requestFocus(); return; } - - } catch (NumberFormatException e) { - binding.portLayout.setError(getString(R.string.not_a_valid_port)); - removeErrorsOnAllBut(binding.portLayout); - binding.port.requestFocus(); - return; } } @@ -512,8 +513,13 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } private void updatePortLayout() { - String hostname = this.binding.hostname.getText().toString(); - this.binding.portLayout.setEnabled(!TextUtils.isEmpty(hostname)); + final String hostname = this.binding.hostname.getText().toString(); + if (TextUtils.isEmpty(hostname)) { + this.binding.portLayout.setEnabled(false); + this.binding.portLayout.setError(null); + } else { + this.binding.portLayout.setEnabled(true); + } } protected void updateSaveButton() { |