Search in sources :

Example 56 with Conversation

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

the class ConversationsActivity method handlePositiveActivityResult.

private void handlePositiveActivityResult(int requestCode, final Intent data) {
    Conversation conversation = ConversationFragment.getConversationReliable(this);
    if (conversation == null) {
        Log.d(Config.LOGTAG, "conversation not found");
        return;
    }
    switch(requestCode) {
        case REQUEST_DECRYPT_PGP:
            conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
            break;
        case REQUEST_CHOOSE_PGP_ID:
            long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
            if (id != 0) {
                conversation.getAccount().setPgpSignId(id);
                announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
            } else {
                choosePgpSignId(conversation.getAccount());
            }
            break;
        case REQUEST_ANNOUNCE_PGP:
            announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
            break;
    }
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation)

Example 57 with Conversation

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

the class ConversationsActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (MenuDoubleTabUtil.shouldIgnoreTap()) {
        return false;
    }
    switch(item.getItemId()) {
        case android.R.id.home:
            FragmentManager fm = getFragmentManager();
            if (fm.getBackStackEntryCount() > 0) {
                try {
                    fm.popBackStack();
                } catch (IllegalStateException e) {
                    Log.w(Config.LOGTAG, "Unable to pop back stack after pressing home button");
                }
                return true;
            }
            break;
        case R.id.action_scan_qr_code:
            UriHandlerActivity.scan(this);
            return true;
        case R.id.action_search_all_conversations:
            startActivity(new Intent(this, SearchActivity.class));
            return true;
        case R.id.action_search_this_conversation:
            final Conversation conversation = ConversationFragment.getConversation(this);
            if (conversation == null) {
                return true;
            }
            final Intent intent = new Intent(this, SearchActivity.class);
            intent.putExtra(SearchActivity.EXTRA_CONVERSATION_UUID, conversation.getUuid());
            startActivity(intent);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : FragmentManager(android.app.FragmentManager) Intent(android.content.Intent) Conversation(eu.siacs.conversations.entities.Conversation)

Example 58 with Conversation

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

the class NotificationService method buildSingleConversations.

private Builder buildSingleConversations(final ArrayList<Message> messages) {
    final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
    if (messages.size() >= 1) {
        final Conversation conversation = messages.get(0).getConversation();
        mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService().get(conversation, getPixel(64)));
        mBuilder.setContentTitle(conversation.getName());
        if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
            int count = messages.size();
            mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
        } else {
            Message message;
            if ((message = getImage(messages)) != null) {
                modifyForImage(mBuilder, message, messages);
            } else {
                modifyForTextOnly(mBuilder, messages);
            }
            RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build();
            NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Reply", createReplyIntent(conversation, false)).addRemoteInput(remoteInput).build();
            NotificationCompat.Action wearReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Reply", createReplyIntent(conversation, true)).addRemoteInput(remoteInput).build();
            mBuilder.extend(new NotificationCompat.WearableExtender().addAction(wearReplyAction));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mBuilder.addAction(replyAction);
            }
            if ((message = getFirstDownloadableMessage(messages)) != null) {
                mBuilder.addAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download, mXmppConnectionService.getResources().getString(R.string.download_x_file, UIHelper.getFileDescriptionString(mXmppConnectionService, message)), createDownloadIntent(message));
            }
            if ((message = getFirstLocationMessage(messages)) != null) {
                mBuilder.addAction(R.drawable.ic_room_white_24dp, mXmppConnectionService.getString(R.string.show_location), createShowLocationIntent(message));
            }
        }
        if (conversation.getMode() == Conversation.MODE_SINGLE) {
            Contact contact = conversation.getContact();
            Uri systemAccount = contact.getSystemAccount();
            if (systemAccount != null) {
                mBuilder.addPerson(systemAccount.toString());
            }
        }
        mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
        mBuilder.setSmallIcon(R.drawable.ic_notification);
        mBuilder.setDeleteIntent(createDeleteIntent(conversation));
        mBuilder.setContentIntent(createContentIntent(conversation));
    }
    return mBuilder;
}
Also used : RemoteInput(android.support.v4.app.RemoteInput) Message(eu.siacs.conversations.entities.Message) Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) Conversation(eu.siacs.conversations.entities.Conversation) Uri(android.net.Uri) Contact(eu.siacs.conversations.entities.Contact)

Example 59 with Conversation

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

the class ConferenceDetailsActivity method startConversation.

protected void startConversation(User user) {
    if (user.getRealJid() != null) {
        Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(), user.getRealJid().toBareJid(), false);
        switchToConversation(conversation);
    }
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation)

Example 60 with Conversation

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

the class ConversationActivity method selectPresenceToAttachFile.

protected void selectPresenceToAttachFile(final int attachmentChoice, final int encryption) {
    final Conversation conversation = getSelectedConversation();
    final Account account = conversation.getAccount();
    final OnPresenceSelected callback = new OnPresenceSelected() {

        @Override
        public void onPresenceSelected() {
            Intent intent = new Intent();
            boolean chooser = false;
            String fallbackPackageId = null;
            switch(attachmentChoice) {
                case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                    }
                    intent.setType("image/*");
                    chooser = true;
                    break;
                case ATTACHMENT_CHOICE_TAKE_PHOTO:
                    Uri uri = xmppConnectionService.getFileBackend().getTakePhotoUri();
                    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                    mPendingImageUris.clear();
                    mPendingImageUris.add(uri);
                    break;
                case ATTACHMENT_CHOICE_CHOOSE_FILE:
                    chooser = true;
                    intent.setType("*/*");
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    break;
                case ATTACHMENT_CHOICE_RECORD_VOICE:
                    intent.setAction(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
                    fallbackPackageId = "eu.siacs.conversations.voicerecorder";
                    break;
                case ATTACHMENT_CHOICE_LOCATION:
                    intent.setAction("eu.siacs.conversations.location.request");
                    fallbackPackageId = "eu.siacs.conversations.sharelocation";
                    break;
            }
            if (intent.resolveActivity(getPackageManager()) != null) {
                if (chooser) {
                    startActivityForResult(Intent.createChooser(intent, getString(R.string.perform_action_with)), attachmentChoice);
                } else {
                    startActivityForResult(intent, attachmentChoice);
                }
            } else if (fallbackPackageId != null) {
                startActivity(getInstallApkIntent(fallbackPackageId));
            }
        }
    };
    if ((account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
        conversation.setNextCounterpart(null);
        callback.onPresenceSelected();
    } else {
        selectPresence(conversation, callback);
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) Conversation(eu.siacs.conversations.entities.Conversation) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri)

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