made conference invite work again

This commit is contained in:
Daniel Gultsch 2018-02-27 18:08:09 +01:00
parent 5ed94d5ab0
commit e3ca4ca485
5 changed files with 47 additions and 23 deletions

View file

@ -135,6 +135,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
mXmppConnectionService.getPgpEngine().encrypt(message, callback);
} else {
mXmppConnectionService.sendMessage(message);
callback.success(message);
}
}

View file

@ -1,5 +1,6 @@
package eu.siacs.conversations.ui;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -25,7 +26,9 @@ import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.xmpp.jid.Jid;
public class ChooseContactActivity extends AbstractSearchableListItemActivity {
@ -246,4 +249,25 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
}
this.mKnownHosts = xmppConnectionService.getKnownHosts();
}
public static Intent create(Activity activity, Conversation conversation) {
final Intent intent = new Intent(activity, ChooseContactActivity.class);
List<String> contacts = new ArrayList<>();
if (conversation.getMode() == Conversation.MODE_MULTI) {
for (MucOptions.User user : conversation.getMucOptions().getUsers(false)) {
Jid jid = user.getRealJid();
if (jid != null) {
contacts.add(jid.toBareJid().toString());
}
}
} else {
contacts.add(conversation.getJid().toBareJid().toString());
}
intent.putExtra("filter_contacts", contacts.toArray(new String[contacts.size()]));
intent.putExtra("conversation", conversation.getUuid());
intent.putExtra("multiple", true);
intent.putExtra("show_enter_jid", true);
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
return intent;
}
}

View file

@ -561,6 +561,12 @@ public class ConversationActivity extends XmppActivity implements OnConversation
}
}
@Override
public void switchToConversation(Conversation conversation) {
Log.d(Config.LOGTAG,"override");
openConversation(conversation,null);
}
@Override
public void onConversationRead(Conversation conversation) {
if (!mActivityPaused && pendingViewIntent.peek() == null) {

View file

@ -50,8 +50,6 @@ import android.widget.PopupMenu;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
import org.openintents.openpgp.util.OpenPgpApi;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -102,8 +100,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
import static eu.siacs.conversations.ui.XmppActivity.REQUEST_ANNOUNCE_PGP;
import static eu.siacs.conversations.ui.XmppActivity.REQUEST_CHOOSE_PGP_ID;
import static eu.siacs.conversations.ui.XmppActivity.REQUEST_INVITE_TO_CONVERSATION;
public class ConversationFragment extends XmppFragment implements EditMessage.KeyboardListener {
@ -723,6 +720,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
Uri geo = Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude));
attachLocationToConversation(conversation, geo);
break;
case REQUEST_INVITE_TO_CONVERSATION:
XmppActivity.ConferenceInvite invite = XmppActivity.ConferenceInvite.parse(data);
if (invite != null) {
if (invite.execute(activity)) {
activity.mToast = Toast.makeText(activity, R.string.creating_conference, Toast.LENGTH_LONG);
activity.mToast.show();
}
}
break;
}
}
@ -1075,7 +1081,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
startActivity(intent);
break;
case R.id.action_invite:
activity.inviteToConversation(conversation);
startActivityForResult(ChooseContactActivity.create(activity,conversation), REQUEST_INVITE_TO_CONVERSATION);
break;
case R.id.action_clear_history:
clearHistoryDialog(conversation);
@ -2347,6 +2353,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
setScrollPosition(scrollState);
}
}
ActivityResult activityResult = postponedActivityResult.pop();
if (activityResult != null) {
handleActivityResult(activityResult);
}
}
public void clearPending() {

View file

@ -568,24 +568,7 @@ public abstract class XmppActivity extends AppCompatActivity {
}
protected void inviteToConversation(Conversation conversation) {
Intent intent = new Intent(this, ChooseContactActivity.class);
List<String> contacts = new ArrayList<>();
if (conversation.getMode() == Conversation.MODE_MULTI) {
for (MucOptions.User user : conversation.getMucOptions().getUsers(false)) {
Jid jid = user.getRealJid();
if (jid != null) {
contacts.add(jid.toBareJid().toString());
}
}
} else {
contacts.add(conversation.getJid().toBareJid().toString());
}
intent.putExtra("filter_contacts", contacts.toArray(new String[contacts.size()]));
intent.putExtra("conversation", conversation.getUuid());
intent.putExtra("multiple", true);
intent.putExtra("show_enter_jid", true);
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
startActivityForResult(ChooseContactActivity.create(this,conversation), REQUEST_INVITE_TO_CONVERSATION);
}
protected void announcePgp(Account account, final Conversation conversation, Intent intent, final Runnable onSuccess) {