EmailIntent extends BaseIntent<EmailIntent> { @Nullable public static Uri createUri(@NonNull final List<String> addresses) { final int n = addresses.size(); if (n == 0) { return null; } final StringBuilder data = new StringBuilder(n * 15); for (int i = 0; i < n; i++) { data.append(addresses.get(i)); if (i < (n - 1)) { data.append(","); } } return Uri.fromParts(URI_SCHEME, data.toString(), null); }  EmailIntent to(@NonNull final String address); EmailIntent to(@NonNull final String... addresses); EmailIntent to(@Nullable final List<String> addresses); @NonNull List<String> addresses(); EmailIntent cc(@NonNull final String address); EmailIntent cc(@NonNull final String... addresses); EmailIntent cc(@Nullable final List<String> addresses); @NonNull List<String> ccAddresses(); EmailIntent bcc(@NonNull final String address); EmailIntent bcc(@NonNull final String... addresses); EmailIntent bcc(@Nullable final List<String> addresses); @NonNull List<String> bccAddresses(); EmailIntent subject(@NonNull final CharSequence subject); @NonNull CharSequence subject(); EmailIntent message(@NonNull final CharSequence message); @NonNull CharSequence message(); @Nullable static Uri createUri(@NonNull final List<String> addresses); static final String URI_SCHEME; static final Matcher EMAIL_MATCHER; }
@SuppressWarnings("ConstantConditions") @Test public void testCreateUriForSingleAddress() { final List<String> addresses = new ArrayList<>(1); addresses.add("test@android.com"); final Uri uri = EmailIntent.createUri(addresses); assertThat(uri, is(notNullValue())); assertThat(uri.getScheme(), is(EmailIntent.URI_SCHEME)); assertThat( uri, is(Uri.fromParts( "mailto", "test@android.com", null )) ); }
@SuppressWarnings("ConstantConditions") @Test public void testCreateUriForMultipleAddresses() { final List<String> addresses = new ArrayList<>(2); addresses.add("test1@android.com"); addresses.add("test2@android.com"); final Uri uri = EmailIntent.createUri(addresses); assertThat(uri, is(notNullValue())); assertThat(uri.getScheme(), is("mailto")); assertThat( uri, is(Uri.fromParts( "mailto", "test1@android.com,test2@android.com", null )) ); }
@Test public void testCreateUriForEmptyAddresses() { assertThat(EmailIntent.createUri(new ArrayList<String>(0)), is(nullValue())); }