diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/XmppActivity.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 2ff317a4b..a9147fba2 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -42,6 +42,7 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; +import android.widget.Toast; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; @@ -54,6 +55,7 @@ import net.java.otr4j.session.SessionID; import java.io.FileNotFoundException; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.concurrent.RejectedExecutionException; @@ -240,9 +242,6 @@ public abstract class XmppActivity extends Activity { if (this instanceof XmppConnectionService.OnRosterUpdate) { this.xmppConnectionService.setOnRosterUpdateListener((XmppConnectionService.OnRosterUpdate) this); } - if (this instanceof MucOptions.OnRenameListener) { - this.xmppConnectionService.setOnRenameListener((MucOptions.OnRenameListener) this); - } } protected void unregisterListeners() { @@ -255,9 +254,6 @@ public abstract class XmppActivity extends Activity { if (this instanceof XmppConnectionService.OnRosterUpdate) { this.xmppConnectionService.removeOnRosterUpdateListener(); } - if (this instanceof MucOptions.OnRenameListener) { - this.xmppConnectionService.setOnRenameListener(null); - } } public boolean onOptionsItemSelected(MenuItem item) { @@ -603,18 +599,53 @@ public abstract class XmppActivity extends Activity { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_INVITE_TO_CONVERSATION && resultCode == RESULT_OK) { - String contactJid = data.getStringExtra("contact"); - String conversationUuid = data.getStringExtra("conversation"); - Conversation conversation = xmppConnectionService - .findConversationByUuid(conversationUuid); - if (conversation.getMode() == Conversation.MODE_MULTI) { - xmppConnectionService.invite(conversation, contactJid); + try { + Jid jid = Jid.fromString(data.getStringExtra("contact")); + String conversationUuid = data.getStringExtra("conversation"); + Conversation conversation = xmppConnectionService + .findConversationByUuid(conversationUuid); + if (conversation.getMode() == Conversation.MODE_MULTI) { + xmppConnectionService.invite(conversation, jid); + } else { + List<Jid> jids = new ArrayList<Jid>(); + jids.add(conversation.getContactJid().toBareJid()); + jids.add(jid); + xmppConnectionService.createAdhocConference(conversation.getAccount(), jids, adhocCallback); + } + } catch (final InvalidJidException ignored) { + } - Log.d(Config.LOGTAG, "inviting " + contactJid + " to " - + conversation.getName()); } } + private UiCallback<Conversation> adhocCallback = new UiCallback<Conversation>() { + @Override + public void success(final Conversation conversation) { + switchToConversation(conversation); + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(XmppActivity.this,R.string.conference_created,Toast.LENGTH_LONG).show(); + } + }); + } + + @Override + public void error(final int errorCode, Conversation object) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(XmppActivity.this,errorCode,Toast.LENGTH_LONG).show(); + } + }); + } + + @Override + public void userInputRequried(PendingIntent pi, Conversation object) { + + } + }; + public int getSecondaryTextColor() { return this.mSecondaryTextColor; } |