diff --git a/res/layout/create_contact_dialog.xml b/res/layout/create_contact_dialog.xml
index 93248b40e..4b5b9a04a 100644
--- a/res/layout/create_contact_dialog.xml
+++ b/res/layout/create_contact_dialog.xml
@@ -19,7 +19,7 @@
diff --git a/res/layout/join_conference_dialog.xml b/res/layout/join_conference_dialog.xml
new file mode 100644
index 000000000..2a0e300a2
--- /dev/null
+++ b/res/layout/join_conference_dialog.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/menu/start_conversation.xml b/res/menu/start_conversation.xml
index 12109d7b6..907fbdede 100644
--- a/res/menu/start_conversation.xml
+++ b/res/menu/start_conversation.xml
@@ -14,10 +14,10 @@
android:showAsAction="always"
android:title="@string/create_contact"/>
+ android:title="@string/join_conference"/>
- Conferences
Search
Create Contact
- Create Conference
+ Join Conference
Delete Contact
View contact details
Create
The contact already exists
+ Join
+ Conference address
+ room@conference.example.com
+ Save as bookmark
\ No newline at end of file
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index dcdd21ddf..259a2b801 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1529,4 +1529,17 @@ public class XmppConnectionService extends Service {
}
return hosts;
}
+
+ public List getKnownConferenceHosts() {
+ ArrayList mucServers = new ArrayList();
+ for (Account account : accounts) {
+ if (account.getXmppConnection() != null) {
+ String server = account.getXmppConnection().getMucServer();
+ if (server != null) {
+ mucServers.add(server);
+ }
+ }
+ }
+ return mucServers;
+ }
}
diff --git a/src/eu/siacs/conversations/ui/StartConversation.java b/src/eu/siacs/conversations/ui/StartConversation.java
index 3986929f2..a105acd76 100644
--- a/src/eu/siacs/conversations/ui/StartConversation.java
+++ b/src/eu/siacs/conversations/ui/StartConversation.java
@@ -60,6 +60,7 @@ public class StartConversation extends XmppActivity {
private List mActivatedAccounts = new ArrayList();
private List mKnownHosts;
+ private List mKnownConferenceHosts;
private TabListener mTabListener = new TabListener() {
@@ -207,9 +208,39 @@ public class StartConversation extends XmppActivity {
}
+ protected void showJoinConferenceDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.join_conference);
+ View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
+ final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
+ final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
+ jid.setAdapter(new KnownHostsAdapter(this, android.R.layout.simple_list_item_1, mKnownConferenceHosts));
+ populateAccountSpinner(spinner);
+ builder.setView(dialogView);
+ builder.setNegativeButton(R.string.cancel, null);
+ builder.setPositiveButton(R.string.join, null);
+ final AlertDialog dialog = builder.create();
+ dialog.show();
+ dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (Validator.isValidJid(jid.getText().toString())) {
+ String accountJid = (String) spinner.getSelectedItem();
+ String conferenceJid = jid.getText().toString();
+ Account account = xmppConnectionService.findAccountByJid(accountJid);
+ Conversation conversation = xmppConnectionService.findOrCreateConversation(account, conferenceJid, true);
+ switchToConversation(conversation);
+ } else {
+ jid.setError(getString(R.string.invalid_jid));
+ }
+ }
+ });
+ }
+
protected void switchToConversation(Contact contact) {
Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false);
- switchToConversation(conversation, null, false);
+ switchToConversation(conversation);
}
private void populateAccountSpinner(Spinner spinner) {
@@ -224,7 +255,7 @@ public class StartConversation extends XmppActivity {
MenuItem menuCreateContact = (MenuItem) menu
.findItem(R.id.action_create_contact);
MenuItem menuCreateConference = (MenuItem) menu
- .findItem(R.id.action_create_conference);
+ .findItem(R.id.action_join_conference);
MenuItem menuSearch = (MenuItem) menu.findItem(R.id.action_search);
if (getActionBar().getSelectedNavigationIndex() == 0) {
menuCreateConference.setVisible(false);
@@ -246,6 +277,9 @@ public class StartConversation extends XmppActivity {
case R.id.action_create_contact:
showCreateContactDialog();
break;
+ case R.id.action_join_conference:
+ showJoinConferenceDialog();
+ break;
}
return super.onOptionsItemSelected(item);
}
@@ -260,6 +294,7 @@ public class StartConversation extends XmppActivity {
}
}
this.mKnownHosts = xmppConnectionService.getKnownHosts();
+ this.mKnownConferenceHosts = xmppConnectionService.getKnownConferenceHosts();
}
protected void filterContacts(String needle) {
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 96278a6d7..7abb2cefb 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -149,6 +149,10 @@ public abstract class XmppActivity extends Activity {
ExceptionHelper.init(getApplicationContext());
}
+ public void switchToConversation(Conversation conversation) {
+ switchToConversation(conversation, null, false);
+ }
+
public void switchToConversation(Conversation conversation, String text,
boolean newTask) {
Intent viewConversationIntent = new Intent(this,