aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-17 00:03:37 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-17 00:03:37 +0200
commit38a9242955704232039272fd8b6011d47622495d (patch)
tree16665564834041b3c1218531d548449e64285f8d /src/eu/siacs/conversations
parent670dead69502884d178ab60ec10e8e0e7b7a7915 (diff)
brought muc invites back. + couple of bug fixes + refactoring
Diffstat (limited to 'src/eu/siacs/conversations')
-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
15 files changed, 270 insertions, 114 deletions
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 6c43a4d7d..728faf4b7 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 abcb1f975..dd4363f44 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 000000000..4236ea703
--- /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 65f70a6dc..56903da89 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 3413353d3..a8527febd 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 66db353be..ae1d218ae 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 47c764ac7..206e40a09 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 9a0b8d842..7c135fc16 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 c3f1e105d..6fa1ec319 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 1c967224a..000000000
--- 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 f23eb4202..5e22b65f1 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 2592bebca..2bf7cf5a1 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 a0a223dda..040e62667 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 000000000..9ef427fc5
--- /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 4e902817d..1cd3403c6 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;