Search in sources :

Example 11 with Nullable

use of androidx.annotation.Nullable in project k-9 by k9mail.

the class AttachmentInfoExtractor method getDecryptedFileProviderUri.

@Nullable
@VisibleForTesting
protected Uri getDecryptedFileProviderUri(DeferredFileBody decryptedTempFileBody, String mimeType) {
    Uri uri;
    try {
        File file = decryptedTempFileBody.getFile();
        uri = DecryptedFileProvider.getUriForProvidedFile(context, file, decryptedTempFileBody.getEncoding(), mimeType);
    } catch (IOException e) {
        Timber.e(e, "Decrypted temp file (no longer?) exists!");
        uri = null;
    }
    return uri;
}
Also used : IOException(java.io.IOException) Uri(android.net.Uri) File(java.io.File) VisibleForTesting(androidx.annotation.VisibleForTesting) Nullable(androidx.annotation.Nullable)

Example 12 with Nullable

use of androidx.annotation.Nullable in project k-9 by k9mail.

the class TextPartFinder method findFirstTextPart.

@Nullable
public Part findFirstTextPart(@NonNull Part part) {
    String mimeType = part.getMimeType();
    Body body = part.getBody();
    if (body instanceof Multipart) {
        Multipart multipart = (Multipart) body;
        if (isSameMimeType(mimeType, "multipart/alternative")) {
            return findTextPartInMultipartAlternative(multipart);
        } else {
            return findTextPartInMultipart(multipart);
        }
    } else if (isSameMimeType(mimeType, "text/plain") || isSameMimeType(mimeType, "text/html")) {
        return part;
    }
    return null;
}
Also used : Multipart(com.fsck.k9.mail.Multipart) Body(com.fsck.k9.mail.Body) Nullable(androidx.annotation.Nullable)

Example 13 with Nullable

use of androidx.annotation.Nullable in project k-9 by k9mail.

the class MessageCryptoHelper method getMultipartSignedContentPartIfAvailable.

@Nullable
private static MimeBodyPart getMultipartSignedContentPartIfAvailable(Part part) {
    MimeBodyPart replacementPart = NO_REPLACEMENT_PART;
    Body body = part.getBody();
    if (body instanceof MimeMultipart) {
        MimeMultipart multipart = ((MimeMultipart) part.getBody());
        if (multipart.getCount() >= 1) {
            replacementPart = (MimeBodyPart) multipart.getBodyPart(0);
        }
    }
    return replacementPart;
}
Also used : MimeMultipart(com.fsck.k9.mail.internet.MimeMultipart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) TextBody(com.fsck.k9.mail.internet.TextBody) Body(com.fsck.k9.mail.Body) Nullable(androidx.annotation.Nullable)

Example 14 with Nullable

use of androidx.annotation.Nullable in project k-9 by k9mail.

the class AutocryptOperations method createGossipUpdateBundle.

@Nullable
private Bundle createGossipUpdateBundle(Message message, MimeBodyPart decryptedPart) {
    List<String> gossipAcceptedAddresses = getGossipAcceptedAddresses(message);
    if (gossipAcceptedAddresses.isEmpty()) {
        return null;
    }
    List<AutocryptGossipHeader> autocryptGossipHeaders = autocryptGossipHeaderParser.getAllAutocryptGossipHeaders(decryptedPart);
    if (autocryptGossipHeaders.isEmpty()) {
        return null;
    }
    Date messageDate = message.getSentDate();
    Date internalDate = message.getInternalDate();
    Date effectiveDate = messageDate.before(internalDate) ? messageDate : internalDate;
    return createGossipUpdateBundle(gossipAcceptedAddresses, autocryptGossipHeaders, effectiveDate);
}
Also used : Date(java.util.Date) Nullable(androidx.annotation.Nullable)

Example 15 with Nullable

use of androidx.annotation.Nullable in project k-9 by k9mail.

the class AutocryptGossipHeaderParser method parseAutocryptGossipHeader.

@Nullable
@VisibleForTesting
AutocryptGossipHeader parseAutocryptGossipHeader(String headerValue) {
    Map<String, String> parameters = MimeUtility.getAllHeaderParameters(headerValue);
    String type = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_TYPE);
    if (type != null && !type.equals(AutocryptHeader.AUTOCRYPT_TYPE_1)) {
        Timber.e("autocrypt: unsupported type parameter %s", type);
        return null;
    }
    String base64KeyData = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_KEY_DATA);
    if (base64KeyData == null) {
        Timber.e("autocrypt: missing key parameter");
        return null;
    }
    ByteString byteString = ByteString.decodeBase64(base64KeyData);
    if (byteString == null) {
        Timber.e("autocrypt: error parsing base64 data");
        return null;
    }
    String addr = parameters.remove(AutocryptHeader.AUTOCRYPT_PARAM_ADDR);
    if (addr == null) {
        Timber.e("autocrypt: no to header!");
        return null;
    }
    if (hasCriticalParameters(parameters)) {
        return null;
    }
    return new AutocryptGossipHeader(addr, byteString.toByteArray());
}
Also used : ByteString(okio.ByteString) ByteString(okio.ByteString) VisibleForTesting(androidx.annotation.VisibleForTesting) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1206 View (android.view.View)207 Bundle (android.os.Bundle)118 IOException (java.io.IOException)106 ArrayList (java.util.ArrayList)104 TextView (android.widget.TextView)102 NonNull (androidx.annotation.NonNull)101 Context (android.content.Context)95 Cursor (android.database.Cursor)78 SuppressLint (android.annotation.SuppressLint)74 Uri (android.net.Uri)69 RecyclerView (androidx.recyclerview.widget.RecyclerView)64 List (java.util.List)63 ViewGroup (android.view.ViewGroup)60 Intent (android.content.Intent)58 Test (org.junit.Test)55 Recipient (org.thoughtcrime.securesms.recipients.Recipient)52 LayoutInflater (android.view.LayoutInflater)48 R (org.thoughtcrime.securesms.R)46 ImageView (android.widget.ImageView)45