MmsSupport.MmsDetails details = mmsSupport.getDetails(mmsUri, addressStyle); MimeMultipart body = MimeMultipart.newInstance(); for (BodyPart p : mmsSupport.getMMSBodyParts(Uri.withAppendedPath(mmsUri, MMS_PART))) { body.addBodyPart(p);
@Test public void testShouldGenerateSubjectWithNameForMMS() throws Exception { PersonRecord personRecord = new PersonRecord(1, "Foo Bar", "foo@bar.com", "1234"); MmsSupport.MmsDetails details = new MmsSupport.MmsDetails(true, "foo", personRecord, new Address("foo@bar.com")); when(mmsSupport.getDetails(any(Uri.class), any(AddressStyle.class))).thenReturn(details); Message msg = generator.messageForDataType(mockMessage("1234", personRecord), DataType.MMS); assertThat(msg).isNotNull(); assertThat(msg.getSubject()).isEqualTo("SMS with Foo Bar"); }
public MessageConverter(Context context, Preferences preferences, String userEmail, PersonLookup personLookup, ContactAccessor contactAccessor) { this.context = context; markAsReadType = preferences.getMarkAsReadType(); this.personLookup = personLookup; markAsReadOnRestore = preferences.getMarkAsReadOnRestore(); String referenceUid = preferences.getReferenceUid(); if (referenceUid == null) { referenceUid = generateReferenceValue(); preferences.setReferenceUid(referenceUid); } final ContactGroup backupContactGroup = preferences.getBackupContactGroup(); ContactGroupIds allowedIds = contactAccessor.getGroupContactIds(context.getContentResolver(), backupContactGroup); if (LOCAL_LOGV) Log.v(TAG, "whitelisted ids for backup: " + allowedIds); messageGenerator = new MessageGenerator(context, new Address(userEmail), preferences.getEmailAddressStyle(), new HeaderGenerator(referenceUid, App.getVersionCode(context)), personLookup, preferences.getMailSubjectPrefix(), allowedIds, new MmsSupport(context.getContentResolver(), personLookup), preferences.getCallLogType(), preferences.getDataTypePreferences()); }
@Test public void testShouldGenerateMMSMessageWithCorrectEncoding() throws Exception { PersonRecord personRecord = new PersonRecord(1, "Foo Bar", "foo@bar.com", "1234"); MmsSupport.MmsDetails details = new MmsSupport.MmsDetails(true, "foo", personRecord, new Address("foo@bar.com")); when(mmsSupport.getDetails(any(Uri.class), any(AddressStyle.class))).thenReturn(details); Message msg = generator.messageForDataType(mockMessage("1234", personRecord), DataType.MMS); assertThat(msg.getHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING)).isEqualTo(new String[] { MimeUtil.ENC_7BIT }); }