target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void calcUnknownContactLetter_withSurrogatePair() { Address address = new Address("\uD800\uDFB5 <[email protected]>"); String result = ContactPictureLoader.calcUnknownContactLetter(address); assertEquals("\uD800\uDFB5", result); }
@VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
@Test public void calcUnknownContactLetter_ignoresSpace() { Address address = new Address(" abcd <[email protected]>"); String result = ContactPictureLoader.calcUnknownContactLetter(address); assertEquals("A", result); }
@VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
@Test public void calcUnknownContactLetter_ignoresUsePunctuation() { Address address = new Address("-a <[email protected]>"); String result = ContactPictureLoader.calcUnknownContactLetter(address); assertEquals("A", result); }
@VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
@Test public void calcUnknownContactLetter_ignoresMatchEmoji() { Address address = new Address("\uD83D\uDE00 <[email protected]>"); String result = ContactPictureLoader.calcUnknownContactLetter(address); assertEquals("?", result); }
@VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { letter = m.group(0).toUpperCase(Locale.US); } return (TextUtils.isEmpty(letter)) ? FALLBACK_CONTACT_LETTER : letter; } ContactPictureLoader(Context context, int defaultBackgroundColor); void loadContactPicture(final Address address, final ImageView imageView); void loadContactPicture(Recipient recipient, ImageView imageView); }
@Test public void findEncrypted__withMissingEncryptedBody__shouldReturnEmpty() throws Exception { Message message = messageFromBody( multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted") ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertTrue(encryptedParts.isEmpty()); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void testInitFromReplyToMessage() throws Exception { Message message = mock(Message.class); when(replyToParser.getRecipientsToReplyTo(message, account)).thenReturn(TO_ADDRESSES); recipientPresenter.initFromReplyToMessage(message, ReplyMode.NORMAL); runBackgroundTask(); verify(recipientMvpView).addRecipients(eq(RecipientType.TO), any(Recipient[].class)); }
public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void testInitFromReplyToAllMessage() throws Exception { Message message = mock(Message.class); when(replyToParser.getRecipientsToReplyTo(message, account)).thenReturn(TO_ADDRESSES); ReplyToAddresses replyToAddresses = new ReplyToAddresses(ALL_TO_ADDRESSES, ALL_CC_ADDRESSES); when(replyToParser.getRecipientsToReplyAllTo(message, account)).thenReturn(replyToAddresses); recipientPresenter.initFromReplyToMessage(message, ReplyMode.ALL); runBackgroundTask(); runBackgroundTask(); verify(recipientMvpView).addRecipients(eq(RecipientType.TO), any(Recipient.class)); verify(recipientMvpView).addRecipients(eq(RecipientType.CC), any(Recipient.class)); }
public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void initFromReplyToMessage_shouldCallComposePgpInlineDecider() throws Exception { Message message = mock(Message.class); when(replyToParser.getRecipientsToReplyTo(message, account)).thenReturn(TO_ADDRESSES); recipientPresenter.initFromReplyToMessage(message, ReplyMode.NORMAL); verify(composePgpInlineDecider).shouldReplyInline(message); }
public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { public void initFromReplyToMessage(Message message, ReplyMode replyMode) { ReplyToAddresses replyToAddresses; switch (replyMode) { case ALL: replyToAddresses = replyToParser.getRecipientsToReplyAllTo(message, account); break; case LIST: replyToAddresses = replyToParser.getRecipientsToReplyListTo(message, account); break; case NORMAL: replyToAddresses = replyToParser.getRecipientsToReplyTo(message, account); break; default: throw new IllegalArgumentException("Unexpected reply mode: " + replyMode); } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } boolean shouldEnablePgpByDefault = composePgpEnableByDefaultDecider.shouldEncryptByDefault(message); currentCryptoMode = shouldEnablePgpByDefault ? CryptoMode.CHOICE_ENABLED : CryptoMode.NO_CHOICE; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void getCurrentCryptoStatus_withoutCryptoProvider() throws Exception { ComposeCryptoStatus status = recipientPresenter.getCurrentCachedCryptoStatus(); assertEquals(CryptoStatusDisplayType.UNCONFIGURED, status.getCryptoStatusDisplayType()); assertEquals(CryptoSpecialModeDisplayType.NONE, status.getCryptoSpecialModeDisplayType()); assertNull(status.getAttachErrorStateOrNull()); assertFalse(status.isProviderStateOk()); assertFalse(status.shouldUsePgpMessageBuilder()); }
@Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; }
RecipientPresenter implements PermissionPingCallback { @Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; } }
RecipientPresenter implements PermissionPingCallback { @Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { @Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { @Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onToTokenAdded_notifiesListenerOfRecipientChange() { recipientPresenter.onToTokenAdded(); verify(listener).onRecipientsChanged(); }
void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onToTokenChanged_notifiesListenerOfRecipientChange() { recipientPresenter.onToTokenChanged(); verify(listener).onRecipientsChanged(); }
void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onToTokenRemoved_notifiesListenerOfRecipientChange() { recipientPresenter.onToTokenRemoved(); verify(listener).onRecipientsChanged(); }
void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onCcTokenAdded_notifiesListenerOfRecipientChange() { recipientPresenter.onCcTokenAdded(); verify(listener).onRecipientsChanged(); }
void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onCcTokenChanged_notifiesListenerOfRecipientChange() { recipientPresenter.onCcTokenChanged(); verify(listener).onRecipientsChanged(); }
void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onCcTokenRemoved_notifiesListenerOfRecipientChange() { recipientPresenter.onCcTokenRemoved(); verify(listener).onRecipientsChanged(); }
void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void findEncrypted__withBadStructure__shouldReturnEmpty() throws Exception { Message message = messageFromBody( multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/octet-stream") ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertTrue(encryptedParts.isEmpty()); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void onBccTokenAdded_notifiesListenerOfRecipientChange() { recipientPresenter.onBccTokenAdded(); verify(listener).onRecipientsChanged(); }
void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onBccTokenChanged_notifiesListenerOfRecipientChange() { recipientPresenter.onBccTokenChanged(); verify(listener).onRecipientsChanged(); }
void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void onBccTokenRemoved_notifiesListenerOfRecipientChange() { recipientPresenter.onBccTokenRemoved(); verify(listener).onRecipientsChanged(); }
void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } }
RecipientPresenter implements PermissionPingCallback { void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
RecipientPresenter implements PermissionPingCallback { void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener); List<Address> getToAddresses(); List<Address> getCcAddresses(); List<Address> getBccAddresses(); boolean checkRecipientsOkForSending(); void initFromReplyToMessage(Message message, ReplyMode replyMode); void initFromTrustIdAction(String trustId); void initFromMailto(MailTo mailTo); void initFromSendOrViewIntent(Intent intent); void onRestoreInstanceState(Bundle savedInstanceState); void onSaveInstanceState(Bundle outState); void initFromDraftMessage(Message message); void addBccAddresses(Address... bccRecipients); void onPrepareOptionsMenu(Menu menu); void onSwitchAccount(Account account); @SuppressWarnings("UnusedParameters") void onSwitchIdentity(Identity identity); void asyncUpdateCryptoStatus(); @Nullable ComposeCryptoStatus getCurrentCachedCryptoStatus(); boolean isForceTextMessageFormat(); void onCryptoModeChanged(CryptoMode cryptoMode); void onCryptoPgpInlineChanged(boolean enablePgpInline); void onMenuAddFromContacts(); void onActivityResult(int requestCode, int resultCode, Intent data); void onNonRecipientFieldFocused(); void showPgpSendError(SendErrorState sendErrorState); @Override void onPgpPermissionCheckResult(Intent result); void onActivityDestroy(); void builderSetProperties(MessageBuilder messageBuilder); void builderSetProperties(PgpMessageBuilder pgpMessageBuilder, ComposeCryptoStatus cryptoStatus); void onMenuSetPgpInline(boolean enablePgpInline); void onMenuSetSignOnly(boolean enableSignOnly); void onMenuSetEnableEncryption(boolean enableEncryption); void onCryptoPgpClickDisable(); void onCryptoPgpSignOnlyDisabled(); boolean shouldSaveRemotely(); }
@Test public void getDisplayName_forUnknownFolder_returnsName() { String result = FolderInfoHolder.getDisplayName(context, mockAccount, "FolderID", "Folder"); assertEquals("Folder", result); }
public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); public String id; public String name; public String displayName; public long lastChecked; public int unreadMessageCount; public int flaggedMessageCount; public boolean loading; public String status; public boolean lastCheckFailed; public Folder folder; public boolean pushActive; public boolean moreMessages; }
@Test public void getDisplayName_forSpamFolder_returnsNameSpam() { when(mockAccount.getSpamFolderId()).thenReturn("FolderID"); String result = FolderInfoHolder.getDisplayName(context, mockAccount, "FolderID", "Folder"); assertEquals("Folder (Spam)", result); }
public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); public String id; public String name; public String displayName; public long lastChecked; public int unreadMessageCount; public int flaggedMessageCount; public boolean loading; public String status; public boolean lastCheckFailed; public Folder folder; public boolean pushActive; public boolean moreMessages; }
@Test public void getDisplayName_forOutboxFolder_returnsOutbox() { when(mockAccount.getOutboxFolderId()).thenReturn("FolderID"); String result = FolderInfoHolder.getDisplayName(context, mockAccount, "FolderID", "Folder"); assertEquals("Outbox", result); }
public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); public String id; public String name; public String displayName; public long lastChecked; public int unreadMessageCount; public int flaggedMessageCount; public boolean loading; public String status; public boolean lastCheckFailed; public Folder folder; public boolean pushActive; public boolean moreMessages; }
@Test public void getDisplayName_forInboxFolder_returnsInbox() { when(mockAccount.getInboxFolderId()).thenReturn("FolderID"); String result = FolderInfoHolder.getDisplayName(context, mockAccount, "FolderID", "Folder"); assertEquals("Inbox", result); }
public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); public String id; public String name; public String displayName; public long lastChecked; public int unreadMessageCount; public int flaggedMessageCount; public boolean loading; public String status; public boolean lastCheckFailed; public Folder folder; public boolean pushActive; public boolean moreMessages; }
@Test public void getDisplayName_forInboxFolderAlternativeCase_returnsInbox() { when(mockAccount.getInboxFolderId()).thenReturn("FOLDERID"); String result = FolderInfoHolder.getDisplayName(context, mockAccount, "FolderID", "Folder"); assertEquals("Inbox", result); }
public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); }
FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam_fmt), name); } else if (id.equals(account.getArchiveFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_archive_fmt), name); } else if (id.equals(account.getSentFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_sent_fmt), name); } else if (id.equals(account.getTrashFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_trash_fmt), name); } else if (id.equals(account.getDraftsFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_drafts_fmt), name); } else if (id.equals(account.getOutboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_outbox); } else if (id.equalsIgnoreCase(account.getInboxFolderId())) { displayName = context.getString(R.string.special_mailbox_name_inbox); } else if (name == null) { displayName = id; } else { displayName = name; } return displayName; } FolderInfoHolder(); FolderInfoHolder(Context context, LocalFolder folder, Account account); FolderInfoHolder(Context context, LocalFolder folder, Account account, int unreadCount); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(FolderInfoHolder o); void populate(Context context, LocalFolder folder, Account account, int unreadCount); void populate(Context context, LocalFolder folder, Account account); static String getDisplayName(Context context, Account account, String id, String name); void setMoreMessagesFromFolder(LocalFolder folder); public String id; public String name; public String displayName; public long lastChecked; public int unreadMessageCount; public int flaggedMessageCount; public boolean loading; public String status; public boolean lastCheckFailed; public Folder folder; public boolean pushActive; public boolean moreMessages; }
@Test public void checkIdentityStringFromMessageReferenceWithoutFlag() { MessageReference messageReference = createMessageReference("o hai!", "folder", "10101010"); assertEquals("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=", messageReference.toIdentityString()); }
public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void checkIdentityStringFromMessageReferenceWithFlag() { MessageReference messageReference = createMessageReferenceWithFlag("o hai!", "folder", "10101010", Flag.ANSWERED); assertEquals("!:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED", messageReference.toIdentityString()); }
public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(uid)); if (flag != null) { refString.append(IDENTITY_SEPARATOR); refString.append(flag.name()); } return refString.toString(); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void findEncrypted__withMultipartMixedSubEncrypted__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertEquals(1, encryptedParts.size()); assertSame(getPart(message, 0), encryptedParts.get(0)); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void findPrimaryCryptoPart_withMultipartMixedContainingMultipartAlternativeContainingPgpInline() throws Exception { List<Part> outputExtraParts = new ArrayList<>(); BodyPart pgpInlinePart = bodypart("text/plain", PGP_INLINE_DATA); Message message = messageFromBody( multipart("mixed", multipart("alternative", pgpInlinePart, bodypart("text/html") ), bodypart("application/octet-stream") ) ); Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts); assertSame(pgpInlinePart, cryptoPart); }
public static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts) { if (isPartEncryptedOrSigned(part)) { return part; } Part foundPart; foundPart = findPrimaryPartInAlternative(part); if (foundPart != null) { return foundPart; } foundPart = findPrimaryPartInMixed(part, outputExtraParts); if (foundPart != null) { return foundPart; } return null; }
MessageDecryptVerifier { public static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts) { if (isPartEncryptedOrSigned(part)) { return part; } Part foundPart; foundPart = findPrimaryPartInAlternative(part); if (foundPart != null) { return foundPart; } foundPart = findPrimaryPartInMixed(part, outputExtraParts); if (foundPart != null) { return foundPart; } return null; } }
MessageDecryptVerifier { public static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts) { if (isPartEncryptedOrSigned(part)) { return part; } Part foundPart; foundPart = findPrimaryPartInAlternative(part); if (foundPart != null) { return foundPart; } foundPart = findPrimaryPartInMixed(part, outputExtraParts); if (foundPart != null) { return foundPart; } return null; } }
MessageDecryptVerifier { public static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts) { if (isPartEncryptedOrSigned(part)) { return part; } Part foundPart; foundPart = findPrimaryPartInAlternative(part); if (foundPart != null) { return foundPart; } foundPart = findPrimaryPartInMixed(part, outputExtraParts); if (foundPart != null) { return foundPart; } return null; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findEncryptedParts(Part startPart); static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPgpMimeEncryptedOrSignedPart(Part part); static boolean isSMimeEncryptedOrSignedPart(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageDecryptVerifier { public static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts) { if (isPartEncryptedOrSigned(part)) { return part; } Part foundPart; foundPart = findPrimaryPartInAlternative(part); if (foundPart != null) { return foundPart; } foundPart = findPrimaryPartInMixed(part, outputExtraParts); if (foundPart != null) { return foundPart; } return null; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findEncryptedParts(Part startPart); static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPgpMimeEncryptedOrSignedPart(Part part); static boolean isSMimeEncryptedOrSignedPart(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void parseIdentityStringContainingBadVersionNumber() { MessageReference messageReference = MessageReference.parse("@:byBoYWkh:Zm9sZGVy:MTAxMDEwMTA=:ANSWERED"); assertNull(messageReference); }
@Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void parseNullIdentityString() { MessageReference messageReference = MessageReference.parse(null); assertNull(messageReference); }
@Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void parseIdentityStringWithCorruptFlag() { MessageReference messageReference = MessageReference.parse("!:%^&%^*$&$by&(BYWkh:Zm9%^@sZGVy:MT-35#$AxMDEwMTA=:ANSWE!RED"); assertNull(messageReference); }
@Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countTokens() < 3) { return null; } String accountUuid = Base64.decode(tokens.nextToken()); String folderId = Base64.decode(tokens.nextToken()); String uid = Base64.decode(tokens.nextToken()); if (!tokens.hasMoreTokens()) { return new MessageReference(accountUuid, folderId, uid, null); } Flag flag; try { flag = Flag.valueOf(tokens.nextToken()); } catch (IllegalArgumentException e) { return null; } return new MessageReference(accountUuid, folderId, uid, flag); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void equalsWithAnObjectShouldReturnFalse() { MessageReference messageReference = new MessageReference("a", "b", "c", null); Object object = new Object(); assertFalse(messageReference.equals(object)); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@SuppressWarnings("ObjectEqualsNull") @Test public void equalsWithNullShouldReturnFalse() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); assertFalse(messageReference.equals(null)); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void equalsWithSameMessageReferenceShouldReturnTrue() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); assertTrue(messageReference.equals(messageReference)); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void alternativeEquals() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); boolean equalsResult = messageReference.equals("account", "folder", "uid"); assertTrue(equalsResult); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void equals_withNullAccount_shouldReturnFalse() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); boolean equalsResult = messageReference.equals(null, "folder", "uid"); assertFalse(equalsResult); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void equals_withNullFolder_shouldReturnFalse() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); boolean equalsResult = messageReference.equals("account", null, "uid"); assertFalse(equalsResult); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void equals_withNullUid_shouldReturnFalse() { MessageReference messageReference = createMessageReference("account", "folder", "uid"); boolean equalsResult = messageReference.equals("account", "folder", null); assertFalse(equalsResult); }
@Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag); @Nullable static MessageReference parse(String identity); String toIdentityString(); @Override boolean equals(Object o); boolean equals(String accountUuid, String folderId, String uid); @Override int hashCode(); @Override String toString(); String getAccountUuid(); String getFolderId(); String getUid(); Flag getFlag(); MessageReference withModifiedUid(String newUid); MessageReference withModifiedFlag(Flag newFlag); }
@Test public void findEncrypted__withMultipartMixedSubEncryptedAndEncrypted__shouldReturnBoth() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ), multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertEquals(2, encryptedParts.size()); assertSame(getPart(message, 0), encryptedParts.get(0)); assertSame(getPart(message, 1), encryptedParts.get(1)); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void testCreateAndInitializeNotificationBuilder() throws Exception { Account account = createFakeAccount(); Builder builder = notifications.createAndInitializeNotificationBuilder(account); verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); }
protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); }
BaseNotifications { protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); } }
BaseNotifications { protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_EMAIL); } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
@Test public void testIsDeleteActionEnabled_NotificationQuickDelete_ALWAYS() throws Exception { QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); boolean result = notifications.isDeleteActionEnabled(); assertTrue(result); }
protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
@Test public void testIsDeleteActionEnabled_NotificationQuickDelete_FOR_SINGLE_MSG() throws Exception { QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.FOR_SINGLE_MSG); boolean result = notifications.isDeleteActionEnabled(); assertTrue(result); }
protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
@Test public void testIsDeleteActionEnabled_NotificationQuickDelete_NEVER() throws Exception { QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.NEVER); boolean result = notifications.isDeleteActionEnabled(); assertFalse(result); }
protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
@Test public void testCreateBigTextStyleNotification() throws Exception { Account account = createFakeAccount(); int notificationId = 23; NotificationHolder holder = createNotificationHolder(notificationId); Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId); verify(builder).setTicker(NOTIFICATION_SUMMARY); verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER); verify(builder).setContentTitle(SENDER); verify(builder).setContentText(SUBJECT); verify(builder).setSubText(ACCOUNT_NAME); BigTextStyle bigTextStyle = notifications.bigTextStyle; verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW); verify(builder).setStyle(bigTextStyle); }
protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; }
BaseNotifications { protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; } }
BaseNotifications { protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
BaseNotifications { protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; } protected BaseNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
@Test public void testBuildStackedNotification() throws Exception { disableOptionalActions(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent replyPendingIntent = createFakePendingIntent(1); when(actionCreator.createReplyPendingIntent(messageReference, notificationId)).thenReturn(replyPendingIntent); PendingIntent markAsReadPendingIntent = createFakePendingIntent(2); when(actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId)) .thenReturn(markAsReadPendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_single_message_options_dark, "Reply", replyPendingIntent); verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark Read", markAsReadPendingIntent); verifyNumberOfActions(2); }
public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception { enableDeleteAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent deletePendingIntent = createFakePendingIntent(1); when(actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId)) .thenReturn(deletePendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_delete_dark, "Delete", deletePendingIntent); }
public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception { enableArchiveAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent archivePendingIntent = createFakePendingIntent(1); when(actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId)) .thenReturn(archivePendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_archive_dark, "Archive", archivePendingIntent); }
public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception { enableSpamAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent markAsSpamPendingIntent = createFakePendingIntent(1); when(actionCreator.createMarkMessageAsSpamPendingIntent(messageReference, notificationId)) .thenReturn(markAsSpamPendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_spam_dark, "Spam", markAsSpamPendingIntent); }
public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void testAddSummaryActions() throws Exception { disableOptionalSummaryActions(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); ArrayList<MessageReference> messageReferences = createMessageReferenceList(); NotificationData notificationData = createNotificationData(messageReferences); PendingIntent markAllAsReadPendingIntent = createFakePendingIntent(1); when(actionCreator.getMarkAllAsReadPendingIntent(account, messageReferences, notificationId)) .thenReturn(markAllAsReadPendingIntent); wearNotifications.addSummaryActions(builder, notificationData); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark All Read", markAllAsReadPendingIntent); verifyNumberOfActions(1); }
public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void findEncrypted__withMultipartMixedSubTextAndEncrypted__shouldReturnEncrypted() throws Exception { Message message = messageFromBody( multipart("mixed", bodypart("text/plain"), multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertEquals(1, encryptedParts.size()); assertSame(getPart(message, 1), encryptedParts.get(0)); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void testAddSummaryActionsWithDeleteAllActionEnabled() throws Exception { enableDeleteAction(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); ArrayList<MessageReference> messageReferences = createMessageReferenceList(); NotificationData notificationData = createNotificationData(messageReferences); PendingIntent deletePendingIntent = createFakePendingIntent(1); when(actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId)) .thenReturn(deletePendingIntent); wearNotifications.addSummaryActions(builder, notificationData); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_delete_dark, "Delete All", deletePendingIntent); }
public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void testAddSummaryActionsWithArchiveAllActionEnabled() throws Exception { enableArchiveAction(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); ArrayList<MessageReference> messageReferences = createMessageReferenceList(); NotificationData notificationData = createNotificationData(messageReferences); PendingIntent archivePendingIntent = createFakePendingIntent(1); when(actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId)) .thenReturn(archivePendingIntent); wearNotifications.addSummaryActions(builder, notificationData); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_archive_dark, "Archive All", archivePendingIntent); }
public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteActionAvailableForWear()) { addDeleteAllAction(wearableExtender, notificationData); } Account account = notificationData.getAccount(); if (isArchiveActionAvailableForWear(account)) { addArchiveAllAction(wearableExtender, notificationData); } builder.extend(wearableExtender); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData); }
@Test public void showAuthenticationErrorNotification_withIncomingServer_shouldCreateNotification() throws Exception { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, INCOMING); authenticationErrorNotifications.showAuthenticationErrorNotification(account, INCOMING); verify(notificationManager).notify(eq(notificationId), any(Notification.class)); assertAuthenticationErrorNotificationContents(); }
public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
@Test public void clearAuthenticationErrorNotification_withIncomingServer_shouldCancelNotification() throws Exception { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, INCOMING); authenticationErrorNotifications.clearAuthenticationErrorNotification(account, INCOMING); verify(notificationManager).cancel(notificationId); }
public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
@Test public void showAuthenticationErrorNotification_withOutgoingServer_shouldCreateNotification() throws Exception { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, OUTGOING); authenticationErrorNotifications.showAuthenticationErrorNotification(account, OUTGOING); verify(notificationManager).notify(eq(notificationId), any(Notification.class)); assertAuthenticationErrorNotificationContents(); }
public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
@Test public void clearAuthenticationErrorNotification_withOutgoingServer_shouldCancelNotification() throws Exception { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, OUTGOING); authenticationErrorNotifications.clearAuthenticationErrorNotification(account, OUTGOING); verify(notificationManager).cancel(notificationId); }
public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(NotificationController controller); void showAuthenticationErrorNotification(Account account, boolean incoming); void clearAuthenticationErrorNotification(Account account, boolean incoming); }
@Test public void createFromMessage_withRegularMessage() throws Exception { NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals(messageReference, content.messageReference); assertEquals(SENDER_NAME, content.sender); assertEquals(SUBJECT, content.subject); assertEquals(SUBJECT + "\n" + PREVIEW, content.preview.toString()); assertEquals(SENDER_NAME + " " + SUBJECT, content.summary.toString()); assertEquals(false, content.starred); }
public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
@Test public void createFromMessage_withoutSubject() throws Exception { when(message.getSubject()).thenReturn(null); NotificationContent content = contentCreator.createFromMessage(account, message); String noSubject = "(No subject)"; assertEquals(noSubject, content.subject); assertEquals(PREVIEW, content.preview.toString()); assertEquals(SENDER_NAME + " " + noSubject, content.summary.toString()); }
public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
@Test public void createFromMessage_withoutSender() throws Exception { when(message.getFrom()).thenReturn(null); NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals("No sender", content.sender); assertEquals(SUBJECT, content.summary.toString()); }
public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
@Test public void createFromMessage_withMessageFromSelf() throws Exception { when(account.isAnIdentity(any(Address[].class))).thenReturn(true); NotificationContent content = contentCreator.createFromMessage(account, message); String insteadOfSender = "To:Bob"; assertEquals(insteadOfSender, content.sender); assertEquals(insteadOfSender + " " + SUBJECT, content.summary.toString()); }
public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
@Test public void findEncrypted__withMultipartMixedSubEncryptedAndText__shouldReturnEncrypted() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", "protocol=\"application/pgp-encrypted\"", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ), bodypart("text/plain") ) ); List<Part> encryptedParts = MessageCryptoStructureDetector.findMultipartEncryptedParts(message); assertEquals(1, encryptedParts.size()); assertSame(getPart(message, 0), encryptedParts.get(0)); }
public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encryptedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return encryptedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void createFromMessage_withStarredMessage() throws Exception { when(message.isSet(Flag.FLAGGED)).thenReturn(true); NotificationContent content = contentCreator.createFromMessage(account, message); assertEquals(true, content.starred); }
public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subject = getMessageSubject(message); CharSequence preview = getMessagePreview(message); CharSequence summary = buildMessageSummary(sender, subject); boolean starred = message.isSet(Flag.FLAGGED); return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred); } NotificationContentCreator(Context context); NotificationContent createFromMessage(Account account, LocalMessage message); }
@Test public void configureLockScreenNotification_NOTHING() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.NOTHING); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(builder).setVisibility(NotificationCompat.VISIBILITY_SECRET); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void configureLockScreenNotification_APP_NAME() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.APP_NAME); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PRIVATE); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void configureLockScreenNotification_EVERYTHING() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.EVERYTHING); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void configureLockScreenNotification_SENDERS_withSingleMessage() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.SENDERS); String senderName = "[email protected]"; NotificationContent content = createNotificationContent(senderName); NotificationHolder holder = new NotificationHolder(42, content); when(notificationData.getNewMessagesCount()).thenReturn(1); when(notificationData.getUnreadMessageCount()).thenReturn(1); when(notificationData.getHolderForLatestNotification()).thenReturn(holder); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(publicBuilder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(publicBuilder).setNumber(1); verify(publicBuilder).setContentTitle("1 new message"); verify(publicBuilder).setContentText(senderName); verify(builder).setPublicVersion(publicBuilder.build()); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void configureLockScreenNotification_SENDERS_withMultipleMessages() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.SENDERS); NotificationContent content1 = createNotificationContent("[email protected]"); NotificationContent content2 = createNotificationContent("Bob <[email protected]>"); NotificationContent content3 = createNotificationContent("\"Peter Lustig\" <[email protected]>"); when(notificationData.getNewMessagesCount()).thenReturn(NEW_MESSAGE_COUNT); when(notificationData.getUnreadMessageCount()).thenReturn(UNREAD_MESSAGE_COUNT); when(notificationData.getContentForSummaryNotification()).thenReturn( Arrays.asList(content1, content2, content3)); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(publicBuilder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(publicBuilder).setNumber(UNREAD_MESSAGE_COUNT); verify(publicBuilder).setContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(publicBuilder).setContentText( "[email protected], Bob <[email protected]>, \"Peter Lustig\" <[email protected]>"); verify(builder).setPublicVersion(publicBuilder.build()); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void createCommaSeparatedListOfSenders_withMoreSendersThanShouldBeDisplayed() throws Exception { NotificationContent content1 = createNotificationContent("[email protected]"); NotificationContent content2 = createNotificationContent("[email protected]"); NotificationContent content3 = createNotificationContent("[email protected]"); NotificationContent content4 = createNotificationContent("[email protected]"); NotificationContent content5 = createNotificationContent("[email protected]"); NotificationContent content6 = createNotificationContent("[email protected]"); String result = lockScreenNotification.createCommaSeparatedListOfSenders( Arrays.asList(content1, content2, content3, content4, content5, content6)); assertEquals( "[email protected], [email protected], [email protected], [email protected], [email protected]", result); }
String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void configureLockScreenNotification_MESSAGE_COUNT() throws Exception { QMail.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.MESSAGE_COUNT); when(notificationData.getNewMessagesCount()).thenReturn(NEW_MESSAGE_COUNT); when(notificationData.getUnreadMessageCount()).thenReturn(UNREAD_MESSAGE_COUNT); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(publicBuilder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(publicBuilder).setNumber(UNREAD_MESSAGE_COUNT); verify(publicBuilder).setContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(publicBuilder).setContentText(ACCOUNT_NAME); verify(builder).setPublicVersion(publicBuilder.build()); }
public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { public void configureLockScreenNotification(Builder builder, NotificationData notificationData) { if (!NotificationController.platformSupportsLockScreenNotifications()) { return; } switch (QMail.getLockScreenNotificationVisibility()) { case NOTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); break; } case APP_NAME: { builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); break; } case EVERYTHING: { builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); break; } case SENDERS: { Notification publicNotification = createPublicNotificationWithSenderList(notificationData); builder.setPublicVersion(publicNotification); break; } case MESSAGE_COUNT: { Notification publicNotification = createPublicNotificationWithNewMessagesCount(notificationData); builder.setPublicVersion(publicNotification); break; } } } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
@Test public void getNewMailSummaryNotificationId_withDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); assertEquals(6, notificationId); }
public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getNewMailStackedNotificationId_withDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); assertEquals(7, notificationId); }
public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void findSigned__withSimpleMultipartSigned__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("signed", "protocol=\"application/pgp-signature\"", bodypart("text/plain"), bodypart("application/pgp-signature") ) ); List<Part> signedParts = MessageCryptoStructureDetector .findMultipartSignedParts(message, messageCryptoAnnotations); assertEquals(1, signedParts.size()); assertSame(message, signedParts.get(0)); }
public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test(expected = IndexOutOfBoundsException.class) public void getNewMailStackedNotificationId_withTooLowIndex() throws Exception { Account account = createMockAccountWithAccountNumber(0); NotificationIds.getNewMailStackedNotificationId(account, -1); }
public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test(expected = IndexOutOfBoundsException.class) public void getNewMailStackedNotificationId_withTooLargeIndex() throws Exception { Account account = createMockAccountWithAccountNumber(0); NotificationIds.getNewMailStackedNotificationId(account, 8); }
public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getNewMailSummaryNotificationId_withSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); assertEquals(21, notificationId); }
public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getNewMailStackedNotificationId_withSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationIndex = 7; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); assertEquals(29, notificationId); }
public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getFetchingMailNotificationId_withDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getFetchingMailNotificationId(account); assertEquals(5, notificationId); }
public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getFetchingMailNotificationId_withSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getFetchingMailNotificationId(account); assertEquals(20, notificationId); }
public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getSendFailedNotificationId_withDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getSendFailedNotificationId(account); assertEquals(0, notificationId); }
public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getSendFailedNotificationId_withSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getSendFailedNotificationId(account); assertEquals(15, notificationId); }
public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getCertificateErrorNotificationId_forIncomingServerWithDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getCertificateErrorNotificationId(account, INCOMING); assertEquals(1, notificationId); }
public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getCertificateErrorNotificationId_forIncomingServerWithSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getCertificateErrorNotificationId(account, INCOMING); assertEquals(16, notificationId); }
public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void findSigned__withNoProtocolAndNoBody__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature") ) ); List<Part> signedParts = MessageCryptoStructureDetector .findMultipartSignedParts(message, messageCryptoAnnotations); assertEquals(1, signedParts.size()); assertSame(message, signedParts.get(0)); }
public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void getCertificateErrorNotificationId_forOutgoingServerWithDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getCertificateErrorNotificationId(account, OUTGOING); assertEquals(2, notificationId); }
public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getCertificateErrorNotificationId_forOutgoingServerWithSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getCertificateErrorNotificationId(account, OUTGOING); assertEquals(17, notificationId); }
public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getAuthenticationErrorNotificationId_forIncomingServerWithDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, INCOMING); assertEquals(3, notificationId); }
public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getAuthenticationErrorNotificationId_forIncomingServerWithSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, INCOMING); assertEquals(18, notificationId); }
public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getAuthenticationErrorNotificationId_forOutgoingServerWithDefaultAccount() throws Exception { Account account = createMockAccountWithAccountNumber(0); int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, OUTGOING); assertEquals(4, notificationId); }
public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void getAuthenticationErrorNotificationId_forOutgoingServerWithSecondAccount() throws Exception { Account account = createMockAccountWithAccountNumber(1); int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, OUTGOING); assertEquals(19, notificationId); }
public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingMailNotificationId(Account account); static int getSendFailedNotificationId(Account account); static int getCertificateErrorNotificationId(Account account, boolean incoming); static int getAuthenticationErrorNotificationId(Account account, boolean incoming); }
@Test public void buildSummaryNotification_withPrivacyModeActive() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.ALWAYS); Notification result = notifications.buildSummaryNotification(account, notificationData, false); verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); verify(builder).setNumber(UNREAD_MESSAGE_COUNT); verify(builder).setTicker("New mail"); verify(builder).setContentText("New mail"); verify(builder).setContentTitle(UNREAD_MESSAGE_COUNT + " Unread (" + ACCOUNT_NAME + ")"); verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData); assertEquals(FAKE_NOTIFICATION, result); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void buildSummaryNotification_withSingleMessageNotification() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); when(notificationData.isSingleMessageNotification()).thenReturn(true); Notification result = notifications.buildSummaryNotification(account, notificationData, false); verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); verify(builder).setTicker(SUMMARY); verify(builder).setContentText(SUBJECT); verify(builder).setContentTitle(SENDER); verify(builder).setStyle(notifications.bigTextStyle); verify(notifications.bigTextStyle).bigText(PREVIEW); verify(builder).addAction(R.drawable.notification_action_reply, "Reply", null); verify(builder).addAction(R.drawable.notification_action_mark_as_read, "Mark Read", null); verify(builder).addAction(R.drawable.notification_action_delete, "Delete", null); verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData); assertEquals(FAKE_NOTIFICATION, result); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void buildSummaryNotification_withMultiMessageNotification() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); when(notificationData.isSingleMessageNotification()).thenReturn(false); when(notificationData.containsStarredMessages()).thenReturn(true); Notification result = notifications.buildSummaryNotification(account, notificationData, false); verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); verify(builder).setTicker(SUMMARY); verify(builder).setContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(builder).setSubText(ACCOUNT_NAME); verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER); verify(builder).setGroupSummary(true); verify(builder).setPriority(NotificationCompat.PRIORITY_HIGH); verify(builder).setStyle(notifications.inboxStyle); verify(notifications.inboxStyle).setBigContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(notifications.inboxStyle).setSummaryText(ACCOUNT_NAME); verify(notifications.inboxStyle).addLine(SUMMARY); verify(notifications.inboxStyle).addLine(SUMMARY_2); verify(builder).addAction(R.drawable.notification_action_mark_as_read, "Mark Read", null); verify(builder).addAction(R.drawable.notification_action_delete, "Delete", null); verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData); assertEquals(FAKE_NOTIFICATION, result); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void buildSummaryNotification_withAdditionalMessages() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); when(notificationData.isSingleMessageNotification()).thenReturn(false); when(notificationData.hasSummaryOverflowMessages()).thenReturn(true); when(notificationData.getSummaryOverflowMessagesCount()).thenReturn(23); notifications.buildSummaryNotification(account, notificationData, false); verify(notifications.inboxStyle).setSummaryText("+ 23 more on " + ACCOUNT_NAME); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void findSigned__withBadProtocol__shouldReturnNothing() throws Exception { Message message = messageFromBody( multipart("signed", "protocol=\"application/not-pgp-signature\"", bodypart("text/plain", "content"), bodypart("application/pgp-signature") ) ); List<Part> signedParts = MessageCryptoStructureDetector .findMultipartSignedParts(message, messageCryptoAnnotations); assertTrue(signedParts.isEmpty()); }
public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
MessageCryptoStructureDetector { public static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations.has(part)) { CryptoResultAnnotation resultAnnotation = messageCryptoAnnotations.get(part); MimeBodyPart replacementData = resultAnnotation.getReplacementData(); if (replacementData != null) { part = replacementData; } } Body body = part.getBody(); if (isPartMultipartSigned(part)) { signedParts.add(part); continue; } if (body instanceof Multipart) { Multipart multipart = (Multipart) body; for (int i = multipart.getCount() - 1; i >= 0; i--) { BodyPart bodyPart = multipart.getBodyPart(i); partsToCheck.push(bodyPart); } } } return signedParts; } static Part findPrimaryEncryptedOrSignedPart(Part part, List<Part> outputExtraParts); static List<Part> findMultipartEncryptedParts(Part startPart); static List<Part> findMultipartSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations); static List<Part> findPgpInlineParts(Part startPart); static byte[] getSignatureData(Part part); static boolean isPartMultipartEncrypted(Part part); static boolean isMultipartEncryptedOpenPgpProtocol(Part part); static boolean isMultipartSignedOpenPgpProtocol(Part part); static boolean isMultipartEncryptedSMimeProtocol(Part part); static boolean isMultipartSignedSMimeProtocol(Part part); static boolean isPartPgpInlineEncrypted(@Nullable Part part); }
@Test public void buildSummaryNotification_withoutDeleteAllAction() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.NEVER); when(notificationData.isSingleMessageNotification()).thenReturn(false); notifications.buildSummaryNotification(account, notificationData, false); verify(builder, never()).addAction(R.drawable.notification_action_delete, "Delete", null); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void buildSummaryNotification_withoutDeleteAction() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.NEVER); when(notificationData.isSingleMessageNotification()).thenReturn(true); notifications.buildSummaryNotification(account, notificationData, false); verify(builder, never()).addAction(R.drawable.notification_action_delete, "Delete", null); }
public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
DeviceNotifications extends BaseNotifications { public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) { int unreadMessageCount = notificationData.getUnreadMessageCount(); NotificationCompat.Builder builder; if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) { builder = createSimpleSummaryNotification(account, unreadMessageCount); } else if (notificationData.isSingleMessageNotification()) { NotificationHolder holder = notificationData.getHolderForLatestNotification(); builder = createBigTextStyleSummaryNotification(account, holder); } else { builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount); } if (notificationData.containsStarredMessages()) { builder.setPriority(NotificationCompat.PRIORITY_HIGH); } int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent( account, notificationId); builder.setDeleteIntent(deletePendingIntent); lockScreenNotification.configureLockScreenNotification(builder, notificationData); boolean ringAndVibrate = false; if (!silent && !account.isRingNotified()) { account.setRingNotified(true); ringAndVibrate = true; } NotificationSetting notificationSetting = account.getNotificationSetting(); controller.configureNotification( builder, (notificationSetting.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator, LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller, NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent); }
@Test public void testShowSendingNotification() throws Exception { int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.showSendingNotification(account); verify(notificationManager).notify(eq(notificationId), any(Notification.class)); verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail); verify(builder).setTicker("Sending mail: " + ACCOUNT_NAME); verify(builder).setContentTitle("Sending mail"); verify(builder).setContentText(ACCOUNT_NAME); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_bg_send_ticker, accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolderName = account.getOutboxFolderId(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); }
SyncNotifications { public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_bg_send_ticker, accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolderName = account.getOutboxFolderId(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } }
SyncNotifications { public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_bg_send_ticker, accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolderName = account.getOutboxFolderId(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); }
SyncNotifications { public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_bg_send_ticker, accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolderName = account.getOutboxFolderId(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
SyncNotifications { public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_bg_send_ticker, accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolderName = account.getOutboxFolderId(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
@Test public void testClearSendingNotification() throws Exception { int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.clearSendingNotification(account); verify(notificationManager).cancel(notificationId); }
public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); }
SyncNotifications { public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } }
SyncNotifications { public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); }
SyncNotifications { public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
SyncNotifications { public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
@Test public void testGetFetchingMailNotificationId() throws Exception { Folder folder = createFakeFolder(); int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.showFetchingMailNotification(account, folder); verify(notificationManager).notify(eq(notificationId), any(Notification.class)); verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail); verify(builder).setTicker("Checking mail: " + ACCOUNT_NAME + ":" + FOLDER_NAME); verify(builder).setContentTitle("Checking mail"); verify(builder).setContentText(ACCOUNT_NAME + ":" + FOLDER_NAME); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName); String title = context.getString(R.string.notification_bg_sync_title); String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); }
SyncNotifications { public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName); String title = context.getString(R.string.notification_bg_sync_title); String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } }
SyncNotifications { public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName); String title = context.getString(R.string.notification_bg_sync_title); String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); }
SyncNotifications { public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName); String title = context.getString(R.string.notification_bg_sync_title); String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
SyncNotifications { public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName); String title = context.getString(R.string.notification_bg_sync_title); String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderName, notificationId); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.ic_notify_check_mail) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
@Test public void testClearSendFailedNotification() throws Exception { int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.clearFetchingMailNotification(account); verify(notificationManager).cancel(notificationId); }
public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); }
SyncNotifications { public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } }
SyncNotifications { public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); }
SyncNotifications { public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }
SyncNotifications { public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void showSendingNotification(Account account); void clearSendingNotification(Account account); void showFetchingMailNotification(Account account, Folder folder); void clearFetchingMailNotification(Account account); }