diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-20 18:20:42 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-20 18:20:42 +0100 |
commit | 0ad6d0616f9663814f6f9f24590833425f6ad372 (patch) | |
tree | fa4b9b39accdf10e176b1c34e4f1b4b140cd6eed /src/main/java/eu/siacs/conversations/ui | |
parent | e9948f6b8417803e2856f53482d5a158eb9ffa2e (diff) |
brought ad hoc conferences back. fixed #688 fixed #367
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
4 files changed, 87 insertions, 37 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index c97f9e56a..a966f77b5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -34,7 +34,7 @@ import eu.siacs.conversations.entities.MucOptions.User; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnRenameListener { +public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate { public static final String ACTION_VIEW_MUC = "view_muc"; private Conversation mConversation; private OnClickListener inviteListener = new OnClickListener() { @@ -57,26 +57,34 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private List<User> users = new ArrayList<>(); private User mSelectedUser = null; - @Override - public void onRename(final boolean success) { - runOnUiThread(new Runnable() { + private UiCallback<Conversation> renameCallback = new UiCallback<Conversation>() { + @Override + public void success(Conversation object) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(ConferenceDetailsActivity.this,getString(R.string.your_nick_has_been_changed),Toast.LENGTH_SHORT).show(); + populateView(); + } + }); - @Override - public void run() { - populateView(); - if (success) { - Toast.makeText( - ConferenceDetailsActivity.this, - getString(R.string.your_nick_has_been_changed), - Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(ConferenceDetailsActivity.this, - getString(R.string.nick_in_use), - Toast.LENGTH_SHORT).show(); + } + + @Override + public void error(final int errorCode, Conversation object) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(ConferenceDetailsActivity.this,getString(errorCode),Toast.LENGTH_SHORT).show(); } - } - }); - } + }); + } + + @Override + public void userInputRequried(PendingIntent pi, Conversation object) { + + } + }; @Override public void onConversationUpdate() { @@ -114,8 +122,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public void onValueEdited(String value) { - xmppConnectionService.renameInMuc(mConversation, - value); + xmppConnectionService.renameInMuc(mConversation,value,renameCallback); } }); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 721ad9c30..0be3a957a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -225,6 +225,18 @@ public class ConversationActivity extends XmppActivity implements } } + @Override + public void switchToConversation(Conversation conversation) { + setSelectedConversation(conversation); + runOnUiThread(new Runnable() { + @Override + public void run() { + ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); + openConversation(); + } + }); + } + public void openConversation() { ActionBar ab = getActionBar(); if (ab != null) { @@ -286,7 +298,7 @@ public class ConversationActivity extends XmppActivity implements menuAttach.setVisible(false); } else { menuMucDetails.setVisible(false); - menuInviteContact.setVisible(false); + menuInviteContact.setTitle(R.string.conference_with); } if (this.getSelectedConversation().isMuted()) { menuMute.setVisible(false); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index abfd07273..287d1636b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -553,7 +553,7 @@ public class ConversationFragment extends Fragment { showSnackbar(R.string.nick_in_use, R.string.edit, clickToMuc); break; - case MucOptions.ERROR_ROOM_NOT_FOUND: + case MucOptions.ERROR_UNKNOWN: showSnackbar(R.string.conference_not_found, R.string.leave, leaveMuc); break; 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; } |