From 9116782cdcee896137562196031929aaab37e50d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 13 Feb 2017 17:32:26 +0100 Subject: [PATCH] fixed adhoc conference creation behaviour. properly show errors. fixes #2290 --- .../conversations/services/XmppConnectionService.java | 9 ++++++--- .../eu/siacs/conversations/ui/ConversationActivity.java | 1 + .../conversations/ui/StartConversationActivity.java | 7 ++++--- .../java/eu/siacs/conversations/ui/XmppActivity.java | 3 +-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 93981f4a4..99b075629 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2410,7 +2410,7 @@ public class XmppConnectionService extends Service { } } - private String findConferenceServer(final Account account) { + public String findConferenceServer(final Account account) { String server; if (account.getXmppConnection() != null) { server = account.getXmppConnection().getMucServer(); @@ -2429,7 +2429,7 @@ public class XmppConnectionService extends Service { return null; } - public void createAdhocConference(final Account account, + public boolean createAdhocConference(final Account account, final String subject, final Iterable jids, final UiCallback callback) { @@ -2441,7 +2441,7 @@ public class XmppConnectionService extends Service { if (callback != null) { callback.error(R.string.no_conference_server_found, null); } - return; + return false; } final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null); final Conversation conversation = findOrCreateConversation(account, jid, true); @@ -2476,15 +2476,18 @@ public class XmppConnectionService extends Service { }); } }); + return true; } catch (InvalidJidException e) { if (callback != null) { callback.error(R.string.conference_creation_failed, null); } + return false; } } else { if (callback != null) { callback.error(R.string.not_connected_try_again, null); } + return false; } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 25cb0d2d3..ce8867e80 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -426,6 +426,7 @@ public class ConversationActivity extends XmppActivity menuContactDetails.setVisible(!this.getSelectedConversation().withSelf()); menuMucDetails.setVisible(false); menuSecure.setVisible(Config.multipleEncryptionChoices()); + menuInviteContact.setVisible(xmppConnectionService != null && xmppConnectionService.findConferenceServer(getSelectedConversation().getAccount()) != null); } if (this.getSelectedConversation().isMuted()) { menuMute.setVisible(false); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 3585f03ab..b81d2d979 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -719,9 +719,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } if (account != null && jids.size() > 0) { - xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback); - mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG); - mToast.show(); + if (xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback)) { + mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG); + mToast.show(); + } } } } else { diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 583fab785..ac3216e23 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -1116,8 +1116,7 @@ public abstract class XmppActivity extends Activity { return false; } else { jids.add(conversation.getJid().toBareJid()); - service.createAdhocConference(conversation.getAccount(), null, jids, activity.adhocCallback); - return true; + return service.createAdhocConference(conversation.getAccount(), null, jids, activity.adhocCallback); } } }