show warning when opening invalid jid

This commit is contained in:
Daniel Gultsch 2017-12-05 17:29:05 +01:00
parent b5fe8789e9
commit 5885bc7f25
2 changed files with 13 additions and 0 deletions

View File

@ -1193,6 +1193,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);
}

View File

@ -151,6 +151,15 @@ public class XmppUri {
}
}
public boolean isJidValid() {
try {
Jid.fromString(jid);
return true;
} catch (InvalidJidException e) {
return false;
}
}
public String getBody() {
return body;
}