Merge pull request #4632 from k9mail/remove_android_net_mailto

Stop using android.net.MailTo
This commit is contained in:
cketti 2020-03-29 21:45:24 +02:00 committed by GitHub
commit 073a00fcb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View file

@ -1,13 +1,13 @@
package com.fsck.k9.helper;
import java.util.ArrayList;
import java.util.List;
import android.net.Uri;
import com.fsck.k9.mail.Address;
import java.util.ArrayList;
import java.util.List;
public final class MailTo {
private static final String MAILTO_SCHEME = "mailto";

View file

@ -1,13 +1,14 @@
package com.fsck.k9.mail.internet;
import android.net.Uri;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.net.MailTo;
import com.fsck.k9.helper.MailTo;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Message;
@ -63,8 +64,8 @@ public class ListHeaders {
return null;
}
String mailToUri = matcher.group(1);
String emailAddress = MailTo.parse(mailToUri).getTo();
return new Address(emailAddress);
Uri mailToUri = Uri.parse(matcher.group(1));
Address[] emailAddress = MailTo.parse(mailToUri).getTo();
return emailAddress.length >= 1 ? emailAddress[0] : null;
}
}

View file

@ -1,19 +1,21 @@
package com.fsck.k9.helper;
import android.net.Uri;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import android.net.Uri;
import com.fsck.k9.RobolectricTest;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@ -21,7 +23,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class MailToTest extends RobolectricTest {
@RunWith(K9LibRobolectricTestRunner.class)
public class MailToTest {
@Rule
public ExpectedException exception = ExpectedException.none();