Search in sources :

Example 6 with Conversational

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()));
    }
}
Also used : Conversational(eu.siacs.conversations.entities.Conversational) Account(eu.siacs.conversations.entities.Account)

Example 7 with Conversational

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);
    }
}
Also used : Conversational(eu.siacs.conversations.entities.Conversational) MucOptions(eu.siacs.conversations.entities.MucOptions) Jid(eu.siacs.conversations.xmpp.Jid) Conversation(eu.siacs.conversations.entities.Conversation) Contact(eu.siacs.conversations.entities.Contact)

Example 8 with Conversational

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;
}
Also used : GeoPoint(org.osmdroid.util.GeoPoint) Conversational(eu.siacs.conversations.entities.Conversational) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Contact(eu.siacs.conversations.entities.Contact)

Aggregations

Conversational (eu.siacs.conversations.entities.Conversational)8 Conversation (eu.siacs.conversations.entities.Conversation)5 Account (eu.siacs.conversations.entities.Account)3 Contact (eu.siacs.conversations.entities.Contact)3 Message (eu.siacs.conversations.entities.Message)2 Jid (eu.siacs.conversations.xmpp.Jid)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 IndividualMessage (eu.siacs.conversations.entities.IndividualMessage)1 MucOptions (eu.siacs.conversations.entities.MucOptions)1 RtpSessionStatus (eu.siacs.conversations.entities.RtpSessionStatus)1 Transferable (eu.siacs.conversations.entities.Transferable)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 GeoPoint (org.osmdroid.util.GeoPoint)1