use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.
the class ShareViaAccountActivity method onBackendConnected.
@Override
void onBackendConnected() {
final int numAccounts = xmppConnectionService.getAccounts().size();
if (numAccounts == 1) {
final String body = getIntent().getStringExtra(EXTRA_BODY);
final Account account = xmppConnectionService.getAccounts().get(0);
try {
final Jid contact = Jid.of(getIntent().getStringExtra(EXTRA_CONTACT));
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, contact, false, false);
switchToConversation(conversation, body);
} catch (IllegalArgumentException e) {
// ignore error
}
finish();
} else {
refreshUiReal();
}
}
use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.
the class XmppConnectionService method removeBlockedConversations.
public boolean removeBlockedConversations(final Account account, final Jid blockedJid) {
boolean removed = false;
synchronized (this.conversations) {
boolean domainJid = blockedJid.getLocal() == null;
for (Conversation conversation : this.conversations) {
boolean jidMatches = (domainJid && blockedJid.getDomain().equals(conversation.getJid().getDomain())) || blockedJid.equals(conversation.getJid().asBareJid());
if (conversation.getAccount() == account && conversation.getMode() == Conversation.MODE_SINGLE && jidMatches) {
this.conversations.remove(conversation);
markRead(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED);
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conversation " + conversation.getJid().asBareJid() + " because jid was blocked");
updateConversation(conversation);
removed = true;
}
}
}
return removed;
}
use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.
the class MessageSearchTask method findOrGenerateStub.
private Conversational findOrGenerateStub(String conversationUuid, String accountUuid, String contactJid, int mode) throws Exception {
Conversation conversation = xmppConnectionService.findConversationByUuid(conversationUuid);
if (conversation != null) {
return conversation;
}
Account account = xmppConnectionService.findAccountByUuid(accountUuid);
Jid jid = Jid.of(contactJid);
if (account != null && jid != null) {
return new StubConversation(account, conversationUuid, jid.asBareJid(), mode);
}
throw new Exception("Unable to generate stub for " + contactJid);
}
use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.
the class NotificationService method buildMultipleConversation.
private Builder buildMultipleConversation(final boolean notify, final boolean quietHours) {
final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService, quietHours ? "quiet_hours" : (notify ? "messages" : "silent_messages"));
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
style.setBigContentTitle(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_unread_conversations, notifications.size(), notifications.size()));
final StringBuilder names = new StringBuilder();
Conversation conversation = null;
for (final ArrayList<Message> messages : notifications.values()) {
if (messages.size() > 0) {
conversation = (Conversation) messages.get(0).getConversation();
final String name = conversation.getName().toString();
SpannableString styledString;
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
style.addLine(styledString);
} else {
styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
style.addLine(styledString);
}
names.append(name);
names.append(", ");
}
}
if (names.length() >= 2) {
names.delete(names.length() - 2, names.length());
}
final String contentTitle = mXmppConnectionService.getResources().getQuantityString(R.plurals.x_unread_conversations, notifications.size(), notifications.size());
mBuilder.setContentTitle(contentTitle);
mBuilder.setTicker(contentTitle);
mBuilder.setContentText(names.toString());
mBuilder.setStyle(style);
if (conversation != null) {
mBuilder.setContentIntent(createContentIntent(conversation));
}
mBuilder.setGroupSummary(true);
mBuilder.setGroup(CONVERSATIONS_GROUP);
mBuilder.setDeleteIntent(createDeleteIntent(null));
mBuilder.setSmallIcon(R.drawable.ic_notification);
return mBuilder;
}
use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.
the class NotificationService method wasHighlightedOrPrivate.
private boolean wasHighlightedOrPrivate(final Message message) {
if (message.getConversation() instanceof Conversation) {
Conversation conversation = (Conversation) message.getConversation();
final String nick = conversation.getMucOptions().getActualNick();
final Pattern highlight = generateNickHighlightPattern(nick);
if (message.getBody() == null || nick == null) {
return false;
}
final Matcher m = highlight.matcher(message.getBody());
return (m.find() || message.isPrivateMessage());
} else {
return false;
}
}
Aggregations