diff --git a/Android.mk b/Android.mk index aea26d4d6..8dd6784d8 100644 --- a/Android.mk +++ b/Android.mk @@ -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 diff --git a/emailcommon/Android.mk b/emailcommon/Android.mk index 2cfd1a105..e3211a56a 100644 --- a/emailcommon/Android.mk +++ b/emailcommon/Android.mk @@ -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 += \ diff --git a/emailcommon/src/com/android/emailcommon/mail/Address.java b/emailcommon/src/com/android/emailcommon/mail/Address.java index be03b39de..7866c8e0d 100644 --- a/emailcommon/src/com/android/emailcommon/mail/Address.java +++ b/emailcommon/src/com/android/emailcommon/mail/Address.java @@ -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 '.'. diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 80512a00b..9bd1d6aa8 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -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();