aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/StartConversation.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-11 19:48:41 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-11 19:48:41 +0200
commit610df2eddc06d9b7cbe0157a2f101eb9eaef76d0 (patch)
tree93fa18809c9b2cb606006e36801b513d81575bd8 /src/eu/siacs/conversations/ui/StartConversation.java
parent690ee4988eda2c23830f514d31302b2837bd04f4 (diff)
added join conference dialog
Diffstat (limited to 'src/eu/siacs/conversations/ui/StartConversation.java')
-rw-r--r--src/eu/siacs/conversations/ui/StartConversation.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/ui/StartConversation.java b/src/eu/siacs/conversations/ui/StartConversation.java
index 3986929f..a105acd7 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<String> mActivatedAccounts = new ArrayList<String>();
private List<String> mKnownHosts;
+ private List<String> 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) {