Include guava in Email.

- adds a compile time dependency to the guava library
- changes to use @VisibleForTesting in places to ensure it works

Change-Id: I2c5c4f9861234fec3613da011185e5c11f228466
This commit is contained in:
Ben Komalo 2011-04-14 13:32:41 -07:00
parent 8faa4e9cfa
commit 28b3fec5c1
4 changed files with 18 additions and 11 deletions

View File

@ -23,7 +23,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/email)
LOCAL_SRC_FILES += $(call all-java-files-under, src/com/beetstra)
LOCAL_STATIC_JAVA_LIBRARIES := android-common com.android.emailcommon
LOCAL_STATIC_JAVA_LIBRARIES := android-common com.android.emailcommon guava
LOCAL_PACKAGE_NAME := Email

View File

@ -21,6 +21,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := com.android.emailcommon
LOCAL_STATIC_JAVA_LIBRARIES := guava
LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/emailcommon)
LOCAL_SRC_FILES += $(call all-java-files-under, src/org)
LOCAL_SRC_FILES += \

View File

@ -17,6 +17,7 @@
package com.android.emailcommon.mail;
import com.android.emailcommon.utility.Utility;
import com.google.common.annotations.VisibleForTesting;
import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.decoder.DecoderUtil;
@ -25,8 +26,6 @@ import android.text.TextUtils;
import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.regex.Pattern;
@ -80,7 +79,7 @@ public class Address {
}
public void setAddress(String address) {
mAddress = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1");;
mAddress = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1");
}
/**
@ -96,7 +95,7 @@ public class Address {
* Set name part from UTF-16 string. Optional surrounding double quote will be removed.
* It will be also unquoted and MIME/base64 decoded.
*
* @param Personal name part of email address as UTF-16 string. Null is acceptable.
* @param personal name part of email address as UTF-16 string. Null is acceptable.
*/
public void setPersonal(String personal) {
if (personal != null) {
@ -163,7 +162,8 @@ public class Address {
* Checks whether a string email address is valid.
* E.g. name@domain.com is valid.
*/
/* package */ static boolean isValidAddress(String address) {
@VisibleForTesting
static boolean isValidAddress(String address) {
// Note: Some email provider may violate the standard, so here we only check that
// address consists of two part that are separated by '@', and domain part contains
// at least one '.'.

View File

@ -35,6 +35,7 @@ import com.android.emailcommon.provider.EmailContent.MessageColumns;
import com.android.emailcommon.utility.AttachmentUtilities;
import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.emailcommon.utility.Utility;
import com.google.common.annotations.VisibleForTesting;
import android.app.ActionBar;
import android.app.Activity;
@ -1043,7 +1044,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
/**
* Checks whether all the email addresses listed in TO, CC, BCC are valid.
*/
/* package */ boolean isAddressAllValid() {
@VisibleForTesting
boolean isAddressAllValid() {
for (TextView view : new TextView[]{mToView, mCcView, mBccView}) {
String addresses = view.getText().toString().trim();
if (!Address.isAllValid(addresses)) {
@ -1336,7 +1338,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
*
* @param text the message body
*/
/* package */ void setInitialComposeText(CharSequence text, String signature) {
@VisibleForTesting
void setInitialComposeText(CharSequence text, String signature) {
mMessageContentView.setText("");
int textLength = 0;
if (text != null) {
@ -1365,7 +1368,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
*
* @param intent the launch intent
*/
/* package */ void initFromIntent(Intent intent) {
@VisibleForTesting
void initFromIntent(Intent intent) {
setAccount(intent);
@ -1534,7 +1538,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
* @param ccView the "Cc" view
* @param replyAll whether this is a replyAll (vs a reply)
*/
/*package*/ void setupAddressViews(Message message, Account account,
@VisibleForTesting
void setupAddressViews(Message message, Account account,
MultiAutoCompleteTextView toView, MultiAutoCompleteTextView ccView, boolean replyAll) {
/*
* If a reply-to was included with the message use that, otherwise use the from
@ -1631,7 +1636,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
/**
* Set a cursor to the end of a body except a signature.
*/
/* package */ void setMessageContentSelection(String signature) {
@VisibleForTesting
void setMessageContentSelection(String signature) {
int selection = mMessageContentView.length();
if (!TextUtils.isEmpty(signature)) {
int signatureLength = signature.length();