aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml9
-rw-r--r--res/layout/activity_choose_contact.xml13
-rw-r--r--res/layout/activity_muc_details.xml4
-rw-r--r--res/menu/choose_contact.xml10
-rw-r--r--res/menu/conversations.xml37
-rw-r--r--res/values/strings.xml6
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java7
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java36
-rw-r--r--src/eu/siacs/conversations/ui/ChooseContactActivity.java140
-rw-r--r--src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java (renamed from src/eu/siacs/conversations/ui/MucDetailsActivity.java)19
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java12
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java31
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java6
-rw-r--r--src/eu/siacs/conversations/ui/EditAccountDialog.java (renamed from src/eu/siacs/conversations/ui/EditAccount.java)4
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java10
-rw-r--r--src/eu/siacs/conversations/ui/OnPresenceSelected.java5
-rw-r--r--src/eu/siacs/conversations/ui/StartConversationActivity.java (renamed from src/eu/siacs/conversations/ui/StartConversation.java)44
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java26
-rw-r--r--src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java (renamed from src/eu/siacs/conversations/utils/KnownHostsAdapter.java)4
-rw-r--r--src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java39
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java1
21 files changed, 318 insertions, 145 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a7bfbbe4..c04bb82b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,11 +49,11 @@
</intent-filter>
</activity>
<activity
- android:name="eu.siacs.conversations.ui.StartConversation"
+ android:name="eu.siacs.conversations.ui.StartConversationActivity"
android:configChanges="orientation|screenSize"
android:label="@string/title_activity_start_conversation"
android:logo="@drawable/ic_activity"
- android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity">
+ android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity" >
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
@@ -68,6 +68,9 @@
android:label="@string/title_activity_settings"
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity" >
</activity>
+ <activity android:name="eu.siacs.conversations.ui.ChooseContactActivity"
+ android:label="@string/title_activity_choose_contact">
+ </activity>
<activity
android:name="eu.siacs.conversations.ui.ManageAccountActivity"
android:configChanges="orientation|screenSize"
@@ -75,7 +78,7 @@
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity" >
</activity>
<activity
- android:name="eu.siacs.conversations.ui.MucDetailsActivity"
+ android:name="eu.siacs.conversations.ui.ConferenceDetailsActivity"
android:label="@string/title_activity_conference_details"
android:windowSoftInputMode="stateHidden" >
</activity>
diff --git a/res/layout/activity_choose_contact.xml b/res/layout/activity_choose_contact.xml
new file mode 100644
index 00000000..248a7822
--- /dev/null
+++ b/res/layout/activity_choose_contact.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ListView
+ android:id="@+id/choose_contact_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:listitem="@layout/contact" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/activity_muc_details.xml b/res/layout/activity_muc_details.xml
index d47c6b6e..49b4cef3 100644
--- a/res/layout/activity_muc_details.xml
+++ b/res/layout/activity_muc_details.xml
@@ -63,7 +63,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:text="hallo hallo"
android:textColor="@color/primarytext"
android:textSize="18sp" />
@@ -72,7 +71,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:text="Participant"
android:textColor="@color/primarytext"
android:textSize="14sp" />
</LinearLayout>
@@ -123,7 +121,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24dp"
- android:text="@string/invite_contacts" />
+ android:text="@string/invite_contact" />
</LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/res/menu/choose_contact.xml b/res/menu/choose_contact.xml
new file mode 100644
index 00000000..3f402664
--- /dev/null
+++ b/res/menu/choose_contact.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/action_search"
+ android:actionLayout="@layout/actionview_search"
+ android:icon="@drawable/ic_action_search"
+ android:showAsAction="collapseActionView|always"
+ android:title="@string/search"/>
+</menu> \ No newline at end of file
diff --git a/res/menu/conversations.xml b/res/menu/conversations.xml
index 710a552e..2621289a 100644
--- a/res/menu/conversations.xml
+++ b/res/menu/conversations.xml
@@ -2,47 +2,44 @@
<item
android:id="@+id/action_add"
- android:orderInCategory="10"
android:icon="@drawable/ic_action_new"
+ android:orderInCategory="10"
android:showAsAction="always"
- android:title="@string/action_add" />
-
+ android:title="@string/action_add"/>
<item
android:id="@+id/action_security"
+ android:icon="@drawable/ic_action_not_secure"
android:orderInCategory="20"
android:showAsAction="always"
- android:icon="@drawable/ic_action_not_secure"
- android:title="@string/action_secure" />
-
+ android:title="@string/action_secure"/>
<item
android:id="@+id/action_attach_file"
+ android:icon="@drawable/ic_action_new_attachment"
android:orderInCategory="30"
android:showAsAction="always"
- android:icon="@drawable/ic_action_new_attachment"
- android:title="@string/attach_file" />
-
+ android:title="@string/attach_file"/>
<item
android:id="@+id/action_contact_details"
android:orderInCategory="40"
android:showAsAction="never"
- android:title="@string/action_contact_details" />
- <item
+ android:title="@string/action_contact_details"/>
+ <item
android:id="@+id/action_muc_details"
+ android:icon="@drawable/ic_action_group"
android:orderInCategory="40"
android:showAsAction="ifRoom"
- android:icon="@drawable/ic_action_group"
- android:title="@string/action_muc_details" />
- <item
+ android:title="@string/action_muc_details"/>
+ <item
android:id="@+id/action_invite"
+ android:orderInCategory="45"
android:showAsAction="never"
- android:title="@string/invite_contacts" />
-
+ android:title="@string/invite_contact"/>
<item
android:id="@+id/action_archive"
android:orderInCategory="50"
android:showAsAction="never"
android:title="@string/action_end_conversation"/>
- <item
+ <item
android:id="@+id/action_clear_history"
android:orderInCategory="60"
android:showAsAction="never"
@@ -51,13 +48,11 @@
android:id="@+id/action_accounts"
android:orderInCategory="90"
android:showAsAction="never"
- android:title="@string/action_accounts"
- />
-
+ android:title="@string/action_accounts"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
-</menu>
+</menu> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 26e5dda5..8cfff368 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -47,10 +47,7 @@
<string name="show_otr_key">OTR fingerprint</string>
<string name="no_otr_fingerprint">No OTR Fingerprint generated. Just go ahead an start an encrypted conversation</string>
<string name="start_conversation">Start Conversation</string>
- <string name="invite_contacts">Invite Contacts</string>
- <string name="invite_contacts_to_existing">Invite to existing conference</string>
- <string name="new_conference">Create new conference</string>
- <string name="new_contact">Create new contact</string>
+ <string name="invite_contact">Invite Contact</string>
<string name="contacts">Contacts</string>
<string name="search_jabber_id">Search or enter Jabber ID</string>
<string name="choose_account">Choose account</string>
@@ -272,4 +269,5 @@
<string name="bookmark_already_exists">This bookmark already exists</string>
<string name="you">You</string>
<string name="action_edit_subject">Edit conference subject</string>
+ <string name="title_activity_choose_contact">Choose contact</string>
</resources>
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 6c43a4d7..728faf4b 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -220,10 +220,13 @@ public class MessageParser extends AbstractParser implements
} else if (packet.hasChild("x")) {
Element x = packet.findChild("x");
if (x.hasChild("invite")) {
- mXmppConnectionService
+ Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account,
packet.getAttribute("from"), true);
- mXmppConnectionService.updateConversationUi();
+ if (!conversation.getMucOptions().online()) {
+ mXmppConnectionService.joinMuc(conversation);
+ mXmppConnectionService.updateConversationUi();
+ }
}
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index abcb1f97..dd4363f4 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1189,21 +1189,18 @@ public class XmppConnectionService extends Service {
}).start();
}
- public void inviteToConference(Conversation conversation,
- List<Contact> contacts) {
- for (Contact contact : contacts) {
- MessagePacket packet = new MessagePacket();
- packet.setTo(conversation.getContactJid().split("/")[0]);
- packet.setFrom(conversation.getAccount().getFullJid());
- Element x = new Element("x");
- x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
- Element invite = new Element("invite");
- invite.setAttribute("to", contact.getJid());
- x.addChild(invite);
- packet.addChild(x);
- Log.d(LOGTAG, packet.toString());
- sendMessagePacket(conversation.getAccount(),packet);
- }
+ public void inviteToConference(Conversation conversation, String contactJid) {
+ Account account = conversation.getAccount();
+ MessagePacket packet = new MessagePacket();
+ packet.setTo(conversation.getContactJid().split("/")[0]);
+ packet.setFrom(account.getFullJid());
+ Element x = new Element("x");
+ x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
+ Element invite = new Element("invite");
+ invite.setAttribute("to", contactJid);
+ x.addChild(invite);
+ packet.addChild(x);
+ sendMessagePacket(account,packet);
}
@@ -1273,6 +1270,15 @@ public class XmppConnectionService extends Service {
}
return null;
}
+
+ public Conversation findConversationByUuid(String uuid) {
+ for (Conversation conversation : getConversations()) {
+ if (conversation.getUuid().equals(uuid)) {
+ return conversation;
+ }
+ }
+ return null;
+ }
public void markRead(Conversation conversation) {
conversation.markRead();
diff --git a/src/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/eu/siacs/conversations/ui/ChooseContactActivity.java
new file mode 100644
index 00000000..4236ea70
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/ChooseContactActivity.java
@@ -0,0 +1,140 @@
+package eu.siacs.conversations.ui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Contact;
+import eu.siacs.conversations.entities.ListItem;
+import eu.siacs.conversations.ui.adapter.ListItemAdapter;
+
+public class ChooseContactActivity extends XmppActivity {
+
+ private ListView mListView;
+ private ArrayList<ListItem> contacts = new ArrayList<ListItem>();
+ private ArrayAdapter<ListItem> mContactsAdapter;
+
+ private EditText mSearchEditText;
+
+ private TextWatcher mSearchTextWatcher = new TextWatcher() {
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ filterContacts(editable.toString());
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before,
+ int count) {
+ }
+ };
+
+ private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() {
+
+ @Override
+ public boolean onMenuItemActionExpand(MenuItem item) {
+ mSearchEditText.post(new Runnable() {
+
+ @Override
+ public void run() {
+ mSearchEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showSoftInput(mSearchEditText,
+ InputMethodManager.SHOW_IMPLICIT);
+ }
+ });
+
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemActionCollapse(MenuItem item) {
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(mSearchEditText.getWindowToken(),
+ InputMethodManager.HIDE_IMPLICIT_ONLY);
+ mSearchEditText.setText("");
+ filterContacts(null);
+ return true;
+ }
+ };
+
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_choose_contact);
+ mListView = (ListView) findViewById(R.id.choose_contact_list);
+ mContactsAdapter = new ListItemAdapter(getApplicationContext(), contacts);
+ mListView.setAdapter(mContactsAdapter);
+ mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1, int position,
+ long arg3) {
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(mSearchEditText.getWindowToken(),
+ InputMethodManager.HIDE_IMPLICIT_ONLY);
+ Intent request = getIntent();
+ Intent data = new Intent();
+ data.putExtra("contact",contacts.get(position).getJid());
+ data.putExtra("account",request.getStringExtra("account"));
+ data.putExtra("conversation",request.getStringExtra("conversation"));
+ setResult(RESULT_OK, data);
+ finish();
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.choose_contact, menu);
+ MenuItem menuSearchView = (MenuItem) menu.findItem(R.id.action_search);
+ View mSearchView = menuSearchView.getActionView();
+ mSearchEditText = (EditText) mSearchView
+ .findViewById(R.id.search_field);
+ mSearchEditText.addTextChangedListener(mSearchTextWatcher);
+ menuSearchView.setOnActionExpandListener(mOnActionExpandListener);
+ return true;
+ }
+
+ @Override
+ void onBackendConnected() {
+ filterContacts(null);
+ }
+
+ protected void filterContacts(String needle) {
+ this.contacts.clear();
+ for (Account account : xmppConnectionService.getAccounts()) {
+ if (account.getStatus() != Account.STATUS_DISABLED) {
+ for (Contact contact : account.getRoster().getContacts()) {
+ if (contact.showInRoster() && contact.match(needle)) {
+ this.contacts.add(contact);
+ }
+ }
+ }
+ }
+ Collections.sort(this.contacts);
+ mContactsAdapter.notifyDataSetChanged();
+ }
+
+}
diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 65f70a6d..56903da8 100644
--- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -31,7 +31,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
-public class MucDetailsActivity extends XmppActivity {
+public class ConferenceDetailsActivity extends XmppActivity {
public static final String ACTION_VIEW_MUC = "view_muc";
private Conversation conversation;
private TextView mYourNick;
@@ -48,12 +48,7 @@ public class MucDetailsActivity extends XmppActivity {
@Override
public void onClick(View v) {
- /*
- * Intent intent = new Intent(getApplicationContext(),
- * ContactsActivity.class); intent.setAction("invite");
- * intent.putExtra("uuid",conversation.getUuid());
- * startActivity(intent);
- */
+ inviteToConversation(conversation);
}
};
@@ -155,11 +150,7 @@ public class MucDetailsActivity extends XmppActivity {
this.uuid = getIntent().getExtras().getString("uuid");
}
if (uuid != null) {
- for (Conversation mConv : xmppConnectionService.getConversations()) {
- if (mConv.getUuid().equals(uuid)) {
- this.conversation = mConv;
- }
- }
+ this.conversation = xmppConnectionService.findConversationByUuid(uuid);
if (this.conversation != null) {
populateView();
}
@@ -188,11 +179,11 @@ public class MucDetailsActivity extends XmppActivity {
public void run() {
populateView();
if (success) {
- Toast.makeText(MucDetailsActivity.this,
+ Toast.makeText(ConferenceDetailsActivity.this,
getString(R.string.your_nick_has_been_changed),
Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(MucDetailsActivity.this,
+ Toast.makeText(ConferenceDetailsActivity.this,
getString(R.string.nick_in_use),
Toast.LENGTH_SHORT).show();
}
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 3413353d..a8527feb 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -21,7 +21,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
-import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.QuickContactBadge;
import android.widget.TextView;
@@ -45,7 +44,6 @@ public class ContactDetailsActivity extends XmppActivity {
private String accountJid;
private String contactJid;
- private EditText name;
private TextView contactJidTv;
private TextView accountJidTv;
private TextView status;
@@ -63,16 +61,6 @@ public class ContactDetailsActivity extends XmppActivity {
}
};
- private DialogInterface.OnClickListener editContactNameListener = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- contact.setServerName(name.getText().toString());
- activity.xmppConnectionService.pushContactToServer(contact);
- populateView();
- }
- };
-
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
@Override
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 66db353b..ae1d218a 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -98,7 +98,7 @@ public class ConversationActivity extends XmppActivity {
swapConversationFragment();
} else {
startActivity(new Intent(getApplicationContext(),
- StartConversation.class));
+ StartConversationActivity.class));
finish();
}
}
@@ -306,23 +306,26 @@ public class ConversationActivity extends XmppActivity {
.findItem(R.id.action_muc_details);
MenuItem menuContactDetails = (MenuItem) menu
.findItem(R.id.action_contact_details);
- MenuItem menuInviteContacts = (MenuItem) menu
- .findItem(R.id.action_invite);
MenuItem menuAttach = (MenuItem) menu.findItem(R.id.action_attach_file);
MenuItem menuClearHistory = (MenuItem) menu
.findItem(R.id.action_clear_history);
+ MenuItem menuManageAccounts = (MenuItem) menu.findItem(R.id.action_accounts);
+ MenuItem menuSettings = (MenuItem) menu.findItem(R.id.action_settings);
+ MenuItem menuAdd = (MenuItem) menu.findItem(R.id.action_add);
+ MenuItem menuInviteContact = (MenuItem) menu.findItem(R.id.action_invite);
if ((spl.isOpen() && (spl.isSlideable()))) {
menuArchive.setVisible(false);
menuMucDetails.setVisible(false);
menuContactDetails.setVisible(false);
menuSecure.setVisible(false);
- menuInviteContacts.setVisible(false);
+ menuInviteContact.setVisible(false);
menuAttach.setVisible(false);
menuClearHistory.setVisible(false);
} else {
- ((MenuItem) menu.findItem(R.id.action_add)).setVisible(!spl
- .isSlideable());
+ menuAdd.setVisible(!spl.isSlideable());
+ menuSettings.setVisible(!spl.isSlideable());
+ menuManageAccounts.setVisible(!spl.isSlideable());
if (this.getSelectedConversation() != null) {
if (this.getSelectedConversation().getLatestMessage()
.getEncryption() != Message.ENCRYPTION_NONE) {
@@ -333,7 +336,7 @@ public class ConversationActivity extends XmppActivity {
menuAttach.setVisible(false);
} else {
menuMucDetails.setVisible(false);
- menuInviteContacts.setVisible(false);
+ menuInviteContact.setVisible(false);
}
}
}
@@ -458,7 +461,7 @@ public class ConversationActivity extends XmppActivity {
attachFilePopup.show();
break;
case R.id.action_add:
- startActivity(new Intent(this, StartConversation.class));
+ startActivity(new Intent(this, StartConversationActivity.class));
break;
case R.id.action_archive:
this.endConversation(getSelectedConversation());
@@ -472,17 +475,13 @@ public class ConversationActivity extends XmppActivity {
}
break;
case R.id.action_muc_details:
- Intent intent = new Intent(this, MucDetailsActivity.class);
- intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
+ Intent intent = new Intent(this, ConferenceDetailsActivity.class);
+ intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", getSelectedConversation().getUuid());
startActivity(intent);
break;
case R.id.action_invite:
- /*Intent inviteIntent = new Intent(getApplicationContext(),
- ContactsActivity.class);
- inviteIntent.setAction("invite");
- inviteIntent.putExtra("uuid", getSelectedConversation().getUuid());
- startActivity(inviteIntent);*/
+ inviteToConversation(getSelectedConversation());
break;
case R.id.action_security:
final Conversation conversation = getSelectedConversation();
@@ -699,7 +698,7 @@ public class ConversationActivity extends XmppActivity {
finish();
} else if (conversationList.size() <= 0) {
// add no history
- startActivity(new Intent(this, StartConversation.class));
+ startActivity(new Intent(this, StartConversationActivity.class));
finish();
} else {
spl.openPane();
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 47c764ac..206e40a0 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -12,9 +12,9 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
-import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
import eu.siacs.conversations.services.ImageProvider;
import eu.siacs.conversations.services.XmppConnectionService;
+import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
import android.app.AlertDialog;
@@ -118,8 +118,8 @@ public class ConversationFragment extends Fragment {
@Override
public void onClick(View v) {
- Intent intent = new Intent(getActivity(), MucDetailsActivity.class);
- intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
+ Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class);
+ intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
diff --git a/src/eu/siacs/conversations/ui/EditAccount.java b/src/eu/siacs/conversations/ui/EditAccountDialog.java
index 9a0b8d84..7c135fc1 100644
--- a/src/eu/siacs/conversations/ui/EditAccount.java
+++ b/src/eu/siacs/conversations/ui/EditAccountDialog.java
@@ -4,7 +4,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.utils.KnownHostsAdapter;
+import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.utils.Validator;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -21,7 +21,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.TextView;
-public class EditAccount extends DialogFragment {
+public class EditAccountDialog extends DialogFragment {
protected Account account;
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index c3f1e105..6fa1ec31 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -6,7 +6,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
-import eu.siacs.conversations.ui.EditAccount.EditAccountListener;
+import eu.siacs.conversations.ui.EditAccountDialog.EditAccountListener;
import eu.siacs.conversations.xmpp.OnTLSExceptionReceived;
import eu.siacs.conversations.xmpp.XmppConnection;
import android.app.Activity;
@@ -221,7 +221,7 @@ public class ManageAccountActivity extends XmppActivity {
} else if (account.getStatus() == Account.STATUS_ONLINE) {
activity.startActivity(new Intent(activity
.getApplicationContext(),
- StartConversation.class));
+ StartConversationActivity.class));
} else if (account.getStatus() != Account.STATUS_DISABLED) {
editAccount(account);
}
@@ -513,7 +513,7 @@ public class ManageAccountActivity extends XmppActivity {
@Override
public boolean onNavigateUp() {
if (xmppConnectionService.getConversations().size() == 0) {
- Intent contactsIntent = new Intent(this, StartConversation.class);
+ Intent contactsIntent = new Intent(this, StartConversationActivity.class);
contactsIntent.setFlags(
// if activity exists in stack, pop the stack and go back to it
Intent.FLAG_ACTIVITY_CLEAR_TOP |
@@ -531,7 +531,7 @@ public class ManageAccountActivity extends XmppActivity {
}
private void editAccount(Account account) {
- EditAccount dialog = new EditAccount();
+ EditAccountDialog dialog = new EditAccountDialog();
dialog.setAccount(account);
dialog.setEditAccountListener(new EditAccountListener() {
@@ -550,7 +550,7 @@ public class ManageAccountActivity extends XmppActivity {
protected void addAccount() {
final Activity activity = this;
- EditAccount dialog = new EditAccount();
+ EditAccountDialog dialog = new EditAccountDialog();
dialog.setEditAccountListener(new EditAccountListener() {
@Override
diff --git a/src/eu/siacs/conversations/ui/OnPresenceSelected.java b/src/eu/siacs/conversations/ui/OnPresenceSelected.java
deleted file mode 100644
index 1c967224..00000000
--- a/src/eu/siacs/conversations/ui/OnPresenceSelected.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package eu.siacs.conversations.ui;
-
-public interface OnPresenceSelected {
- public void onPresenceSelected();
-}
diff --git a/src/eu/siacs/conversations/ui/StartConversation.java b/src/eu/siacs/conversations/ui/StartConversationActivity.java
index f23eb420..5e22b65f 100644
--- a/src/eu/siacs/conversations/ui/StartConversation.java
+++ b/src/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -21,11 +21,9 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
@@ -34,20 +32,19 @@ import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.CheckBox;
import android.widget.EditText;
-import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
-import android.widget.TextView;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.ListItem;
-import eu.siacs.conversations.utils.KnownHostsAdapter;
+import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
+import eu.siacs.conversations.ui.adapter.ListItemAdapter;
import eu.siacs.conversations.utils.Validator;
-public class StartConversation extends XmppActivity {
+public class StartConversationActivity extends XmppActivity {
private Tab mContactsTab;
private Tab mConferencesTab;
@@ -176,7 +173,7 @@ public class StartConversation extends XmppActivity {
}
});
- mConferenceAdapter = new ListItemAdapter(conferences);
+ mConferenceAdapter = new ListItemAdapter(getApplicationContext(),conferences);
mConferenceListFragment.setListAdapter(mConferenceAdapter);
mConferenceListFragment.setContextMenu(R.menu.conference_context);
mConferenceListFragment
@@ -189,7 +186,7 @@ public class StartConversation extends XmppActivity {
}
});
- mContactsAdapter = new ListItemAdapter(contacts);
+ mContactsAdapter = new ListItemAdapter(getApplicationContext(),contacts);
mContactsListFragment.setListAdapter(mContactsAdapter);
mContactsListFragment.setContextMenu(R.menu.contact_context);
mContactsListFragment
@@ -502,33 +499,6 @@ public class StartConversation extends XmppActivity {
invalidateOptionsMenu();
}
- private class ListItemAdapter extends ArrayAdapter<ListItem> {
-
- public ListItemAdapter(List<ListItem> objects) {
- super(getApplicationContext(), 0, objects);
- }
-
- @Override
- public View getView(int position, View view, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- ListItem item = getItem(position);
- if (view == null) {
- view = (View) inflater.inflate(R.layout.contact, null);
- }
- TextView name = (TextView) view
- .findViewById(R.id.contact_display_name);
- TextView jid = (TextView) view.findViewById(R.id.contact_jid);
- ImageView picture = (ImageView) view
- .findViewById(R.id.contact_photo);
-
- jid.setText(item.getJid());
- name.setText(item.getDisplayName());
- picture.setImageBitmap(item.getImage(48, getApplicationContext()));
- return view;
- }
-
- }
-
public static class MyListFragment extends ListFragment {
private AdapterView.OnItemClickListener mOnItemClickListener;
private int mResContextMenu;
@@ -558,7 +528,7 @@ public class StartConversation extends XmppActivity {
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
- StartConversation activity = (StartConversation) getActivity();
+ StartConversationActivity activity = (StartConversationActivity) getActivity();
activity.getMenuInflater().inflate(mResContextMenu, menu);
AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
if (mResContextMenu == R.menu.conference_context) {
@@ -570,7 +540,7 @@ public class StartConversation extends XmppActivity {
@Override
public boolean onContextItemSelected(MenuItem item) {
- StartConversation activity = (StartConversation) getActivity();
+ StartConversationActivity activity = (StartConversationActivity) getActivity();
switch (item.getItemId()) {
case R.id.context_start_conversation:
activity.openConversationForContact();
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 2592bebc..2bf7cf5a 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -23,6 +23,7 @@ import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
+import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -31,6 +32,7 @@ import android.widget.EditText;
public abstract class XmppActivity extends Activity {
public static final int REQUEST_ANNOUNCE_PGP = 0x73731;
+ protected static final int REQUEST_INVITE_TO_CONVERSATION = 0x341830;
protected final static String LOGTAG = "xmppService";
@@ -41,6 +43,10 @@ public abstract class XmppActivity extends Activity {
protected interface OnValueEdited {
public void onValueEdited(String value);
}
+
+ public interface OnPresenceSelected {
+ public void onPresenceSelected();
+ }
protected ServiceConnection mConnection = new ServiceConnection() {
@@ -187,6 +193,12 @@ public abstract class XmppActivity extends Activity {
startActivity(intent);
}
+ protected void inviteToConversation(Conversation conversation) {
+ Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
+ intent.putExtra("conversation",conversation.getUuid());
+ startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
+ }
+
protected void announcePgp(Account account, final Conversation conversation) {
xmppConnectionService.getPgpEngine().generateSignature(account,
"online", new UiCallback<Account>() {
@@ -328,4 +340,18 @@ public abstract class XmppActivity extends Activity {
}
}
}
+
+ protected void onActivityResult(int requestCode, int resultCode,
+ final Intent data) {
+ 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.inviteToConference(conversation, contactJid);
+ }
+ Log.d("xmppService","inviting "+contactJid+" to "+conversation.getName(true));
+ }
+ }
}
diff --git a/src/eu/siacs/conversations/utils/KnownHostsAdapter.java b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
index a0a223dd..040e6266 100644
--- a/src/eu/siacs/conversations/utils/KnownHostsAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
@@ -1,4 +1,4 @@
-package eu.siacs.conversations.utils;
+package eu.siacs.conversations.ui.adapter;
import java.util.ArrayList;
import java.util.List;
@@ -42,7 +42,7 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
- ArrayList<String> filteredList = ((ArrayList<String>) results.values);
+ ArrayList<String> filteredList = (ArrayList<String>) results.values;
if (results != null && results.count > 0) {
clear();
for (String c : filteredList) {
diff --git a/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
new file mode 100644
index 00000000..9ef427fc
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
@@ -0,0 +1,39 @@
+package eu.siacs.conversations.ui.adapter;
+
+import java.util.List;
+
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.ListItem;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class ListItemAdapter extends ArrayAdapter<ListItem> {
+
+ public ListItemAdapter(Context context, List<ListItem> objects) {
+ super(context, 0, objects);
+ }
+
+ @Override
+ public View getView(int position, View view, ViewGroup parent) {
+ LayoutInflater inflater = (LayoutInflater) getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ ListItem item = getItem(position);
+ if (view == null) {
+ view = (View) inflater.inflate(R.layout.contact, null);
+ }
+ TextView name = (TextView) view.findViewById(R.id.contact_display_name);
+ TextView jid = (TextView) view.findViewById(R.id.contact_jid);
+ ImageView picture = (ImageView) view.findViewById(R.id.contact_photo);
+
+ jid.setText(item.getJid());
+ name.setText(item.getDisplayName());
+ picture.setImageBitmap(item.getImage(48, getContext()));
+ return view;
+ }
+
+} \ No newline at end of file
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 4e902817..1cd3403c 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -13,7 +13,6 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.ui.ConversationActivity;