mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-26 09:19:07 -05:00
added join conference dialog
This commit is contained in:
parent
690ee4988e
commit
610df2eddc
@ -19,7 +19,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/jabber_id"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
@ -28,10 +28,11 @@
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/jid"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textEmailAddress"
|
||||
android:hint="@string/account_settings_example_jabber_id"
|
||||
android:textColorHint="@color/secondarytext"
|
||||
android:textColor="@color/primarytext"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
46
res/layout/join_conference_dialog.xml
Normal file
46
res/layout/join_conference_dialog.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/your_account"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/primarytext"
|
||||
android:text="@string/your_account" />
|
||||
<Spinner
|
||||
android:id="@+id/account"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/jabber_id"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/primarytext"
|
||||
android:text="@string/conference_address" />
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/jid"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textEmailAddress"
|
||||
android:hint="@string/conference_address_example"
|
||||
android:textColorHint="@color/secondarytext"
|
||||
android:textColor="@color/primarytext"
|
||||
/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/bookmark"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save_as_bookmark" />
|
||||
|
||||
</LinearLayout>
|
@ -14,10 +14,10 @@
|
||||
android:showAsAction="always"
|
||||
android:title="@string/create_contact"/>
|
||||
<item
|
||||
android:id="@+id/action_create_conference"
|
||||
android:id="@+id/action_join_conference"
|
||||
android:icon="@drawable/ic_action_add_group"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/create_conference"/>
|
||||
android:title="@string/join_conference"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_accounts"
|
||||
|
@ -258,9 +258,13 @@
|
||||
<string name="conferences">Conferences</string>
|
||||
<string name="search">Search</string>
|
||||
<string name="create_contact">Create Contact</string>
|
||||
<string name="create_conference">Create Conference</string>
|
||||
<string name="join_conference">Join Conference</string>
|
||||
<string name="delete_contact">Delete Contact</string>
|
||||
<string name="view_contact_details">View contact details</string>
|
||||
<string name="create">Create</string>
|
||||
<string name="contact_already_exists">The contact already exists</string>
|
||||
<string name="join">Join</string>
|
||||
<string name="conference_address">Conference address</string>
|
||||
<string name="conference_address_example">room@conference.example.com</string>
|
||||
<string name="save_as_bookmark">Save as bookmark</string>
|
||||
</resources>
|
@ -1529,4 +1529,17 @@ public class XmppConnectionService extends Service {
|
||||
}
|
||||
return hosts;
|
||||
}
|
||||
|
||||
public List<String> getKnownConferenceHosts() {
|
||||
ArrayList<String> mucServers = new ArrayList<String>();
|
||||
for (Account account : accounts) {
|
||||
if (account.getXmppConnection() != null) {
|
||||
String server = account.getXmppConnection().getMucServer();
|
||||
if (server != null) {
|
||||
mucServers.add(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mucServers;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user