Search in sources :

Example 1 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ExportLogsService method export.

private void export() {
    List<Conversation> conversations = mDatabaseBackend.getConversations(Conversation.STATUS_AVAILABLE);
    conversations.addAll(mDatabaseBackend.getConversations(Conversation.STATUS_ARCHIVED));
    NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
    mBuilder.setContentTitle(getString(R.string.notification_export_logs_title)).setSmallIcon(R.drawable.ic_import_export_white_24dp).setProgress(conversations.size(), 0, false);
    startForeground(NOTIFICATION_ID, mBuilder.build());
    int progress = 0;
    for (Conversation conversation : conversations) {
        writeToFile(conversation);
        progress++;
        mBuilder.setProgress(conversations.size(), progress, false);
        mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Conversation(eu.siacs.conversations.entities.Conversation)

Example 2 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class NotificationService method buildMultipleConversation.

private Builder buildMultipleConversation() {
    final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
    final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(notifications.size() + " " + mXmppConnectionService.getString(R.string.unread_conversations));
    final StringBuilder names = new StringBuilder();
    Conversation conversation = null;
    for (final ArrayList<Message> messages : notifications.values()) {
        if (messages.size() > 0) {
            conversation = messages.get(0).getConversation();
            final String name = conversation.getName();
            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());
    }
    mBuilder.setContentTitle(notifications.size() + " " + mXmppConnectionService.getString(R.string.unread_conversations));
    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;
}
Also used : SpannableString(android.text.SpannableString) Message(eu.siacs.conversations.entities.Message) Builder(android.support.v4.app.NotificationCompat.Builder) StyleSpan(android.text.style.StyleSpan) NotificationCompat(android.support.v4.app.NotificationCompat) Conversation(eu.siacs.conversations.entities.Conversation) SpannableString(android.text.SpannableString)

Example 3 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class StartConversationActivity method switchToConversation.

protected void switchToConversation(Contact contact, String body) {
    Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false);
    switchToConversation(conversation, body, false);
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation)

Example 4 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationActivity method updateActionBarTitle.

private void updateActionBarTitle(boolean titleShouldBeName) {
    final ActionBar ab = getActionBar();
    final Conversation conversation = getSelectedConversation();
    if (ab != null) {
        if (titleShouldBeName && conversation != null) {
            if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != ActionBar.DISPLAY_HOME_AS_UP) {
                ab.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
            }
            if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) {
                ab.setTitle(conversation.getName());
            } else {
                ab.setTitle(conversation.getJid().toBareJid().toString());
            }
        } else {
            if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) == ActionBar.DISPLAY_HOME_AS_UP) {
                ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
            }
            ab.setTitle(R.string.app_name);
        }
    }
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation) ActionBar(android.app.ActionBar)

Example 5 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationActivity method onSaveInstanceState.

@Override
public void onSaveInstanceState(final Bundle savedInstanceState) {
    Conversation conversation = getSelectedConversation();
    if (conversation != null) {
        savedInstanceState.putString(STATE_OPEN_CONVERSATION, conversation.getUuid());
        Pair<Integer, Integer> scrollPosition = mConversationFragment.getScrollPosition();
        if (scrollPosition != null) {
            savedInstanceState.putInt(STATE_FIRST_VISIBLE, scrollPosition.first);
            savedInstanceState.putInt(STATE_OFFSET_FROM_TOP, scrollPosition.second);
        }
    } else {
        savedInstanceState.remove(STATE_OPEN_CONVERSATION);
    }
    savedInstanceState.putBoolean(STATE_PANEL_OPEN, isConversationsOverviewVisable());
    if (this.mPendingImageUris.size() >= 1) {
        Log.d(Config.LOGTAG, "ConversationsActivity.onSaveInstanceState() - saving pending image uri");
        savedInstanceState.putString(STATE_PENDING_URI, this.mPendingImageUris.get(0).toString());
    } else {
        savedInstanceState.remove(STATE_PENDING_URI);
    }
    super.onSaveInstanceState(savedInstanceState);
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation)

Aggregations

Conversation (eu.siacs.conversations.entities.Conversation)110 Account (eu.siacs.conversations.entities.Account)27 Message (eu.siacs.conversations.entities.Message)24 Jid (eu.siacs.conversations.xmpp.Jid)22 Contact (eu.siacs.conversations.entities.Contact)17 MucOptions (eu.siacs.conversations.entities.MucOptions)10 Intent (android.content.Intent)9 Element (eu.siacs.conversations.xml.Element)9 PendingIntent (android.app.PendingIntent)8 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)8 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)8 Uri (android.net.Uri)7 Conversational (eu.siacs.conversations.entities.Conversational)7 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)7 SuppressLint (android.annotation.SuppressLint)6 SpannableString (android.text.SpannableString)6 XmppConnection (eu.siacs.conversations.xmpp.XmppConnection)6 Jid (eu.siacs.conversations.xmpp.jid.Jid)6 ArrayList (java.util.ArrayList)6 Fragment (android.app.Fragment)4