From a1e3198deea193cf4392b0a37d724ebfb1ab4d19 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 10 Dec 2017 21:34:52 +0100 Subject: show warning when opening invalid jid --- .../java/de/pixart/messenger/ui/StartConversationActivity.java | 4 ++++ src/main/java/de/pixart/messenger/utils/XmppUri.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 642296c31..23a0bf011 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -1192,6 +1192,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU public String account; boolean invite() { + if (!isJidValid()) { + Toast.makeText(StartConversationActivity.this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); + return false; + } if (getJid() != null) { return handleJid(this); } diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java index 120f0e88a..24c0b3bff 100644 --- a/src/main/java/de/pixart/messenger/utils/XmppUri.java +++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java @@ -156,6 +156,15 @@ public class XmppUri { } } + public boolean isJidValid() { + try { + Jid.fromString(jid); + return true; + } catch (InvalidJidException e) { + return false; + } + } + public String getBody() { return body; } -- cgit v1.2.3