use of eu.siacs.conversations.entities.Conversational in project Conversations by siacs.
the class NotificationService method pushNow.
private void pushNow(final Message message) {
mXmppConnectionService.updateUnreadCountBadge();
if (!notify(message)) {
Log.d(Config.LOGTAG, message.getConversation().getAccount().getJid().asBareJid() + ": suppressing notification because turned off");
return;
}
final boolean isScreenLocked = mXmppConnectionService.isScreenLocked();
if (this.mIsInForeground && !isScreenLocked && this.mOpenConversation == message.getConversation()) {
Log.d(Config.LOGTAG, message.getConversation().getAccount().getJid().asBareJid() + ": suppressing notification because conversation is open");
return;
}
synchronized (notifications) {
pushToStack(message);
final Conversational conversation = message.getConversation();
final Account account = conversation.getAccount();
final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || isScreenLocked) && !account.inGracePeriod() && !this.inMiniGracePeriod(account);
updateNotification(doNotify, Collections.singletonList(conversation.getUuid()));
}
}
use of eu.siacs.conversations.entities.Conversational in project Conversations by siacs.
the class AvatarService method get.
public Bitmap get(Message message, int size, boolean cachedOnly) {
final Conversational conversation = message.getConversation();
if (message.getType() == Message.TYPE_STATUS && message.getCounterparts() != null && message.getCounterparts().size() > 1) {
return get(message.getCounterparts(), size, cachedOnly);
} else if (message.getStatus() == Message.STATUS_RECEIVED) {
Contact c = message.getContact();
if (c != null && (c.getProfilePhoto() != null || c.getAvatarFilename() != null)) {
return get(c, size, cachedOnly);
} else if (conversation instanceof Conversation && message.getConversation().getMode() == Conversation.MODE_MULTI) {
final Jid trueCounterpart = message.getTrueCounterpart();
final MucOptions mucOptions = ((Conversation) conversation).getMucOptions();
MucOptions.User user;
if (trueCounterpart != null) {
user = mucOptions.findOrCreateUserByRealJid(trueCounterpart, message.getCounterpart());
} else {
user = mucOptions.findUserByFullJid(message.getCounterpart());
}
if (user != null) {
return getImpl(user, size, cachedOnly);
}
} else if (c != null) {
return get(c, size, cachedOnly);
}
Jid tcp = message.getTrueCounterpart();
String seed = tcp != null ? tcp.asBareJid().toString() : null;
return get(UIHelper.getMessageDisplayName(message), seed, size, cachedOnly);
} else {
return get(conversation.getAccount(), size, cachedOnly);
}
}
use of eu.siacs.conversations.entities.Conversational in project Conversations by siacs.
the class GeoHelper method createGeoIntentsFromMessage.
public static ArrayList<Intent> createGeoIntentsFromMessage(Context context, Message message) {
final ArrayList<Intent> intents = new ArrayList<>();
final GeoPoint geoPoint;
try {
geoPoint = parseGeoPoint(message.getBody());
} catch (IllegalArgumentException e) {
return intents;
}
final Conversational conversation = message.getConversation();
final String label = getLabel(context, message);
if (isLocationPluginInstalledAndDesired(context)) {
Intent locationPluginIntent = new Intent(SHOW_LOCATION_PACKAGE_NAME);
locationPluginIntent.putExtra("latitude", geoPoint.getLatitude());
locationPluginIntent.putExtra("longitude", geoPoint.getLongitude());
if (message.getStatus() != Message.STATUS_RECEIVED) {
locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString());
locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocal());
} else {
Contact contact = message.getContact();
if (contact != null) {
locationPluginIntent.putExtra("name", contact.getDisplayName());
locationPluginIntent.putExtra("jid", contact.getJid().toString());
} else {
locationPluginIntent.putExtra("name", UIHelper.getDisplayedMucCounterpart(message.getCounterpart()));
}
}
intents.add(locationPluginIntent);
} else {
Intent intent = new Intent(context, ShowLocationActivity.class);
intent.setAction(SHOW_LOCATION_PACKAGE_NAME);
intent.putExtra("latitude", geoPoint.getLatitude());
intent.putExtra("longitude", geoPoint.getLongitude());
intents.add(intent);
}
intents.add(geoIntent(geoPoint, label));
Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:" + geoPoint.getLatitude() + "," + geoPoint.getLongitude() + label));
intents.add(httpIntent);
return intents;
}
Aggregations