Search in sources :

Example 71 with LinkedList

use of java.util.LinkedList in project Signal-Android by WhisperSystems.

the class MultiDeviceReadUpdateJob method onRun.

@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
    if (!TextSecurePreferences.isMultiDevice(context)) {
        Log.w(TAG, "Not multi device...");
        return;
    }
    List<ReadMessage> readMessages = new LinkedList<>();
    for (SerializableSyncMessageId messageId : messageIds) {
        readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
    }
    SignalServiceMessageSender messageSender = messageSenderFactory.create();
    messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages));
}
Also used : ReadMessage(org.whispersystems.signalservice.api.messages.multidevice.ReadMessage) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) LinkedList(java.util.LinkedList)

Example 72 with LinkedList

use of java.util.LinkedList in project Signal-Android by WhisperSystems.

the class PushSendJob method getAttachmentsFor.

protected List<SignalServiceAttachment> getAttachmentsFor(MasterSecret masterSecret, List<Attachment> parts) {
    List<SignalServiceAttachment> attachments = new LinkedList<>();
    for (final Attachment attachment : parts) {
        if (ContentType.isImageType(attachment.getContentType()) || ContentType.isAudioType(attachment.getContentType()) || ContentType.isVideoType(attachment.getContentType())) {
            try {
                if (attachment.getDataUri() == null || attachment.getSize() == 0)
                    throw new IOException("Assertion failed, outgoing attachment has no data!");
                InputStream is = PartAuthority.getAttachmentStream(context, masterSecret, attachment.getDataUri());
                attachments.add(SignalServiceAttachment.newStreamBuilder().withStream(is).withContentType(attachment.getContentType()).withLength(attachment.getSize()).withListener(new ProgressListener() {

                    @Override
                    public void onAttachmentProgress(long total, long progress) {
                        EventBus.getDefault().postSticky(new PartProgressEvent(attachment, total, progress));
                    }
                }).build());
            } catch (IOException ioe) {
                Log.w(TAG, "Couldn't open attachment", ioe);
            }
        }
    }
    return attachments;
}
Also used : SignalServiceAttachment(org.whispersystems.signalservice.api.messages.SignalServiceAttachment) ProgressListener(org.whispersystems.signalservice.api.messages.SignalServiceAttachment.ProgressListener) InputStream(java.io.InputStream) SignalServiceAttachment(org.whispersystems.signalservice.api.messages.SignalServiceAttachment) Attachment(org.thoughtcrime.securesms.attachments.Attachment) PartProgressEvent(org.thoughtcrime.securesms.events.PartProgressEvent) IOException(java.io.IOException) LinkedList(java.util.LinkedList)

Example 73 with LinkedList

use of java.util.LinkedList in project Signal-Android by WhisperSystems.

the class GiphyFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle bundle) {
    super.onActivityCreated(bundle);
    this.giphyAdapter = new GiphyAdapter(getActivity(), new LinkedList<GiphyImage>());
    this.giphyAdapter.setListener(this);
    this.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    this.recyclerView.setItemAnimator(new DefaultItemAnimator());
    this.recyclerView.setAdapter(giphyAdapter);
    this.recyclerView.addOnScrollListener(new GiphyScrollListener());
    getLoaderManager().initLoader(0, null, this);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinkedList(java.util.LinkedList) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 74 with LinkedList

use of java.util.LinkedList in project Signal-Android by WhisperSystems.

the class ThreadDatabase method setRead.

public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
    ContentValues contentValues = new ContentValues(1);
    contentValues.put(READ, 1);
    if (lastSeen) {
        contentValues.put(LAST_SEEN, System.currentTimeMillis());
    }
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] { threadId + "" });
    final List<MarkedMessageInfo> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
    final List<MarkedMessageInfo> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
    notifyConversationListListeners();
    return new LinkedList<MarkedMessageInfo>() {

        {
            addAll(smsRecords);
            addAll(mmsRecords);
        }
    };
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo) LinkedList(java.util.LinkedList)

Example 75 with LinkedList

use of java.util.LinkedList in project Signal-Android by WhisperSystems.

the class AndroidAutoReplyReceiver method onReceive.

@Override
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret) {
    if (!REPLY_ACTION.equals(intent.getAction()))
        return;
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null)
        return;
    final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA);
    final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1);
    final CharSequence responseText = getMessageText(intent);
    final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false);
    if (responseText != null) {
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                long replyThreadId;
                Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds);
                int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
                long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
                if (recipients.isGroupRecipient()) {
                    Log.i("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message");
                    OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
                    replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
                } else {
                    Log.i("AndroidAutoReplyReceiver", "Sending regular message ");
                    OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString(), expiresIn, subscriptionId);
                    replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
                }
                List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId, true);
                MessageNotifier.updateNotification(context, masterSecret);
                MarkReadReceiver.process(context, messageIds);
                return null;
            }
        }.execute();
    }
}
Also used : OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) Recipients(org.thoughtcrime.securesms.recipients.Recipients) Optional(org.whispersystems.libsignal.util.guava.Optional) Bundle(android.os.Bundle) OutgoingMediaMessage(org.thoughtcrime.securesms.mms.OutgoingMediaMessage) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)10512 Test (org.junit.Test)1487 List (java.util.List)1463 HashMap (java.util.HashMap)1371 ArrayList (java.util.ArrayList)1313 Map (java.util.Map)871 IOException (java.io.IOException)800 File (java.io.File)695 HashSet (java.util.HashSet)605 LinkedHashMap (java.util.LinkedHashMap)382 GenericValue (org.apache.ofbiz.entity.GenericValue)296 Iterator (java.util.Iterator)277 Set (java.util.Set)255 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)232 Date (java.util.Date)222 Collection (java.util.Collection)201 Delegator (org.apache.ofbiz.entity.Delegator)162 Locale (java.util.Locale)158 URL (java.net.URL)154 BufferedReader (java.io.BufferedReader)146