From e3ca4ca485a3fbed30a9d9a02847519ca64df219 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 27 Feb 2018 18:08:09 +0100 Subject: [PATCH] made conference invite work again --- .../AttachFileToConversationRunnable.java | 1 + .../ui/ChooseContactActivity.java | 24 +++++++++++++++++++ .../ui/ConversationActivity.java | 6 +++++ .../ui/ConversationFragment.java | 20 ++++++++++++---- .../siacs/conversations/ui/XmppActivity.java | 19 +-------------- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 9f5020c91..e5a3a4dd3 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -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); } } diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index 5eb1410f0..d889c0ca4 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -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 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; + } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index c367b84a4..c9874ca81 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -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) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 831970d41..2c6ec41d2 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -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() { diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index d03a449e3..42cf18872 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -568,24 +568,7 @@ public abstract class XmppActivity extends AppCompatActivity { } protected void inviteToConversation(Conversation conversation) { - Intent intent = new Intent(this, ChooseContactActivity.class); - List 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) {