use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.
the class ChooseContactActivity method filterContacts.
protected void filterContacts(final String needle) {
getListItems().clear();
for (final Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) {
for (final Contact contact : account.getRoster().getContacts()) {
if (contact.showInRoster() && !filterContacts.contains(contact.getJid().toBareJid().toString()) && contact.match(this, needle)) {
getListItems().add(contact);
}
}
}
}
Collections.sort(getListItems());
getListItemAdapter().notifyDataSetChanged();
}
use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.
the class XmppActivity method showPresenceSelectionDialog.
private void showPresenceSelectionDialog(Presences presences, final Conversation conversation, final OnPresenceSelected listener) {
final Contact contact = conversation.getContact();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.choose_presence));
final String[] resourceArray = presences.toResourceArray();
Pair<Map<String, String>, Map<String, String>> typeAndName = presences.toTypeAndNameMap();
final Map<String, String> resourceTypeMap = typeAndName.first;
final Map<String, String> resourceNameMap = typeAndName.second;
final String[] readableIdentities = new String[resourceArray.length];
final AtomicInteger selectedResource = new AtomicInteger(0);
for (int i = 0; i < resourceArray.length; ++i) {
String resource = resourceArray[i];
if (resource.equals(contact.getLastResource())) {
selectedResource.set(i);
}
String type = resourceTypeMap.get(resource);
String name = resourceNameMap.get(resource);
if (type != null) {
if (Collections.frequency(resourceTypeMap.values(), type) == 1) {
readableIdentities[i] = UIHelper.tranlasteType(this, type);
} else if (name != null) {
if (Collections.frequency(resourceNameMap.values(), name) == 1 || CryptoHelper.UUID_PATTERN.matcher(resource).matches()) {
readableIdentities[i] = UIHelper.tranlasteType(this, type) + " (" + name + ")";
} else {
readableIdentities[i] = UIHelper.tranlasteType(this, type) + " (" + name + " / " + resource + ")";
}
} else {
readableIdentities[i] = UIHelper.tranlasteType(this, type) + " (" + resource + ")";
}
} else {
readableIdentities[i] = resource;
}
}
builder.setSingleChoiceItems(readableIdentities, selectedResource.get(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selectedResource.set(which);
}
});
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
Jid next = Jid.fromParts(contact.getJid().getLocalpart(), contact.getJid().getDomainpart(), resourceArray[selectedResource.get()]);
conversation.setNextCounterpart(next);
} catch (InvalidJidException e) {
conversation.setNextCounterpart(null);
}
listener.onPresenceSelected();
}
});
builder.create().show();
}
use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.
the class StartConversationActivity method openDetailsForContact.
protected void openDetailsForContact() {
int position = contact_context_id;
Contact contact = (Contact) contacts.get(position);
switchToContactDetails(contact);
}
use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.
the class StartConversationActivity method deleteContact.
protected void deleteContact() {
final int position = contact_context_id;
final Contact contact = (Contact) contacts.get(position);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setNegativeButton(R.string.cancel, null);
builder.setTitle(R.string.action_delete_contact);
builder.setMessage(getString(R.string.remove_contact_text, contact.getJid()));
builder.setPositiveButton(R.string.delete, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
xmppConnectionService.deleteContactOnServer(contact);
filter(mSearchEditText.getText().toString());
}
});
builder.create().show();
}
use of eu.siacs.conversations.entities.Contact in project Conversations by siacs.
the class StartConversationActivity method filterContacts.
protected void filterContacts(String needle) {
this.contacts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) {
for (Contact contact : account.getRoster().getContacts()) {
Presence.Status s = contact.getShownStatus();
if (contact.showInRoster() && contact.match(this, needle) && (!this.mHideOfflineContacts || (needle != null && !needle.trim().isEmpty()) || s.compareTo(Presence.Status.OFFLINE) < 0)) {
this.contacts.add(contact);
}
}
}
}
Collections.sort(this.contacts);
mContactsAdapter.notifyDataSetChanged();
}
Aggregations