fixed adhoc conference creation behaviour. properly show errors. fixes #2290

This commit is contained in:
Daniel Gultsch 2017-02-13 17:32:26 +01:00
parent c8f97be68e
commit 9116782cdc
4 changed files with 12 additions and 8 deletions

View file

@ -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<Jid> jids,
final UiCallback<Conversation> 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;
}
}

View file

@ -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);

View file

@ -719,11 +719,12 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
}
if (account != null && jids.size() > 0) {
xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback);
if (xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback)) {
mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG);
mToast.show();
}
}
}
} else {
this.mPostponedActivityResult = new Pair<>(requestCode, intent);
}

View file

@ -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);
}
}
}