diff --git a/src/com/android/email/Account.java b/src/com/android/email/Account.java
index 362377554..7b0944fdc 100644
--- a/src/com/android/email/Account.java
+++ b/src/com/android/email/Account.java
@@ -18,6 +18,7 @@ package com.android.email;
import com.android.email.mail.Store;
import com.android.emailcommon.service.SyncWindow;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.content.SharedPreferences;
diff --git a/src/com/android/email/AccountBackupRestore.java b/src/com/android/email/AccountBackupRestore.java
index 776c0c05e..bd94f5e74 100644
--- a/src/com/android/email/AccountBackupRestore.java
+++ b/src/com/android/email/AccountBackupRestore.java
@@ -16,14 +16,14 @@
package com.android.email;
-import com.android.email.provider.EmailProvider;
import com.android.email.service.MailService;
+import com.android.emailcommon.CalendarProviderStub;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
-import android.provider.Calendar;
import android.provider.ContactsContract;
import android.util.Log;
@@ -45,7 +45,7 @@ public class AccountBackupRestore {
*/
public static void backupAccounts(final Context context) {
if (Email.DEBUG) {
- Log.v(Email.LOG_TAG, "backupAccounts");
+ Log.v(Logging.LOG_TAG, "backupAccounts");
}
// Because we typically call this from the UI, let's do the work in a thread
new Thread() {
@@ -68,7 +68,7 @@ public class AccountBackupRestore {
boolean restored = doRestoreAccounts(context, Preferences.getPreferences(context), false);
if (restored) {
// after restoring accounts, register services appropriately
- Log.w(Email.LOG_TAG, "Register services after restoring accounts");
+ Log.w(Logging.LOG_TAG, "Register services after restoring accounts");
// update security profile
SecurityPolicy.getInstance(context).updatePolicies(-1);
// enable/disable other email services as necessary
@@ -110,7 +110,7 @@ public class AccountBackupRestore {
EmailContent.Account fromAccount =
EmailContent.getContent(c, EmailContent.Account.class);
if (Email.DEBUG) {
- Log.v(Email.LOG_TAG, "Backing up account:" + fromAccount.getDisplayName());
+ Log.v(Logging.LOG_TAG, "Backing up account:" + fromAccount.getDisplayName());
}
Account toAccount = LegacyConversions.makeLegacyAccount(context, fromAccount);
@@ -124,12 +124,12 @@ public class AccountBackupRestore {
toAccount.mBackupFlags |= Account.BACKUP_FLAGS_SYNC_CONTACTS;
}
boolean syncCalendar = ContentResolver.getSyncAutomatically(acct,
- Calendar.AUTHORITY);
+ CalendarProviderStub.AUTHORITY);
if (syncCalendar) {
toAccount.mBackupFlags |= Account.BACKUP_FLAGS_SYNC_CALENDAR;
}
boolean syncEmail = ContentResolver.getSyncAutomatically(acct,
- EmailProvider.EMAIL_AUTHORITY);
+ EmailContent.AUTHORITY);
if (!syncEmail) {
toAccount.mBackupFlags |= Account.BACKUP_FLAGS_DONT_SYNC_EMAIL;
}
@@ -178,7 +178,7 @@ public class AccountBackupRestore {
return result;
}
- Log.w(Email.LOG_TAG, "*** Restoring Email Accounts, found " + backups.length);
+ Log.w(Logging.LOG_TAG, "*** Restoring Email Accounts, found " + backups.length);
// 3. Possible lost accounts situation - check for any backups, and restore them
for (Account backupAccount : backups) {
@@ -187,7 +187,7 @@ public class AccountBackupRestore {
continue;
}
// Restore the account
- Log.w(Email.LOG_TAG, "Restoring account:" + backupAccount.getDescription());
+ Log.w(Logging.LOG_TAG, "Restoring account:" + backupAccount.getDescription());
EmailContent.Account toAccount = LegacyConversions.makeAccount(context, backupAccount);
// Mark the default account if this is it
diff --git a/src/com/android/email/AttachmentInfo.java b/src/com/android/email/AttachmentInfo.java
index 6b71160ad..603310724 100644
--- a/src/com/android/email/AttachmentInfo.java
+++ b/src/com/android/email/AttachmentInfo.java
@@ -19,6 +19,7 @@ package com.android.email;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.content.Intent;
@@ -77,15 +78,18 @@ public class AttachmentInfo {
boolean canSave = true;
// Check for acceptable / unacceptable attachments by MIME-type
- if ((!MimeUtility.mimeTypeMatches(mContentType, Email.ACCEPTABLE_ATTACHMENT_VIEW_TYPES)) ||
- (MimeUtility.mimeTypeMatches(mContentType, Email.UNACCEPTABLE_ATTACHMENT_VIEW_TYPES))) {
+ if ((!MimeUtility.mimeTypeMatches(mContentType,
+ AttachmentUtilities.ACCEPTABLE_ATTACHMENT_VIEW_TYPES)) ||
+ (MimeUtility.mimeTypeMatches(mContentType,
+ AttachmentUtilities.UNACCEPTABLE_ATTACHMENT_VIEW_TYPES))) {
canView = false;
}
// Check for unacceptable attachments by filename extension
String extension = AttachmentUtilities.getFilenameExtension(mName);
if (!TextUtils.isEmpty(extension) &&
- Utility.arrayContains(Email.UNACCEPTABLE_ATTACHMENT_EXTENSIONS, extension)) {
+ Utility.arrayContains(AttachmentUtilities.UNACCEPTABLE_ATTACHMENT_EXTENSIONS,
+ extension)) {
canView = false;
canSave = false;
}
@@ -93,7 +97,8 @@ public class AttachmentInfo {
// Check for installable attachments by filename extension
extension = AttachmentUtilities.getFilenameExtension(mName);
if (!TextUtils.isEmpty(extension) &&
- Utility.arrayContains(Email.INSTALLABLE_ATTACHMENT_EXTENSIONS, extension)) {
+ Utility.arrayContains(AttachmentUtilities.INSTALLABLE_ATTACHMENT_EXTENSIONS,
+ extension)) {
int sideloadEnabled;
sideloadEnabled = Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0 /* sideload disabled */);
@@ -103,7 +108,7 @@ public class AttachmentInfo {
// Check for file size exceeded
// The size limit is overridden when on a wifi connection - any size is OK
- if (mSize > Email.MAX_ATTACHMENT_DOWNLOAD_SIZE) {
+ if (mSize > AttachmentUtilities.MAX_ATTACHMENT_DOWNLOAD_SIZE) {
ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo network = cm.getActiveNetworkInfo();
diff --git a/src/com/android/email/Controller.java b/src/com/android/email/Controller.java
index e34b89e57..965bb9979 100644
--- a/src/com/android/email/Controller.java
+++ b/src/com/android/email/Controller.java
@@ -19,6 +19,7 @@ package com.android.email;
import com.android.email.mail.Store;
import com.android.email.mail.store.Pop3Store.Pop3Message;
import com.android.emailcommon.Api;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.AuthenticationFailedException;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Folder.MessageRetrievalListener;
@@ -34,6 +35,7 @@ import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.IEmailService;
import com.android.emailcommon.service.IEmailServiceCallback;
import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import android.app.Service;
import android.content.ContentResolver;
@@ -399,7 +401,7 @@ public class Controller {
ContentValues cv = new ContentValues();
cv.put(MessageColumns.FLAG_LOADED, Message.FLAG_LOADED_COMPLETE);
mProviderContext.getContentResolver().update(uri, cv, null, null);
- Log.d(Email.LOG_TAG, "Unexpected loadMessageForView() for service-based message.");
+ Log.d(Logging.LOG_TAG, "Unexpected loadMessageForView() for service-based message.");
final long accountId = Account.getAccountIdForMessageId(mProviderContext, messageId);
synchronized (mListeners) {
for (Result listener : mListeners) {
@@ -490,7 +492,7 @@ public class Controller {
/* package */ long createMailbox(long accountId, int mailboxType) {
if (accountId < 0 || mailboxType < 0) {
String mes = "Invalid arguments " + accountId + ' ' + mailboxType;
- Log.e(Email.LOG_TAG, mes);
+ Log.e(Logging.LOG_TAG, mes);
throw new RuntimeException(mes);
}
Mailbox box = new Mailbox();
@@ -979,7 +981,7 @@ public class Controller {
Email.setServicesEnabledSync(context);
} catch (Exception e) {
- Log.w(Email.LOG_TAG, "Exception while deleting account", e);
+ Log.w(Logging.LOG_TAG, "Exception while deleting account", e);
} finally {
synchronized (mListeners) {
for (Result l : mListeners) {
@@ -1032,7 +1034,7 @@ public class Controller {
service.deleteAccountPIMData(accountId);
}
} catch (Exception e) {
- Log.w(Email.LOG_TAG, "Exception while deleting account synced data", e);
+ Log.w(Logging.LOG_TAG, "Exception while deleting account synced data", e);
}
}
diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java
index 078e25c88..d38e90f92 100644
--- a/src/com/android/email/Email.java
+++ b/src/com/android/email/Email.java
@@ -20,7 +20,10 @@ import com.android.email.activity.AccountShortcutPicker;
import com.android.email.activity.MessageCompose;
import com.android.email.service.AttachmentDownloadService;
import com.android.email.service.MailService;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.provider.EmailContent;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.Eas;
import android.app.Application;
@@ -29,15 +32,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
-import android.text.format.DateUtils;
import android.util.Log;
-import java.io.File;
-import java.util.HashMap;
-
public class Email extends Application {
- public static final String LOG_TAG = "Email";
-
/**
* If this is enabled there will be additional logging information sent to
* Log.d, including protocol dumps.
@@ -75,76 +72,6 @@ public class Email extends Application {
*/
public static boolean sDebugInhibitGraphicsAcceleration = false;
- /**
- * The MIME type(s) of attachments we're willing to send via attachments.
- *
- * Any attachments may be added via Intents with Intent.ACTION_SEND or ACTION_SEND_MULTIPLE.
- */
- public static final String[] ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES = new String[] {
- "*/*",
- };
-
- /**
- * The MIME type(s) of attachments we're willing to send from the internal UI.
- *
- * NOTE: At the moment it is not possible to open a chooser with a list of filter types, so
- * the chooser is only opened with the first item in the list.
- */
- public static final String[] ACCEPTABLE_ATTACHMENT_SEND_UI_TYPES = new String[] {
- "image/*",
- "video/*",
- };
-
- /**
- * The MIME type(s) of attachments we're willing to view.
- */
- public static final String[] ACCEPTABLE_ATTACHMENT_VIEW_TYPES = new String[] {
- "*/*",
- };
-
- /**
- * The MIME type(s) of attachments we're not willing to view.
- */
- public static final String[] UNACCEPTABLE_ATTACHMENT_VIEW_TYPES = new String[] {
- };
-
- /**
- * The MIME type(s) of attachments we're willing to download to SD.
- */
- public static final String[] ACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES = new String[] {
- "*/*",
- };
-
- /**
- * The MIME type(s) of attachments we're not willing to download to SD.
- */
- public static final String[] UNACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES = new String[] {
- };
-
- /**
- * Filename extensions of attachments we're never willing to download (potential malware).
- * Entries in this list are compared to the end of the lower-cased filename, so they must
- * be lower case, and should not include a "."
- */
- public static final String[] UNACCEPTABLE_ATTACHMENT_EXTENSIONS = new String[] {
- // File types that contain malware
- "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "dll", "exe",
- "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
- "mst", "pif", "scr", "sct", "shb", "sys", "vb", "vbe",
- "vbs", "vxd", "wsc", "wsf", "wsh",
- // File types of common compression/container formats (again, to avoid malware)
- "zip", "gz", "z", "tar", "tgz", "bz2",
- };
-
- /**
- * Filename extensions of attachments that can be installed.
- * Entries in this list are compared to the end of the lower-cased filename, so they must
- * be lower case, and should not include a "."
- */
- public static final String[] INSTALLABLE_ATTACHMENT_EXTENSIONS = new String[] {
- "apk",
- };
-
/**
* Specifies how many messages will be shown in a folder by default. This number is set
* on each new folder and can be incremented with "Load more messages..." by the
@@ -157,22 +84,6 @@ public class Email extends Application {
*/
public static final int VISIBLE_LIMIT_INCREMENT = 25;
- /**
- * The maximum size of an attachment we're willing to download (either View or Save)
- * Attachments that are base64 encoded (most) will be about 1.375x their actual size
- * so we should probably factor that in. A 5MB attachment will generally be around
- * 6.8MB downloaded but only 5MB saved.
- */
- public static final int MAX_ATTACHMENT_DOWNLOAD_SIZE = (5 * 1024 * 1024);
-
- /**
- * The maximum size of an attachment we're willing to upload (measured as stored on disk).
- * Attachments that are base64 encoded (most) will be about 1.375x their actual size
- * so we should probably factor that in. A 5MB attachment will generally be around
- * 6.8MB uploaded.
- */
- public static final int MAX_ATTACHMENT_UPLOAD_SIZE = (5 * 1024 * 1024);
-
/**
* This is used to force stacked UI to return to the "welcome" screen any time we change
* the accounts list (e.g. deleting accounts in the Account Manager preferences.)
@@ -182,25 +93,10 @@ public class Email extends Application {
public static final String EXCHANGE_ACCOUNT_MANAGER_TYPE = "com.android.exchange";
public static final String POP_IMAP_ACCOUNT_MANAGER_TYPE = "com.android.email";
- private static File sTempDirectory;
-
private static String sMessageDecodeErrorString;
private static Thread sUiThread;
- public static void setTempDirectory(Context context) {
- sTempDirectory = context.getCacheDir();
- }
-
- public static File getTempDirectory() {
- if (sTempDirectory == null) {
- throw new RuntimeException(
- "TempDirectory not set. " +
- "If in a unit test, call Email.setTempDirectory(context) in setUp().");
- }
- return sTempDirectory;
- }
-
/**
* Asynchronous version of {@link #setServicesEnabledSync(Context)}. Use when calling from
* UI thread (or lifecycle entry points.)
@@ -299,7 +195,7 @@ public class Email extends Application {
Preferences prefs = Preferences.getPreferences(this);
DEBUG = prefs.getEnableDebugLogging();
sDebugInhibitGraphicsAcceleration = prefs.getInhibitGraphicsAcceleration();
- setTempDirectory(this);
+ TempDirectory.setTempDirectory(this);
// Tie MailRefreshManager to the Controller.
RefreshManager.getInstance(this);
@@ -332,7 +228,7 @@ public class Email extends Application {
* The calls to log() must be guarded with "if (Email.LOGD)" for performance reasons.
*/
public static void log(String message) {
- Log.d(LOG_TAG, message);
+ Log.d(Logging.LOG_TAG, message);
}
/**
@@ -354,7 +250,7 @@ public class Email extends Application {
public static void warnIfUiThread() {
if (Thread.currentThread().equals(sUiThread)) {
- Log.w(Email.LOG_TAG, "Method called on the UI thread", new Exception("STACK TRACE"));
+ Log.w(Logging.LOG_TAG, "Method called on the UI thread", new Exception("STACK TRACE"));
}
}
diff --git a/src/com/android/email/FolderProperties.java b/src/com/android/email/FolderProperties.java
new file mode 100644
index 000000000..88abff6ca
--- /dev/null
+++ b/src/com/android/email/FolderProperties.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.email;
+
+import com.android.emailcommon.provider.EmailContent.Mailbox;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+
+
+// TODO When the UI is settled, cache all strings/drawables
+// TODO When the UI is settled, write up tests
+// TODO When the UI is settled, remove backward-compatibility methods
+public class FolderProperties {
+
+ private static FolderProperties sInstance;
+
+ private final Context mContext;
+
+ // Caches for frequently accessed resources.
+ private final String[] mSpecialMailbox;
+ private final TypedArray mSpecialMailboxDrawable;
+ private final Drawable mSummaryStarredMailboxDrawable;
+ private final Drawable mSummaryCombinedInboxDrawable;
+
+ private FolderProperties(Context context) {
+ mContext = context.getApplicationContext();
+ mSpecialMailbox = context.getResources().getStringArray(R.array.mailbox_display_names);
+ for (int i = 0; i < mSpecialMailbox.length; ++i) {
+ if ("".equals(mSpecialMailbox[i])) {
+ // there is no localized name, so use the display name from the server
+ mSpecialMailbox[i] = null;
+ }
+ }
+ mSpecialMailboxDrawable =
+ context.getResources().obtainTypedArray(R.array.mailbox_display_icons);
+ mSummaryStarredMailboxDrawable =
+ context.getResources().getDrawable(R.drawable.ic_folder_star_holo_light);
+ mSummaryCombinedInboxDrawable =
+ context.getResources().getDrawable(R.drawable.ic_list_combined_inbox);
+ }
+
+ public static synchronized FolderProperties getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new FolderProperties(context);
+ }
+ return sInstance;
+ }
+
+ // For backward compatibility.
+ public String getDisplayName(int type) {
+ return getDisplayName(type, -1);
+ }
+
+ // For backward compatibility.
+ public Drawable getSummaryMailboxIconIds(long id) {
+ return getIcon(-1, id);
+ }
+
+ /**
+ * Lookup names of localized special mailboxes
+ */
+ public String getDisplayName(int type, long mailboxId) {
+ // Special combined mailboxes
+ int resId = 0;
+
+ // Can't use long for switch!?
+ if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
+ resId = R.string.account_folder_list_summary_inbox;
+ } else if (mailboxId == Mailbox.QUERY_ALL_FAVORITES) {
+ resId = R.string.account_folder_list_summary_starred;
+ } else if (mailboxId == Mailbox.QUERY_ALL_DRAFTS) {
+ resId = R.string.account_folder_list_summary_drafts;
+ } else if (mailboxId == Mailbox.QUERY_ALL_OUTBOX) {
+ resId = R.string.account_folder_list_summary_outbox;
+ }
+ if (resId != 0) {
+ return mContext.getString(resId);
+ }
+
+ if (type < mSpecialMailbox.length) {
+ return mSpecialMailbox[type];
+ }
+ return null;
+ }
+
+ /**
+ * Lookup icons of special mailboxes
+ */
+ public Drawable getIcon(int type, long mailboxId) {
+ if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
+ return mSummaryCombinedInboxDrawable;
+ } else if (mailboxId == Mailbox.QUERY_ALL_FAVORITES) {
+ return mSummaryStarredMailboxDrawable;
+ } else if (mailboxId == Mailbox.QUERY_ALL_DRAFTS) {
+ return mSpecialMailboxDrawable.getDrawable(Mailbox.TYPE_DRAFTS);
+ } else if (mailboxId == Mailbox.QUERY_ALL_OUTBOX) {
+ return mSpecialMailboxDrawable.getDrawable(Mailbox.TYPE_OUTBOX);
+ }
+ if (0 <= type && type < mSpecialMailboxDrawable.length()) {
+ final int resId = mSpecialMailboxDrawable.getResourceId(type, -1);
+ if (resId != -1) {
+ return mContext.getResources().getDrawable(resId);
+ }
+ }
+ return null; // No icon
+ }
+}
+
diff --git a/src/com/android/email/LegacyConversions.java b/src/com/android/email/LegacyConversions.java
index f771b9626..e9acd4c33 100644
--- a/src/com/android/email/LegacyConversions.java
+++ b/src/com/android/email/LegacyConversions.java
@@ -16,6 +16,7 @@
package com.android.email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeBodyPart;
import com.android.emailcommon.internet.MimeHeader;
import com.android.emailcommon.internet.MimeMessage;
@@ -219,7 +220,7 @@ public class LegacyConversions {
localAttachment.mAccountKey = localMessage.mAccountKey;
if (DEBUG_ATTACHMENTS) {
- Log.d(Email.LOG_TAG, "Add attachment " + localAttachment);
+ Log.d(Logging.LOG_TAG, "Add attachment " + localAttachment);
}
// To prevent duplication - do we already have a matching attachment?
@@ -245,7 +246,7 @@ public class LegacyConversions {
attachmentFoundInDb = true;
localAttachment.mId = dbAttachment.mId;
if (DEBUG_ATTACHMENTS) {
- Log.d(Email.LOG_TAG, "Skipped, found db attachment " + dbAttachment);
+ Log.d(Logging.LOG_TAG, "Skipped, found db attachment " + dbAttachment);
}
break;
}
@@ -355,14 +356,14 @@ public class LegacyConversions {
addTextBodyPart(mp, "text/html", null,
EmailContent.Body.restoreBodyHtmlWithMessageId(context, localMessage.mId));
} catch (RuntimeException rte) {
- Log.d(Email.LOG_TAG, "Exception while reading html body " + rte.toString());
+ Log.d(Logging.LOG_TAG, "Exception while reading html body " + rte.toString());
}
try {
addTextBodyPart(mp, "text/plain", null,
EmailContent.Body.restoreBodyTextWithMessageId(context, localMessage.mId));
} catch (RuntimeException rte) {
- Log.d(Email.LOG_TAG, "Exception while reading text body " + rte.toString());
+ Log.d(Logging.LOG_TAG, "Exception while reading text body " + rte.toString());
}
boolean isReply = (localMessage.mFlags & EmailContent.Message.FLAG_TYPE_REPLY) != 0;
@@ -376,7 +377,7 @@ public class LegacyConversions {
addTextBodyPart(mp, "text/plain", BODY_QUOTED_PART_INTRO,
EmailContent.Body.restoreIntroTextWithMessageId(context, localMessage.mId));
} catch (RuntimeException rte) {
- Log.d(Email.LOG_TAG, "Exception while reading text reply " + rte.toString());
+ Log.d(Logging.LOG_TAG, "Exception while reading text reply " + rte.toString());
}
String replyTag = isReply ? BODY_QUOTED_PART_REPLY : BODY_QUOTED_PART_FORWARD;
@@ -384,14 +385,14 @@ public class LegacyConversions {
addTextBodyPart(mp, "text/html", replyTag,
EmailContent.Body.restoreReplyHtmlWithMessageId(context, localMessage.mId));
} catch (RuntimeException rte) {
- Log.d(Email.LOG_TAG, "Exception while reading html reply " + rte.toString());
+ Log.d(Logging.LOG_TAG, "Exception while reading html reply " + rte.toString());
}
try {
addTextBodyPart(mp, "text/plain", replyTag,
EmailContent.Body.restoreReplyTextWithMessageId(context, localMessage.mId));
} catch (RuntimeException rte) {
- Log.d(Email.LOG_TAG, "Exception while reading text reply " + rte.toString());
+ Log.d(Logging.LOG_TAG, "Exception while reading text reply " + rte.toString());
}
}
diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java
index 8a0120d16..4c5687970 100644
--- a/src/com/android/email/MessagingController.java
+++ b/src/com/android/email/MessagingController.java
@@ -19,6 +19,7 @@ package com.android.email;
import com.android.email.mail.Sender;
import com.android.email.mail.Store;
import com.android.email.mail.StoreSynchronizer;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeBodyPart;
import com.android.emailcommon.internet.MimeHeader;
import com.android.emailcommon.internet.MimeMultipart;
@@ -42,6 +43,7 @@ import com.android.emailcommon.provider.EmailContent.MessageColumns;
import com.android.emailcommon.provider.EmailContent.SyncColumns;
import com.android.emailcommon.utility.AttachmentUtilities;
import com.android.emailcommon.utility.ConversionUtilities;
+import com.android.emailcommon.utility.Utility;
import android.content.ContentResolver;
import android.content.ContentUris;
@@ -400,7 +402,7 @@ public class MessagingController implements Runnable {
nc.cancelLoginFailedNotification(account.mId);
} catch (MessagingException e) {
if (Email.LOGD) {
- Log.v(Email.LOG_TAG, "synchronizeMailbox", e);
+ Log.v(Logging.LOG_TAG, "synchronizeMailbox", e);
}
if (e instanceof AuthenticationFailedException) {
// Generate authentication notification
@@ -467,7 +469,7 @@ public class MessagingController implements Runnable {
final EmailContent.Account account, final EmailContent.Mailbox folder)
throws MessagingException {
- Log.d(Email.LOG_TAG, "*** synchronizeMailboxGeneric ***");
+ Log.d(Logging.LOG_TAG, "*** synchronizeMailboxGeneric ***");
ContentResolver resolver = mContext.getContentResolver();
// 0. We do not ever sync DRAFTS or OUTBOX (down or up)
@@ -640,14 +642,14 @@ public class MessagingController implements Runnable {
newMessages.add(message);
}
} catch (MessagingException me) {
- Log.e(Email.LOG_TAG,
+ Log.e(Logging.LOG_TAG,
"Error while copying downloaded message." + me);
}
}
}
catch (Exception e) {
- Log.e(Email.LOG_TAG,
+ Log.e(Logging.LOG_TAG,
"Error while storing downloaded message." + e.toString());
}
}
@@ -1027,13 +1029,13 @@ public class MessagingController implements Runnable {
context.getContentResolver().update(uri, cv, null, null);
} catch (MessagingException me) {
- Log.e(Email.LOG_TAG, "Error while copying downloaded message." + me);
+ Log.e(Logging.LOG_TAG, "Error while copying downloaded message." + me);
}
} catch (RuntimeException rte) {
- Log.e(Email.LOG_TAG, "Error while storing downloaded message." + rte.toString());
+ Log.e(Logging.LOG_TAG, "Error while storing downloaded message." + rte.toString());
} catch (IOException ioe) {
- Log.e(Email.LOG_TAG, "Error while storing attachment." + ioe.toString());
+ Log.e(Logging.LOG_TAG, "Error while storing attachment." + ioe.toString());
}
}
@@ -1050,7 +1052,7 @@ public class MessagingController implements Runnable {
}
catch (MessagingException me) {
if (Email.LOGD) {
- Log.v(Email.LOG_TAG, "processPendingActions", me);
+ Log.v(Logging.LOG_TAG, "processPendingActions", me);
}
/*
* Ignore any exceptions from the commands. Commands will be processed
@@ -1150,7 +1152,7 @@ public class MessagingController implements Runnable {
// Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Unable to process pending delete for id="
+ Log.d(Logging.LOG_TAG, "Unable to process pending delete for id="
+ lastMessageId + ": " + me);
}
} finally {
@@ -1257,7 +1259,7 @@ public class MessagingController implements Runnable {
// Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Unable to process pending upsync for id="
+ Log.d(Logging.LOG_TAG, "Unable to process pending upsync for id="
+ lastMessageId + ": " + me);
}
} finally {
@@ -1343,7 +1345,7 @@ public class MessagingController implements Runnable {
// Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Unable to process pending update for id="
+ Log.d(Logging.LOG_TAG, "Unable to process pending update for id="
+ lastMessageId + ": " + me);
}
} finally {
@@ -1377,18 +1379,18 @@ public class MessagingController implements Runnable {
boolean deleteUpdate = false;
if (message == null) {
deleteUpdate = true;
- Log.d(Email.LOG_TAG, "Upsync failed for null message, id=" + messageId);
+ Log.d(Logging.LOG_TAG, "Upsync failed for null message, id=" + messageId);
} else if (mailbox.mType == Mailbox.TYPE_DRAFTS) {
deleteUpdate = false;
- Log.d(Email.LOG_TAG, "Upsync skipped for mailbox=drafts, id=" + messageId);
+ Log.d(Logging.LOG_TAG, "Upsync skipped for mailbox=drafts, id=" + messageId);
} else if (mailbox.mType == Mailbox.TYPE_OUTBOX) {
deleteUpdate = false;
- Log.d(Email.LOG_TAG, "Upsync skipped for mailbox=outbox, id=" + messageId);
+ Log.d(Logging.LOG_TAG, "Upsync skipped for mailbox=outbox, id=" + messageId);
} else if (mailbox.mType == Mailbox.TYPE_TRASH) {
deleteUpdate = false;
- Log.d(Email.LOG_TAG, "Upsync skipped for mailbox=trash, id=" + messageId);
+ Log.d(Logging.LOG_TAG, "Upsync skipped for mailbox=trash, id=" + messageId);
} else {
- Log.d(Email.LOG_TAG, "Upsyc triggered for message id=" + messageId);
+ Log.d(Logging.LOG_TAG, "Upsyc triggered for message id=" + messageId);
deleteUpdate = processPendingAppend(remoteStore, account, mailbox, message);
}
if (deleteUpdate) {
@@ -1453,7 +1455,7 @@ public class MessagingController implements Runnable {
return;
}
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG,
+ Log.d(Logging.LOG_TAG,
"Update for msg id=" + newMessage.mId
+ " read=" + newMessage.mFlagRead
+ " flagged=" + newMessage.mFlagFavorite
@@ -1854,7 +1856,7 @@ public class MessagingController implements Runnable {
mListeners.loadMessageForViewFinished(messageId);
} catch (MessagingException me) {
- if (Email.LOGD) Log.v(Email.LOG_TAG, "", me);
+ if (Email.LOGD) Log.v(Logging.LOG_TAG, "", me);
mListeners.loadMessageForViewFailed(messageId, me.getMessage());
} catch (RuntimeException rte) {
mListeners.loadMessageForViewFailed(messageId, rte.getMessage());
@@ -1956,11 +1958,11 @@ public class MessagingController implements Runnable {
mListeners.loadAttachmentFinished(accountId, messageId, attachmentId);
}
catch (MessagingException me) {
- if (Email.LOGD) Log.v(Email.LOG_TAG, "", me);
+ if (Email.LOGD) Log.v(Logging.LOG_TAG, "", me);
mListeners.loadAttachmentFailed(
accountId, messageId, attachmentId, me, background);
} catch (IOException ioe) {
- Log.e(Email.LOG_TAG, "Error while storing attachment." + ioe.toString());
+ Log.e(Logging.LOG_TAG, "Error while storing attachment." + ioe.toString());
}
}});
}
@@ -2024,7 +2026,7 @@ public class MessagingController implements Runnable {
// Don't send messages with unloaded attachments
if (Utility.hasUnloadedAttachments(mContext, messageId)) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Can't send #" + messageId +
+ Log.d(Logging.LOG_TAG, "Can't send #" + messageId +
"; unloaded attachments");
}
continue;
diff --git a/src/com/android/email/MessagingExceptionStrings.java b/src/com/android/email/MessagingExceptionStrings.java
new file mode 100644
index 000000000..481f5d4f8
--- /dev/null
+++ b/src/com/android/email/MessagingExceptionStrings.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.email;
+
+import com.android.emailcommon.mail.MessagingException;
+
+import android.content.Context;
+
+/**
+ * @return the error message associated with this exception.
+ */
+public class MessagingExceptionStrings {
+ public static String getErrorString(Context context, MessagingException e) {
+ return context.getResources().getString(getErrorStringResourceId(e));
+ }
+
+ /**
+ * @return the resource ID of the error message associated with this exception.
+ */
+ private static int getErrorStringResourceId(MessagingException e) {
+ switch (e.getExceptionType()) {
+ case MessagingException.IOERROR:
+ return R.string.account_setup_failed_ioerror;
+ case MessagingException.TLS_REQUIRED:
+ return R.string.account_setup_failed_tls_required;
+ case MessagingException.AUTH_REQUIRED:
+ return R.string.account_setup_failed_auth_required;
+ case MessagingException.GENERAL_SECURITY:
+ return R.string.account_setup_failed_security;
+ // TODO Generate a unique string for this case, which is the case
+ // where the security policy needs to be updated.
+ case MessagingException.SECURITY_POLICIES_REQUIRED:
+ return R.string.account_setup_failed_security;
+ }
+ return R.string.status_network_error; // default
+ }
+}
diff --git a/src/com/android/email/NotificationController.java b/src/com/android/email/NotificationController.java
index 61c2ab879..406ed850b 100644
--- a/src/com/android/email/NotificationController.java
+++ b/src/com/android/email/NotificationController.java
@@ -24,6 +24,7 @@ import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.app.Notification;
import android.app.Notification.Builder;
diff --git a/src/com/android/email/Preferences.java b/src/com/android/email/Preferences.java
index 485b31e25..942b8c851 100644
--- a/src/com/android/email/Preferences.java
+++ b/src/com/android/email/Preferences.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.Logging;
+
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
@@ -248,7 +250,7 @@ public class Preferences {
public void dump() {
if (Email.LOGD) {
for (String key : mSharedPreferences.getAll().keySet()) {
- Log.v(Email.LOG_TAG, key + " = " + mSharedPreferences.getAll().get(key));
+ Log.v(Logging.LOG_TAG, key + " = " + mSharedPreferences.getAll().get(key));
}
}
}
diff --git a/src/com/android/email/RefreshManager.java b/src/com/android/email/RefreshManager.java
index 1541c6392..3f20d9d9e 100644
--- a/src/com/android/email/RefreshManager.java
+++ b/src/com/android/email/RefreshManager.java
@@ -16,7 +16,9 @@
package com.android.email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.os.Handler;
@@ -212,7 +214,7 @@ public class RefreshManager {
if (!status.canRefresh()) return false;
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "refreshMailboxList " + accountId);
+ Log.d(Logging.LOG_TAG, "refreshMailboxList " + accountId);
}
status.onRefreshRequested();
notifyRefreshStatusChanged(accountId, -1);
@@ -250,7 +252,7 @@ public class RefreshManager {
if (!status.canRefresh()) return false;
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "refreshMessageList " + accountId + ", " + mailboxId + ", "
+ Log.d(Logging.LOG_TAG, "refreshMessageList " + accountId + ", " + mailboxId + ", "
+ loadMoreMessages);
}
status.onRefreshRequested();
@@ -268,7 +270,7 @@ public class RefreshManager {
*/
public boolean sendPendingMessages(long accountId) {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "sendPendingMessages " + accountId);
+ Log.d(Logging.LOG_TAG, "sendPendingMessages " + accountId);
}
notifyRefreshStatusChanged(accountId, -1);
mController.sendPendingMessages(accountId);
@@ -280,7 +282,7 @@ public class RefreshManager {
*/
public void sendPendingMessagesForAllAccounts() {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "sendPendingMessagesForAllAccounts");
+ Log.d(Logging.LOG_TAG, "sendPendingMessagesForAllAccounts");
}
new SendPendingMessagesForAllAccountsImpl().execute();
}
@@ -356,7 +358,7 @@ public class RefreshManager {
if (exception == null) {
return "(no exception)";
} else {
- return exception.getUiErrorMessage(mContext);
+ return MessagingExceptionStrings.getErrorString(mContext, exception);
}
}
@@ -367,12 +369,13 @@ public class RefreshManager {
public void updateMailboxListCallback(MessagingException exception, long accountId,
int progress) {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "updateMailboxListCallback " + accountId + ", " + progress
+ Log.d(Logging.LOG_TAG, "updateMailboxListCallback " + accountId + ", " + progress
+ ", " + exceptionToString(exception));
}
mMailboxListStatus.get(accountId).onCallback(exception, progress, mClock);
if (exception != null) {
- reportError(accountId, -1, exception.getUiErrorMessage(mContext));
+ reportError(accountId, -1,
+ MessagingExceptionStrings.getErrorString(mContext, exception));
}
notifyRefreshStatusChanged(accountId, -1);
}
@@ -384,7 +387,7 @@ public class RefreshManager {
public void updateMailboxCallback(MessagingException exception, long accountId,
long mailboxId, int progress, int dontUseNumNewMessages) {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "updateMailboxCallback " + accountId + ", "
+ Log.d(Logging.LOG_TAG, "updateMailboxCallback " + accountId + ", "
+ mailboxId + ", " + progress + ", " + exceptionToString(exception));
}
updateMailboxCallbackInternal(exception, accountId, mailboxId, progress, 0);
@@ -403,7 +406,7 @@ public class RefreshManager {
MessagingException exception, long accountId, long mailboxId, int progress,
long tag) {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "serviceCheckMailCallback " + accountId + ", "
+ Log.d(Logging.LOG_TAG, "serviceCheckMailCallback " + accountId + ", "
+ mailboxId + ", " + progress + ", " + exceptionToString(exception));
}
updateMailboxCallbackInternal(exception, accountId, mailboxId, progress, 0);
@@ -414,7 +417,8 @@ public class RefreshManager {
// Don't use dontUseNumNewMessages. serviceCheckMailCallback() don't set it.
mMessageListStatus.get(mailboxId).onCallback(exception, progress, mClock);
if (exception != null) {
- reportError(accountId, mailboxId, exception.getUiErrorMessage(mContext));
+ reportError(accountId, mailboxId,
+ MessagingExceptionStrings.getErrorString(mContext, exception));
}
notifyRefreshStatusChanged(accountId, mailboxId);
}
@@ -430,7 +434,7 @@ public class RefreshManager {
public void sendMailCallback(MessagingException exception, long accountId, long messageId,
int progress) {
if (LOG_ENABLED) {
- Log.d(Email.LOG_TAG, "sendMailCallback " + accountId + ", "
+ Log.d(Logging.LOG_TAG, "sendMailCallback " + accountId + ", "
+ messageId + ", " + progress + ", " + exceptionToString(exception));
}
if (progress == 0 && messageId == -1) {
@@ -439,7 +443,8 @@ public class RefreshManager {
if (exception != null && !mSendMailExceptionReported) {
// Only the first error in a batch will be reported.
mSendMailExceptionReported = true;
- reportError(accountId, messageId, exception.getUiErrorMessage(mContext));
+ reportError(accountId, messageId,
+ MessagingExceptionStrings.getErrorString(mContext, exception));
}
if (progress == 100) {
mSendMailExceptionReported = false;
diff --git a/src/com/android/email/SecurityPolicy.java b/src/com/android/email/SecurityPolicy.java
index d8639f0bf..f49f3dd4d 100644
--- a/src/com/android/email/SecurityPolicy.java
+++ b/src/com/android/email/SecurityPolicy.java
@@ -18,6 +18,7 @@ package com.android.email;
import com.android.email.activity.setup.AccountSecurity;
import com.android.email.service.EmailBroadcastProcessorService;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
@@ -491,7 +492,7 @@ public class SecurityPolicy {
if (dpm.isAdminActive(mAdminName)) {
dpm.wipeData(0);
} else {
- Log.d(Email.LOG_TAG, "Could not remote wipe because not device admin.");
+ Log.d(Logging.LOG_TAG, "Could not remote wipe because not device admin.");
}
}
/**
diff --git a/src/com/android/email/SingleRunningTask.java b/src/com/android/email/SingleRunningTask.java
index f0215faf7..ae628a049 100644
--- a/src/com/android/email/SingleRunningTask.java
+++ b/src/com/android/email/SingleRunningTask.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.Logging;
+
import android.util.Log;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -39,16 +41,16 @@ public abstract class SingleRunningTask {
*/
public final void run(Param param) {
if (mIsRunning.compareAndSet(false, true)) {
- Log.i(Email.LOG_TAG, mLogTaskName + ": start");
+ Log.i(Logging.LOG_TAG, mLogTaskName + ": start");
try {
runInternal(param);
} finally {
- Log.i(Email.LOG_TAG, mLogTaskName + ": done");
+ Log.i(Logging.LOG_TAG, mLogTaskName + ": done");
mIsRunning.set(false);
}
} else {
// Already running -- do nothing.
- Log.i(Email.LOG_TAG, mLogTaskName + ": already running");
+ Log.i(Logging.LOG_TAG, mLogTaskName + ": already running");
}
}
diff --git a/src/com/android/email/StopWatch.java b/src/com/android/email/StopWatch.java
index 410a97862..20088b751 100644
--- a/src/com/android/email/StopWatch.java
+++ b/src/com/android/email/StopWatch.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.Logging;
+
import android.os.SystemClock;
import android.util.Log;
@@ -41,7 +43,7 @@ public class StopWatch {
mName = name;
mStart = getCurrentTime();
mLastSplit = mStart;
- Log.w(Email.LOG_TAG, "StopWatch(" + mName + ") start");
+ Log.w(Logging.LOG_TAG, "StopWatch(" + mName + ") start");
}
public static StopWatch start(String name) {
@@ -51,14 +53,14 @@ public class StopWatch {
public void split(String label) {
long now = getCurrentTime() ;
long elapse = now - mLastSplit;
- Log.w(Email.LOG_TAG, "StopWatch(" + mName + ") split(" + label + ") " + elapse);
+ Log.w(Logging.LOG_TAG, "StopWatch(" + mName + ") split(" + label + ") " + elapse);
mLastSplit = now;
}
public void stop() {
long now = getCurrentTime();
long elapse = now - mLastSplit;
- Log.w(Email.LOG_TAG, "StopWatch(" + mName + ") stop: "
+ Log.w(Logging.LOG_TAG, "StopWatch(" + mName + ") stop: "
+ (now - mLastSplit)
+ " (total " + (now - mStart) + ")");
}
diff --git a/src/com/android/email/Throttle.java b/src/com/android/email/Throttle.java
index 5b0a1eca6..41e22e1b9 100644
--- a/src/com/android/email/Throttle.java
+++ b/src/com/android/email/Throttle.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.Logging;
+
import android.os.Handler;
import android.util.Log;
@@ -95,7 +97,7 @@ public class Throttle {
}
private void debugLog(String message) {
- Log.d(Email.LOG_TAG, "Throttle: [" + mName + "] " + message);
+ Log.d(Logging.LOG_TAG, "Throttle: [" + mName + "] " + message);
}
private boolean isCallbackScheduled() {
diff --git a/src/com/android/email/UiUtilities.java b/src/com/android/email/UiUtilities.java
new file mode 100644
index 000000000..79ac4bbb5
--- /dev/null
+++ b/src/com/android/email/UiUtilities.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.email;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+public class UiUtilities {
+
+ /**
+ * Formats the given size as a String in bytes, kB, MB or GB. Ex: 12,315,000 = 11 MB
+ */
+ public static String formatSize(Context context, long size) {
+ final Resources res = context.getResources();
+ final long KB = 1024;
+ final long MB = (KB * 1024);
+ final long GB = (MB * 1024);
+
+ int resId;
+ int value;
+
+ if (size < KB) {
+ resId = R.plurals.message_view_attachment_bytes;
+ value = (int) size;
+ } else if (size < MB) {
+ resId = R.plurals.message_view_attachment_kilobytes;
+ value = (int) (size / KB);
+ } else if (size < GB) {
+ resId = R.plurals.message_view_attachment_megabytes;
+ value = (int) (size / MB);
+ } else {
+ resId = R.plurals.message_view_attachment_gigabytes;
+ value = (int) (size / GB);
+ }
+ return res.getQuantityString(resId, value, value);
+ }
+
+ public static String getMessageCountForUi(Context context, int count,
+ boolean replaceZeroWithBlank) {
+ if (replaceZeroWithBlank && (count == 0)) {
+ return "";
+ } else if (count > 999) {
+ return context.getString(R.string.more_than_999);
+ } else {
+ return Integer.toString(count);
+ }
+ }
+}
diff --git a/src/com/android/email/VendorPolicyLoader.java b/src/com/android/email/VendorPolicyLoader.java
index a95921f29..a608015d5 100644
--- a/src/com/android/email/VendorPolicyLoader.java
+++ b/src/com/android/email/VendorPolicyLoader.java
@@ -17,6 +17,7 @@
package com.android.email;
import com.android.email.activity.setup.AccountSettingsUtils.Provider;
+import com.android.emailcommon.Logging;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -78,7 +79,7 @@ public class VendorPolicyLoader {
*/
public static void injectPolicyForTest(Context context, String apkPackageName, Class> clazz) {
String name = clazz.getName();
- Log.d(Email.LOG_TAG, String.format("Using policy: package=%s name=%s",
+ Log.d(Logging.LOG_TAG, String.format("Using policy: package=%s name=%s",
apkPackageName, name));
sInstance = new VendorPolicyLoader(context, apkPackageName, name, true);
}
@@ -120,10 +121,10 @@ public class VendorPolicyLoader {
// Package not found -- it's okay - there's no policy .apk found, which is OK
} catch (ClassNotFoundException e) {
// Class not found -- probably not OK, but let's not crash here
- Log.w(Email.LOG_TAG, "VendorPolicyLoader: " + e);
+ Log.w(Logging.LOG_TAG, "VendorPolicyLoader: " + e);
} catch (NoSuchMethodException e) {
// Method not found -- probably not OK, but let's not crash here
- Log.w(Email.LOG_TAG, "VendorPolicyLoader: " + e);
+ Log.w(Logging.LOG_TAG, "VendorPolicyLoader: " + e);
}
mPolicyMethod = method;
}
@@ -150,7 +151,7 @@ public class VendorPolicyLoader {
try {
ret = (Bundle) mPolicyMethod.invoke(null, policy, args);
} catch (Exception e) {
- Log.w(Email.LOG_TAG, "VendorPolicyLoader", e);
+ Log.w(Logging.LOG_TAG, "VendorPolicyLoader", e);
}
}
return (ret != null) ? ret : Bundle.EMPTY;
@@ -230,7 +231,7 @@ public class VendorPolicyLoader {
p.note = out.getString(FIND_PROVIDER_NOTE);
return p;
} catch (URISyntaxException e) {
- Log.d(Email.LOG_TAG, "uri exception while vendor policy loads " + domain);
+ Log.d(Logging.LOG_TAG, "uri exception while vendor policy loads " + domain);
}
}
return null;
diff --git a/src/com/android/email/activity/AccountFolderListFragment.java b/src/com/android/email/activity/AccountFolderListFragment.java
index 5c15770cf..79537f19e 100644
--- a/src/com/android/email/activity/AccountFolderListFragment.java
+++ b/src/com/android/email/activity/AccountFolderListFragment.java
@@ -19,7 +19,6 @@ package com.android.email.activity;
import com.android.email.Controller;
import com.android.email.ControllerResultUiThreadWrapper;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -27,6 +26,7 @@ import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.ListFragment;
diff --git a/src/com/android/email/activity/AccountSelectorAdapter.java b/src/com/android/email/activity/AccountSelectorAdapter.java
index af556ec1e..7d95efb9d 100644
--- a/src/com/android/email/activity/AccountSelectorAdapter.java
+++ b/src/com/android/email/activity/AccountSelectorAdapter.java
@@ -17,12 +17,12 @@
package com.android.email.activity;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.data.ClosingMatrixCursor;
import com.android.email.data.ThrottlingCursorLoader;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.content.Loader;
diff --git a/src/com/android/email/activity/AccountShortcutPicker.java b/src/com/android/email/activity/AccountShortcutPicker.java
index 023778749..2e422d8ce 100644
--- a/src/com/android/email/activity/AccountShortcutPicker.java
+++ b/src/com/android/email/activity/AccountShortcutPicker.java
@@ -17,9 +17,9 @@
package com.android.email.activity;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
+import com.android.emailcommon.utility.Utility;
import android.app.ListActivity;
import android.content.Intent;
diff --git a/src/com/android/email/activity/AccountsAdapter.java b/src/com/android/email/activity/AccountsAdapter.java
index 75df992c7..05a4afe9e 100644
--- a/src/com/android/email/activity/AccountsAdapter.java
+++ b/src/com/android/email/activity/AccountsAdapter.java
@@ -16,9 +16,8 @@
package com.android.email.activity;
-import com.android.email.Email;
+import com.android.email.FolderProperties;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
@@ -207,7 +206,7 @@ public class AccountsAdapter extends CursorAdapter {
view.findViewById(R.id.default_sender).setVisibility(View.GONE);
view.findViewById(R.id.folder_icon).setVisibility(View.VISIBLE);
((ImageView)view.findViewById(R.id.folder_icon)).setImageDrawable(
- Utility.FolderProperties.getInstance(context).getSummaryMailboxIconIds(id));
+ FolderProperties.getInstance(context).getSummaryMailboxIconIds(id));
}
private void bindAccountItem(View view, Context context, Cursor cursor, boolean isExpanded)
diff --git a/src/com/android/email/activity/ActivityHelper.java b/src/com/android/email/activity/ActivityHelper.java
index 419de33d8..d5909854d 100644
--- a/src/com/android/email/activity/ActivityHelper.java
+++ b/src/com/android/email/activity/ActivityHelper.java
@@ -19,8 +19,8 @@ package com.android.email.activity;
import com.android.email.Controller;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent.Mailbox;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.ActivityNotFoundException;
diff --git a/src/com/android/email/activity/ContactStatusLoader.java b/src/com/android/email/activity/ContactStatusLoader.java
index d6e1d1ea5..b193016fb 100644
--- a/src/com/android/email/activity/ContactStatusLoader.java
+++ b/src/com/android/email/activity/ContactStatusLoader.java
@@ -16,7 +16,8 @@
package com.android.email.activity;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.utility.Utility;
import android.content.AsyncTaskLoader;
import android.content.ContentUris;
@@ -128,8 +129,7 @@ public class ContactStatusLoader extends AsyncTaskLoader 0) {
showErrorBanner(null);
}
diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java
index 6bea10cd4..4d9cbb4d7 100644
--- a/src/com/android/email/activity/MailboxListFragment.java
+++ b/src/com/android/email/activity/MailboxListFragment.java
@@ -20,10 +20,11 @@ import com.android.email.Controller;
import com.android.email.Email;
import com.android.email.R;
import com.android.email.RefreshManager;
-import com.android.email.Utility;
import com.android.email.provider.EmailProvider;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.ListFragment;
@@ -151,7 +152,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onCreate");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -178,7 +179,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
@@ -198,7 +199,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
*/
public void openMailboxes(long accountId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment openMailboxes");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment openMailboxes");
}
if (accountId == -1) {
throw new InvalidParameterException();
@@ -226,7 +227,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onStart");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onStart");
}
super.onStart();
}
@@ -237,7 +238,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onResume");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onResume");
}
super.onResume();
mResumed = true;
@@ -252,7 +253,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onPause");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onPause");
}
mResumed = false;
super.onPause();
@@ -265,7 +266,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onStop");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onStop");
}
super.onStop();
}
@@ -276,7 +277,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onDestroy");
}
super.onDestroy();
}
@@ -284,7 +285,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
outState.putLong(BUNDLE_KEY_SELECTED_MAILBOX_ID, mSelectedMailboxId);
@@ -298,7 +299,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
private void startLoading() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment startLoading");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment startLoading");
}
mOpenRequested = false;
// Clear the list. (ListFragment will show the "Loading" animation)
@@ -331,7 +332,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public Loader onCreateLoader(int id, Bundle args) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onCreateLoader");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onCreateLoader");
}
return MailboxesAdapter.createLoader(getActivity(), mAccountId,
MailboxesAdapter.MODE_NORMAL);
@@ -340,7 +341,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
@Override
public void onLoadFinished(Loader loader, Cursor cursor) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxListFragment onLoadFinished");
+ Log.d(Logging.LOG_TAG, "MailboxListFragment onLoadFinished");
}
mLastLoadedAccountId = mAccountId;
diff --git a/src/com/android/email/activity/MailboxesAdapter.java b/src/com/android/email/activity/MailboxesAdapter.java
index a9bee833a..2bb121098 100644
--- a/src/com/android/email/activity/MailboxesAdapter.java
+++ b/src/com/android/email/activity/MailboxesAdapter.java
@@ -17,17 +17,19 @@
package com.android.email.activity;
import com.android.email.Email;
+import com.android.email.FolderProperties;
import com.android.email.R;
import com.android.email.ResourceHelper;
-import com.android.email.Utility;
import com.android.email.data.ClosingMatrixCursor;
import com.android.email.data.ThrottlingCursorLoader;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.content.Loader;
@@ -254,8 +256,7 @@ import android.widget.TextView;
// we use the predefined names.
final int type = cursor.getInt(COLUMN_TYPE);
final long mailboxId = cursor.getLong(COLUMN_ID);
- name = Utility.FolderProperties.getInstance(context)
- .getDisplayName(type, mailboxId);
+ name = FolderProperties.getInstance(context).getDisplayName(type, mailboxId);
}
if (name == null) {
name = cursor.getString(COLUMN_DISPLAY_NAME);
@@ -306,7 +307,7 @@ import android.widget.TextView;
// Set folder icon
((ImageView) view.findViewById(R.id.folder_icon)).setImageDrawable(
- Utility.FolderProperties.getInstance(context).getIcon(type, id));
+ FolderProperties.getInstance(context).getIcon(type, id));
final View chipView = view.findViewById(R.id.color_chip);
if (isAccount) {
@@ -336,7 +337,7 @@ import android.widget.TextView;
public static Loader createLoader(Context context, long accountId,
int mode) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxesAdapter createLoader accountId=" + accountId);
+ Log.d(Logging.LOG_TAG, "MailboxesAdapter createLoader accountId=" + accountId);
}
if (accountId != Account.ACCOUNT_ID_COMBINED_VIEW) {
return new MailboxesLoader(context, accountId, mode);
diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java
index c3b27df81..d5ba3a1c5 100644
--- a/src/com/android/email/activity/MessageCompose.java
+++ b/src/com/android/email/activity/MessageCompose.java
@@ -20,9 +20,10 @@ import com.android.email.Controller;
import com.android.email.Email;
import com.android.email.EmailAddressAdapter;
import com.android.email.EmailAddressValidator;
+import com.android.email.UiUtilities;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.mail.internet.EmailHtmlUtil;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.provider.EmailContent;
@@ -32,6 +33,8 @@ import com.android.emailcommon.provider.EmailContent.Body;
import com.android.emailcommon.provider.EmailContent.BodyColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
+import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import android.app.ActionBar;
import android.app.Activity;
@@ -652,7 +655,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
message.mIntroText = null;
}
} catch (RuntimeException e) {
- Log.d(Email.LOG_TAG, "Exception while loading message body: " + e);
+ Log.d(Logging.LOG_TAG, "Exception while loading message body: " + e);
return new Object[] {null, null};
}
return new Object[]{message, account};
@@ -904,7 +907,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
public SendOrSaveMessageTask(boolean send) {
if (send && ActivityManager.isUserAMonkey()) {
- Log.d(Email.LOG_TAG, "Inhibiting send while monkey is in charge.");
+ Log.d(Logging.LOG_TAG, "Inhibiting send while monkey is in charge.");
send = false;
}
mSend = send;
@@ -1098,7 +1101,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
private void onAddAttachment() {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
- i.setType(Email.ACCEPTABLE_ATTACHMENT_SEND_UI_TYPES[0]);
+ i.setType(AttachmentUtilities.ACCEPTABLE_ATTACHMENT_SEND_UI_TYPES[0]);
startActivityForResult(
Intent.createChooser(i, getString(R.string.choose_attachment_dialog_title)),
ACTIVITY_REQUEST_PICK_ATTACHMENT);
@@ -1138,7 +1141,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
// The size was not measurable; This attachment is not safe to use.
// Quick hack to force a relevant error into the UI
// TODO: A proper announcement of the problem
- size = Email.MAX_ATTACHMENT_UPLOAD_SIZE + 1;
+ size = AttachmentUtilities.MAX_ATTACHMENT_UPLOAD_SIZE + 1;
}
}
@@ -1157,7 +1160,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
private void addAttachment(Attachment attachment, boolean allowDelete) {
// Before attaching the attachment, make sure it meets any other pre-attach criteria
- if (attachment.mSize > Email.MAX_ATTACHMENT_UPLOAD_SIZE) {
+ if (attachment.mSize > AttachmentUtilities.MAX_ATTACHMENT_UPLOAD_SIZE) {
Toast.makeText(this, R.string.message_compose_attachment_size, Toast.LENGTH_LONG)
.show();
return;
@@ -1170,7 +1173,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
TextView sizeView = (TextView)view.findViewById(R.id.attachment_size);
nameView.setText(attachment.mFileName);
- sizeView.setText(Utility.formatSize(this, attachment.mSize));
+ sizeView.setText(UiUtilities.formatSize(this, attachment.mSize));
if (allowDelete) {
delete.setOnClickListener(this);
delete.setTag(view);
@@ -1386,7 +1389,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
Uri stream = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (stream != null && type != null) {
if (MimeUtility.mimeTypeMatches(type,
- Email.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES)) {
+ AttachmentUtilities.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES)) {
addAttachment(stream);
}
}
@@ -1401,7 +1404,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
if (uri != null) {
Attachment attachment = loadAttachmentInfo(uri);
if (MimeUtility.mimeTypeMatches(attachment.mMimeType,
- Email.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES)) {
+ AttachmentUtilities.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES)) {
addAttachment(attachment, true);
}
}
@@ -1436,7 +1439,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
}
addAddresses(mToView, to.split(" ,"));
} catch (UnsupportedEncodingException e) {
- Log.e(Email.LOG_TAG, e.getMessage() + " while decoding '" + mailToString + "'");
+ Log.e(Logging.LOG_TAG, e.getMessage() + " while decoding '" + mailToString + "'");
}
// Extract the other parameters
diff --git a/src/com/android/email/activity/MessageFileView.java b/src/com/android/email/activity/MessageFileView.java
index 59f628904..6da663e61 100644
--- a/src/com/android/email/activity/MessageFileView.java
+++ b/src/com/android/email/activity/MessageFileView.java
@@ -16,9 +16,9 @@
package com.android.email.activity;
-import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.utility.Utility;
import android.app.ActionBar;
import android.content.Intent;
@@ -73,7 +73,7 @@ public class MessageFileView extends MessageViewBase {
Intent intent = getIntent();
mFileEmailUri = intent.getData();
if (mFileEmailUri == null) {
- Log.w(Email.LOG_TAG, "Insufficient intent parameter. Closing...");
+ Log.w(Logging.LOG_TAG, "Insufficient intent parameter. Closing...");
finish();
return;
}
diff --git a/src/com/android/email/activity/MessageFileViewFragment.java b/src/com/android/email/activity/MessageFileViewFragment.java
index 43fb9389f..24417c1ef 100644
--- a/src/com/android/email/activity/MessageFileViewFragment.java
+++ b/src/com/android/email/activity/MessageFileViewFragment.java
@@ -18,8 +18,9 @@ package com.android.email.activity;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.net.Uri;
@@ -68,7 +69,7 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
/** Called by activities with a URI to an EML file. */
public void openMessage(Uri fileEmailUri) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageFileViewFragment openMessage");
+ Log.d(Logging.LOG_TAG, "MessageFileViewFragment openMessage");
}
if (fileEmailUri == null) {
throw new InvalidParameterException();
@@ -101,7 +102,7 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
protected Message openMessageSync(Activity activity) {
synchronized (mLock) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageFileViewFragment openMessageSync");
+ Log.d(Logging.LOG_TAG, "MessageFileViewFragment openMessageSync");
}
Uri messageUri = mFileEmailUri;
if (messageUri == null) {
diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java
index cc11bf005..1d461e44b 100644
--- a/src/com/android/email/activity/MessageList.java
+++ b/src/com/android/email/activity/MessageList.java
@@ -19,8 +19,9 @@ package com.android.email.activity;
import com.android.email.Controller;
import com.android.email.ControllerResultUiThreadWrapper;
import com.android.email.Email;
+import com.android.email.MessagingExceptionStrings;
+import com.android.email.FolderProperties;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.activity.setup.AccountSecurity;
import com.android.email.activity.setup.AccountSettingsXL;
import com.android.emailcommon.mail.MessagingException;
@@ -29,6 +30,7 @@ import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.ContentResolver;
@@ -494,7 +496,7 @@ public class MessageList extends Activity implements OnClickListener,
new String[] { Long.toString(mMailboxKey) }, null);
try {
if (c.moveToFirst()) {
- mailboxName = Utility.FolderProperties.getInstance(MessageList.this)
+ mailboxName = FolderProperties.getInstance(MessageList.this)
.getDisplayName(c.getInt(MAILBOX_NAME_COLUMN_TYPE));
if (mailboxName == null) {
mailboxName = c.getString(MAILBOX_NAME_COLUMN_ID);
@@ -640,7 +642,8 @@ public class MessageList extends Activity implements OnClickListener,
return;
}
if (result != null) {
- showErrorBanner(result.getUiErrorMessage(MessageList.this));
+ showErrorBanner(
+ MessagingExceptionStrings.getErrorString(MessageList.this, result));
} else if (progress > 0) {
showErrorBanner(null);
}
diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java
index 296f4cc98..9c1a4afd7 100644
--- a/src/com/android/email/activity/MessageListFragment.java
+++ b/src/com/android/email/activity/MessageListFragment.java
@@ -20,15 +20,16 @@ import com.android.email.Controller;
import com.android.email.Email;
import com.android.email.R;
import com.android.email.RefreshManager;
-import com.android.email.Utility;
-import com.android.email.Utility.ListStateSaver;
import com.android.email.data.MailboxAccountLoader;
import com.android.email.provider.EmailProvider;
import com.android.email.service.MailService;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
+import com.android.emailcommon.utility.Utility.ListStateSaver;
import android.app.Activity;
import android.app.ListFragment;
@@ -216,7 +217,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onCreate");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onCreate");
}
super.onCreate(savedInstanceState);
mActivity = getActivity();
@@ -239,7 +240,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
@@ -264,7 +265,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onStart");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onStart");
}
super.onStart();
}
@@ -272,7 +273,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onResume");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onResume");
}
super.onResume();
mResumed = true;
@@ -287,7 +288,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onPause");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onPause");
}
mResumed = false;
super.onStop();
@@ -297,7 +298,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onStop");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onStop");
}
super.onStop();
}
@@ -305,7 +306,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onDestroy");
}
Utility.cancelTaskInterrupt(mMessageOpenTask);
mMessageOpenTask = null;
@@ -316,7 +317,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "MessageListFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
mListAdapter.onSaveInstanceState(outState);
@@ -385,7 +386,7 @@ public class MessageListFragment extends ListFragment
*/
public void openMailbox(long mailboxId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment openMailbox");
+ Log.d(Logging.LOG_TAG, "MessageListFragment openMailbox");
}
if (mailboxId == -1) {
throw new InvalidParameterException();
@@ -1050,7 +1051,7 @@ public class MessageListFragment extends ListFragment
private void startLoading() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment startLoading");
+ Log.d(Logging.LOG_TAG, "MessageListFragment startLoading");
}
mOpenRequested = false;
@@ -1093,7 +1094,7 @@ public class MessageListFragment extends ListFragment
@Override
public Loader onCreateLoader(int id, Bundle args) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG,
+ Log.d(Logging.LOG_TAG,
"MessageListFragment onCreateLoader(mailbox) mailboxId=" + mMailboxId);
}
return new MailboxAccountLoader(getActivity().getApplicationContext(), mMailboxId);
@@ -1103,7 +1104,7 @@ public class MessageListFragment extends ListFragment
public void onLoadFinished(Loader loader,
MailboxAccountLoader.Result result) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListFragment onLoadFinished(mailbox) mailboxId="
+ Log.d(Logging.LOG_TAG, "MessageListFragment onLoadFinished(mailbox) mailboxId="
+ mMailboxId);
}
if (!result.mIsFound) {
@@ -1150,7 +1151,7 @@ public class MessageListFragment extends ListFragment
@Override
public Loader onCreateLoader(int id, Bundle args) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG,
+ Log.d(Logging.LOG_TAG,
"MessageListFragment onCreateLoader(messages) mailboxId=" + mMailboxId);
}
return MessagesAdapter.createLoader(getActivity(), mMailboxId);
@@ -1159,7 +1160,7 @@ public class MessageListFragment extends ListFragment
@Override
public void onLoadFinished(Loader loader, Cursor cursor) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG,
+ Log.d(Logging.LOG_TAG,
"MessageListFragment onLoadFinished(messages) mailboxId=" + mMailboxId);
}
diff --git a/src/com/android/email/activity/MessageListXL.java b/src/com/android/email/activity/MessageListXL.java
index fa60e63ae..5d7a68327 100644
--- a/src/com/android/email/activity/MessageListXL.java
+++ b/src/com/android/email/activity/MessageListXL.java
@@ -20,15 +20,17 @@ import com.android.email.Clock;
import com.android.email.Controller;
import com.android.email.ControllerResultUiThreadWrapper;
import com.android.email.Email;
+import com.android.email.MessagingExceptionStrings;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.RefreshManager;
-import com.android.email.Utility;
import com.android.email.activity.setup.AccountSecurity;
import com.android.email.activity.setup.AccountSettingsXL;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
+import com.android.emailcommon.utility.Utility;
import android.app.ActionBar;
import android.app.Activity;
@@ -147,7 +149,7 @@ public class MessageListXL extends Activity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onCreate");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onCreate");
super.onCreate(savedInstanceState);
ActivityHelper.debugSetWindowFlags(this);
setContentView(R.layout.message_list_xl);
@@ -200,7 +202,7 @@ public class MessageListXL extends Activity implements
final long mailboxId = i.getLongExtra(EXTRA_MAILBOX_ID, -1);
final long messageId = i.getLongExtra(EXTRA_MESSAGE_ID, -1);
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, String.format("initFromIntent: %d %d", accountId, mailboxId));
+ Log.d(Logging.LOG_TAG, String.format("initFromIntent: %d %d", accountId, mailboxId));
}
if (accountId != -1) {
@@ -211,7 +213,7 @@ public class MessageListXL extends Activity implements
@Override
protected void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListXL onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "MessageListXL onSaveInstanceState");
}
super.onSaveInstanceState(outState);
mFragmentManager.onSaveInstanceState(outState);
@@ -219,7 +221,7 @@ public class MessageListXL extends Activity implements
@Override
protected void onStart() {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onStart");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onStart");
super.onStart();
mFragmentManager.onStart();
@@ -230,7 +232,7 @@ public class MessageListXL extends Activity implements
@Override
protected void onResume() {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onResume");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onResume");
super.onResume();
mFragmentManager.onResume();
@@ -243,14 +245,14 @@ public class MessageListXL extends Activity implements
@Override
protected void onPause() {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onPause");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onPause");
super.onPause();
mFragmentManager.onPause();
}
@Override
protected void onStop() {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onStop");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onStop");
super.onStop();
mFragmentManager.onStop();
@@ -259,7 +261,7 @@ public class MessageListXL extends Activity implements
@Override
protected void onDestroy() {
- if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onDestroy");
+ if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, "MessageListXL onDestroy");
mIsCreated = false;
mController.removeResultCallback(mControllerResult);
Utility.cancelTaskInterrupt(mRefreshTask);
@@ -271,7 +273,7 @@ public class MessageListXL extends Activity implements
@Override
public void onBackPressed() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListXL onBackPressed");
+ Log.d(Logging.LOG_TAG, "MessageListXL onBackPressed");
}
onBackPressed(true);
}
@@ -677,7 +679,7 @@ public class MessageListXL extends Activity implements
@Override
public boolean onNavigationItemSelected(int itemPosition, long accountId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Account selected: accountId=" + accountId);
+ Log.d(Logging.LOG_TAG, "Account selected: accountId=" + accountId);
}
mFragmentManager.selectAccount(accountId, -1, -1, true);
return true;
@@ -928,7 +930,9 @@ public class MessageListXL extends Activity implements
}
} else {
// Connection error.
- showErrorMessage(result.getUiErrorMessage(MessageListXL.this), accountId);
+ showErrorMessage(
+ MessagingExceptionStrings.getErrorString(MessageListXL.this, result),
+ accountId);
}
}
}
diff --git a/src/com/android/email/activity/MessageListXLFragmentManager.java b/src/com/android/email/activity/MessageListXLFragmentManager.java
index 00945a05b..86bd936ad 100644
--- a/src/com/android/email/activity/MessageListXLFragmentManager.java
+++ b/src/com/android/email/activity/MessageListXLFragmentManager.java
@@ -18,6 +18,7 @@ package com.android.email.activity;
import com.android.email.Email;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
@@ -129,7 +130,7 @@ class MessageListXLFragmentManager {
*/
public void onActivityViewReady() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListXLFragmentManager.onActivityViewReady");
+ Log.d(Logging.LOG_TAG, "MessageListXLFragmentManager.onActivityViewReady");
}
mThreePane = (ThreePaneLayout) mTargetActivity.findViewById(R.id.three_pane);
mThreePane.setCallback(mThreePaneLayoutCallback);
@@ -287,7 +288,7 @@ class MessageListXLFragmentManager {
long messageId = savedInstanceState.getLong(BUNDLE_KEY_MESSAGE_ID, -1);
mMessageListFragmentState = savedInstanceState.getParcelable(BUNDLE_KEY_MESSAGE_LIST_STATE);
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageListXLFragmentManager: Restoring "
+ Log.d(Logging.LOG_TAG, "MessageListXLFragmentManager: Restoring "
+ accountId + "," + mailboxId + "," + messageId);
}
if (accountId == -1) {
@@ -343,7 +344,7 @@ class MessageListXLFragmentManager {
public void selectAccount(long accountId, long mailboxId, long messageId,
boolean byExplicitUserAction) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "selectAccount mAccountId=" + accountId);
+ Log.d(Logging.LOG_TAG, "selectAccount mAccountId=" + accountId);
}
if (accountId == -1) {
throw new InvalidParameterException();
@@ -408,7 +409,7 @@ class MessageListXLFragmentManager {
*/
public void selectMailbox(long mailboxId, long messageId, boolean byExplicitUserAction) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "selectMailbox mMailboxId=" + mailboxId);
+ Log.d(Logging.LOG_TAG, "selectMailbox mMailboxId=" + mailboxId);
}
if (mailboxId == -1) {
throw new InvalidParameterException();
@@ -446,7 +447,7 @@ class MessageListXLFragmentManager {
*/
public void selectMessage(long messageId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "selectMessage messageId=" + messageId);
+ Log.d(Logging.LOG_TAG, "selectMessage messageId=" + messageId);
}
if (messageId == -1) {
throw new InvalidParameterException();
@@ -480,7 +481,7 @@ class MessageListXLFragmentManager {
private void startInboxLookup() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "startLookForInbox account=" + mAccountId);
+ Log.d(Logging.LOG_TAG, "startLookForInbox account=" + mAccountId);
}
closeMailboxFinder();
mMailboxFinder = new MailboxFinder(mContext, mAccountId, Mailbox.TYPE_INBOX,
@@ -499,7 +500,7 @@ class MessageListXLFragmentManager {
@Override
public void onAccountNotFound() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxFinderCallback.onAccountNotFound");
+ Log.d(Logging.LOG_TAG, "MailboxFinderCallback.onAccountNotFound");
}
// Shouldn't happen
}
@@ -507,7 +508,7 @@ class MessageListXLFragmentManager {
@Override
public void onAccountSecurityHold(long accountId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxFinderCallback.onAccountSecurityHold");
+ Log.d(Logging.LOG_TAG, "MailboxFinderCallback.onAccountSecurityHold");
}
mTargetActivity.onAccountSecurityHold(accountId);
}
@@ -515,7 +516,7 @@ class MessageListXLFragmentManager {
@Override
public void onMailboxFound(long accountId, long mailboxId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, " Found inbox");
+ Log.d(Logging.LOG_TAG, " Found inbox");
}
selectMailbox(mailboxId, -1, true);
}
@@ -523,7 +524,7 @@ class MessageListXLFragmentManager {
@Override
public void onMailboxNotFound(long accountId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MailboxFinderCallback.onMailboxNotFound");
+ Log.d(Logging.LOG_TAG, "MailboxFinderCallback.onMailboxNotFound");
}
// Shouldn't happen
}
diff --git a/src/com/android/email/activity/MessageOrderManager.java b/src/com/android/email/activity/MessageOrderManager.java
index 6155282b1..85bd15261 100644
--- a/src/com/android/email/activity/MessageOrderManager.java
+++ b/src/com/android/email/activity/MessageOrderManager.java
@@ -16,8 +16,8 @@
package com.android.email.activity;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent;
+import com.android.emailcommon.utility.Utility;
import android.content.ContentResolver;
import android.content.Context;
diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java
index 105fa184f..1b5ceb0c1 100644
--- a/src/com/android/email/activity/MessageView.java
+++ b/src/com/android/email/activity/MessageView.java
@@ -18,6 +18,7 @@ package com.android.email.activity;
import com.android.email.Email;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import android.content.Context;
@@ -110,7 +111,7 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
mMessageId = intent.getLongExtra(EXTRA_MESSAGE_ID, -1);
mMailboxId = intent.getLongExtra(EXTRA_MAILBOX_ID, -1);
if (mMessageId == -1 || mMailboxId == -1) {
- Log.w(Email.LOG_TAG, "Insufficient intent parameter. Closing...");
+ Log.w(Logging.LOG_TAG, "Insufficient intent parameter. Closing...");
finish();
return;
}
diff --git a/src/com/android/email/activity/MessageViewFragment.java b/src/com/android/email/activity/MessageViewFragment.java
index 2b004691e..0911f918c 100644
--- a/src/com/android/email/activity/MessageViewFragment.java
+++ b/src/com/android/email/activity/MessageViewFragment.java
@@ -18,12 +18,13 @@ package com.android.email.activity;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MeetingInfo;
import com.android.emailcommon.mail.PackedString;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.service.EmailServiceConstants;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.res.Resources;
@@ -201,7 +202,7 @@ public class MessageViewFragment extends MessageViewFragmentBase
/** Called by activities to set an id of a message to open. */
public void openMessage(long messageId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment openMessage");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment openMessage");
}
if (messageId == -1) {
throw new InvalidParameterException();
diff --git a/src/com/android/email/activity/MessageViewFragmentBase.java b/src/com/android/email/activity/MessageViewFragmentBase.java
index b7b91b4bb..d895bd066 100644
--- a/src/com/android/email/activity/MessageViewFragmentBase.java
+++ b/src/com/android/email/activity/MessageViewFragmentBase.java
@@ -20,12 +20,13 @@ import com.android.email.AttachmentInfo;
import com.android.email.Controller;
import com.android.email.ControllerResultUiThreadWrapper;
import com.android.email.Email;
+import com.android.email.UiUtilities;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.Throttle;
-import com.android.email.Utility;
import com.android.email.mail.internet.EmailHtmlUtil;
import com.android.email.service.AttachmentDownloadService;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Attachment;
@@ -33,6 +34,7 @@ import com.android.emailcommon.provider.EmailContent.Body;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import org.apache.commons.io.IOUtils;
@@ -255,7 +257,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onCreate");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -272,7 +274,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onCreateView");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onCreateView");
}
final View view = inflater.inflate(R.layout.message_view_fragment, container, false);
@@ -321,7 +323,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
mController.addResultCallback(mControllerCallback);
@@ -330,7 +332,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onStart");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onStart");
}
super.onStart();
}
@@ -338,7 +340,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onResume");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onResume");
}
super.onResume();
@@ -358,7 +360,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onPause");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onPause");
}
mResumed = false;
super.onPause();
@@ -367,7 +369,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onStop");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onStop");
}
super.onStop();
}
@@ -375,7 +377,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onDestroy");
}
mCallback.onMessageViewGone();
mController.removeResultCallback(mControllerCallback);
@@ -388,7 +390,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessageViewFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "MessageViewFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
}
@@ -1002,7 +1004,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
} catch (RuntimeException re) {
// This catches SQLiteException as well as other RTE's we've seen from the
// database calls, such as IllegalStateException
- Log.d(Email.LOG_TAG, "Exception while loading message body", re);
+ Log.d(Logging.LOG_TAG, "Exception while loading message body", re);
mErrorLoadingMessageBody = true;
return null;
}
@@ -1081,7 +1083,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
PREVIEW_ICON_WIDTH,
PREVIEW_ICON_HEIGHT)));
} catch (Exception e) {
- Log.d(Email.LOG_TAG, "Attachment preview failed with exception " + e.getMessage());
+ Log.d(Logging.LOG_TAG, "Attachment preview failed with exception " + e.getMessage());
return null;
}
}
@@ -1227,7 +1229,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
attachmentCancel.setTag(attachmentInfo);
attachmentName.setText(attachmentInfo.mName);
- attachmentInfoView.setText(Utility.formatSize(mContext, attachmentInfo.mSize));
+ attachmentInfoView.setText(UiUtilities.formatSize(mContext, attachmentInfo.mSize));
mAttachments.addView(view);
mAttachments.setVisibility(View.VISIBLE);
diff --git a/src/com/android/email/activity/MessagesAdapter.java b/src/com/android/email/activity/MessagesAdapter.java
index a52be05aa..ba1741ca0 100644
--- a/src/com/android/email/activity/MessagesAdapter.java
+++ b/src/com/android/email/activity/MessagesAdapter.java
@@ -18,11 +18,12 @@ package com.android.email.activity;
import com.android.email.Email;
import com.android.email.ResourceHelper;
-import com.android.email.Utility;
import com.android.email.data.ThrottlingCursorLoader;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.content.Loader;
@@ -202,7 +203,7 @@ import java.util.Set;
public static Loader createLoader(Context context, long mailboxId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "MessagesAdapter createLoader mailboxId=" + mailboxId);
+ Log.d(Logging.LOG_TAG, "MessagesAdapter createLoader mailboxId=" + mailboxId);
}
return new MessagesCursorLoader(context, mailboxId);
diff --git a/src/com/android/email/activity/MoveMessageToDialog.java b/src/com/android/email/activity/MoveMessageToDialog.java
index 8d4a1adac..0dac41f98 100644
--- a/src/com/android/email/activity/MoveMessageToDialog.java
+++ b/src/com/android/email/activity/MoveMessageToDialog.java
@@ -17,10 +17,10 @@
package com.android.email.activity;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.AlertDialog;
diff --git a/src/com/android/email/activity/ThreePaneLayout.java b/src/com/android/email/activity/ThreePaneLayout.java
index b18827a06..87952f2da 100644
--- a/src/com/android/email/activity/ThreePaneLayout.java
+++ b/src/com/android/email/activity/ThreePaneLayout.java
@@ -16,8 +16,8 @@
package com.android.email.activity;
-import com.android.email.Email;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import android.animation.Animator;
import android.animation.ObjectAnimator;
@@ -484,7 +484,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
}
if (mLastAnimatorListener != null) {
if (ANIMATION_DEBUG) {
- Log.w(Email.LOG_TAG, "Anim: Cancelling last animation: " + mLastAnimator);
+ Log.w(Logging.LOG_TAG, "Anim: Cancelling last animation: " + mLastAnimator);
}
// Animator.cancel() doesn't call listener.cancel() immediately, so sometimes
// we end up cancelling the previous one *after* starting the next one.
@@ -528,7 +528,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
private void log(String message) {
if (ANIMATION_DEBUG) {
- Log.w(Email.LOG_TAG, "Anim: " + mLogLabel + "[" + this + "] " + message);
+ Log.w(Logging.LOG_TAG, "Anim: " + mLogLabel + "[" + this + "] " + message);
}
}
diff --git a/src/com/android/email/activity/Welcome.java b/src/com/android/email/activity/Welcome.java
index e054de425..22c575dc3 100644
--- a/src/com/android/email/activity/Welcome.java
+++ b/src/com/android/email/activity/Welcome.java
@@ -19,12 +19,12 @@ package com.android.email.activity;
import com.android.email.AccountBackupRestore;
import com.android.email.Email;
import com.android.email.ExchangeUtils;
-import com.android.email.Utility;
import com.android.email.activity.setup.AccountSetupBasics;
import com.android.email.service.MailService;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.Context;
diff --git a/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java b/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
index bcc9a0e56..1eb4c1fd2 100644
--- a/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
+++ b/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
@@ -16,16 +16,16 @@
package com.android.email.activity.setup;
-import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.mail.Sender;
import com.android.email.mail.Store;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.PolicySet;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.AlertDialog;
@@ -415,7 +415,7 @@ public class AccountCheckSettingsFragment extends Fragment {
if ((mMode & SetupData.CHECK_AUTODISCOVER) != 0) {
if (isCancelled()) return null;
publishProgress(STATE_CHECK_AUTODISCOVER);
- Log.d(Email.LOG_TAG, "Begin auto-discover for " + mCheckEmail);
+ Log.d(Logging.LOG_TAG, "Begin auto-discover for " + mCheckEmail);
Store store = Store.getInstance(mStoreUri, mContext, null);
Bundle result = store.autoDiscover(mContext, mCheckEmail, mCheckPassword);
// Result will be one of:
@@ -442,7 +442,7 @@ public class AccountCheckSettingsFragment extends Fragment {
// Check Incoming Settings
if ((mMode & SetupData.CHECK_INCOMING) != 0) {
if (isCancelled()) return null;
- Log.d(Email.LOG_TAG, "Begin check of incoming email settings");
+ Log.d(Logging.LOG_TAG, "Begin check of incoming email settings");
publishProgress(STATE_CHECK_INCOMING);
Store store = Store.getInstance(mStoreUri, mContext, null);
Bundle bundle = store.checkSettings();
@@ -467,7 +467,7 @@ public class AccountCheckSettingsFragment extends Fragment {
// Check Outgoing Settings
if ((mMode & SetupData.CHECK_OUTGOING) != 0) {
if (isCancelled()) return null;
- Log.d(Email.LOG_TAG, "Begin check of outgoing email settings");
+ Log.d(Logging.LOG_TAG, "Begin check of outgoing email settings");
publishProgress(STATE_CHECK_OUTGOING);
Sender sender = Sender.getInstance(mContext, mSenderUri);
sender.close();
diff --git a/src/com/android/email/activity/setup/AccountSecurity.java b/src/com/android/email/activity/setup/AccountSecurity.java
index c80ac3754..576870d6a 100644
--- a/src/com/android/email/activity/setup/AccountSecurity.java
+++ b/src/com/android/email/activity/setup/AccountSecurity.java
@@ -18,10 +18,10 @@ package com.android.email.activity.setup;
import com.android.email.R;
import com.android.email.SecurityPolicy;
-import com.android.email.Utility;
import com.android.email.activity.ActivityHelper;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
diff --git a/src/com/android/email/activity/setup/AccountServerBaseFragment.java b/src/com/android/email/activity/setup/AccountServerBaseFragment.java
index 2b785ce64..be658b6dd 100644
--- a/src/com/android/email/activity/setup/AccountServerBaseFragment.java
+++ b/src/com/android/email/activity/setup/AccountServerBaseFragment.java
@@ -17,10 +17,10 @@
package com.android.email.activity.setup;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.Fragment;
diff --git a/src/com/android/email/activity/setup/AccountSettingsFragment.java b/src/com/android/email/activity/setup/AccountSettingsFragment.java
index 449f0892d..3027c5bc1 100644
--- a/src/com/android/email/activity/setup/AccountSettingsFragment.java
+++ b/src/com/android/email/activity/setup/AccountSettingsFragment.java
@@ -18,13 +18,15 @@ package com.android.email.activity.setup;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.mail.Sender;
import com.android.email.mail.Store;
+import com.android.emailcommon.CalendarProviderStub;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.app.AlertDialog;
@@ -47,7 +49,6 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.RingtonePreference;
-import android.provider.Calendar;
import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.Log;
@@ -167,7 +168,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onCreate");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -190,7 +191,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
}
@@ -201,7 +202,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onStart");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onStart");
}
super.onStart();
mStarted = true;
@@ -220,7 +221,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onResume");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onResume");
}
super.onResume();
@@ -249,7 +250,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onPause");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onPause");
}
super.onPause();
if (mSaveOnExit) {
@@ -263,7 +264,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onStop");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onStop");
}
super.onStop();
mStarted = false;
@@ -275,7 +276,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onDestroy");
}
super.onDestroy();
@@ -286,7 +287,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSettingsFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "AccountSettingsFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
}
@@ -547,7 +548,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
.getSyncAutomatically(acct, ContactsContract.AUTHORITY));
mSyncContacts.setOnPreferenceChangeListener(mPreferenceChangeListener);
mSyncCalendar.setChecked(ContentResolver
- .getSyncAutomatically(acct, Calendar.AUTHORITY));
+ .getSyncAutomatically(acct, CalendarProviderStub.AUTHORITY));
mSyncCalendar.setOnPreferenceChangeListener(mPreferenceChangeListener);
mSyncEmail.setChecked(ContentResolver
.getSyncAutomatically(acct, EmailContent.AUTHORITY));
@@ -632,7 +633,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
Email.EXCHANGE_ACCOUNT_MANAGER_TYPE);
ContentResolver.setSyncAutomatically(acct, ContactsContract.AUTHORITY,
mSyncContacts.isChecked());
- ContentResolver.setSyncAutomatically(acct, Calendar.AUTHORITY,
+ ContentResolver.setSyncAutomatically(acct, CalendarProviderStub.AUTHORITY,
mSyncCalendar.isChecked());
ContentResolver.setSyncAutomatically(acct, EmailContent.AUTHORITY,
mSyncEmail.isChecked());
diff --git a/src/com/android/email/activity/setup/AccountSettingsUtils.java b/src/com/android/email/activity/setup/AccountSettingsUtils.java
index a936bd6f4..0b5ded2df 100644
--- a/src/com/android/email/activity/setup/AccountSettingsUtils.java
+++ b/src/com/android/email/activity/setup/AccountSettingsUtils.java
@@ -17,9 +17,9 @@
package com.android.email.activity.setup;
import com.android.email.AccountBackupRestore;
-import com.android.email.Email;
import com.android.email.R;
import com.android.email.VendorPolicyLoader;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
@@ -136,7 +136,7 @@ public class AccountSettingsUtils {
}
}
catch (Exception e) {
- Log.e(Email.LOG_TAG, "Error while trying to load provider settings.", e);
+ Log.e(Logging.LOG_TAG, "Error while trying to load provider settings.", e);
}
return null;
}
diff --git a/src/com/android/email/activity/setup/AccountSettingsXL.java b/src/com/android/email/activity/setup/AccountSettingsXL.java
index 1112cc3be..6ea1fb44e 100644
--- a/src/com/android/email/activity/setup/AccountSettingsXL.java
+++ b/src/com/android/email/activity/setup/AccountSettingsXL.java
@@ -17,16 +17,16 @@
package com.android.email.activity.setup;
import com.android.email.Controller;
-import com.android.email.Email;
import com.android.email.NotificationController;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.activity.ActivityHelper;
import com.android.email.mail.Sender;
import com.android.email.mail.Store;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
+import com.android.emailcommon.utility.Utility;
import android.app.ActionBar;
import android.app.Activity;
@@ -594,7 +594,7 @@ public class AccountSettingsXL extends PreferenceActivity {
}
}
} catch (Exception e) {
- Log.d(Email.LOG_TAG, "Error while trying to invoke store settings.", e);
+ Log.d(Logging.LOG_TAG, "Error while trying to invoke store settings.", e);
}
}
@@ -618,7 +618,7 @@ public class AccountSettingsXL extends PreferenceActivity {
}
}
} catch (Exception e) {
- Log.d(Email.LOG_TAG, "Error while trying to invoke sender settings.", e);
+ Log.d(Logging.LOG_TAG, "Error while trying to invoke sender settings.", e);
}
}
diff --git a/src/com/android/email/activity/setup/AccountSetupBasics.java b/src/com/android/email/activity/setup/AccountSetupBasics.java
index 2360e3bb5..c2441d345 100644
--- a/src/com/android/email/activity/setup/AccountSetupBasics.java
+++ b/src/com/android/email/activity/setup/AccountSetupBasics.java
@@ -16,17 +16,17 @@
package com.android.email.activity.setup;
-import com.android.email.Email;
import com.android.email.EmailAddressValidator;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.VendorPolicyLoader;
import com.android.email.activity.ActivityHelper;
import com.android.email.activity.Welcome;
import com.android.email.activity.setup.AccountSettingsUtils.Provider;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
@@ -266,7 +266,7 @@ public class AccountSetupBasics extends AccountSetupActivity
if (SetupData.getFlowMode() == SetupData.FLOW_MODE_FORCE_CREATE) {
if (!DEBUG_ALLOW_NON_TEST_HARNESS_CREATION &&
!ActivityManager.isRunningInTestHarness()) {
- Log.e(Email.LOG_TAG,
+ Log.e(Logging.LOG_TAG,
"ERROR: Force account create only allowed while in test harness");
finish();
return;
@@ -278,7 +278,7 @@ public class AccountSetupBasics extends AccountSetupActivity
String outgoing = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_OUTGOING);
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(user) ||
TextUtils.isEmpty(incoming) || TextUtils.isEmpty(outgoing)) {
- Log.e(Email.LOG_TAG, "ERROR: Force account create requires extras EMAIL, USER, " +
+ Log.e(Logging.LOG_TAG, "ERROR: Force account create requires extras EMAIL, USER, " +
"INCOMING, OUTGOING");
finish();
return;
diff --git a/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java b/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java
index 03cc49e9a..f0e6a4ab2 100644
--- a/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java
+++ b/src/com/android/email/activity/setup/AccountSetupExchangeFragment.java
@@ -20,9 +20,10 @@ import com.android.email.AccountBackupRestore;
import com.android.email.Email;
import com.android.email.ExchangeUtils;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.ExchangeService;
import android.app.Activity;
@@ -76,7 +77,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onCreate");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -90,7 +91,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onCreateView");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onCreateView");
}
int layoutId = mSettingsMode
? R.layout.account_settings_exchange_fragment
@@ -140,7 +141,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
}
@@ -151,7 +152,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onStart");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onStart");
}
super.onStart();
mStarted = true;
@@ -164,7 +165,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onResume");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onResume");
}
super.onResume();
validateFields();
@@ -173,7 +174,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onPause");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onPause");
}
super.onPause();
}
@@ -184,7 +185,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onStop");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onStop");
}
super.onStop();
mStarted = false;
@@ -196,7 +197,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onDestroy");
}
super.onDestroy();
}
@@ -204,7 +205,7 @@ public class AccountSetupExchangeFragment extends AccountServerBaseFragment
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupExchangeFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "AccountSetupExchangeFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
diff --git a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java
index 315977c12..9ba275076 100644
--- a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java
+++ b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java
@@ -19,9 +19,10 @@ package com.android.email.activity.setup;
import com.android.email.AccountBackupRestore;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.Context;
@@ -94,7 +95,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onCreate");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -108,7 +109,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onCreateView");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onCreateView");
}
int layoutId = mSettingsMode
? R.layout.account_settings_incoming_fragment
@@ -198,7 +199,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
}
@@ -209,7 +210,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onStart");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onStart");
}
super.onStart();
mStarted = true;
@@ -223,7 +224,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onResume");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onResume");
}
super.onResume();
validateFields();
@@ -232,7 +233,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onPause");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onPause");
}
super.onPause();
}
@@ -243,7 +244,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onStop");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onStop");
}
super.onStop();
mStarted = false;
@@ -255,7 +256,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onDestroy");
}
super.onDestroy();
}
@@ -263,7 +264,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment {
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupIncomingFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "AccountSetupIncomingFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
diff --git a/src/com/android/email/activity/setup/AccountSetupNames.java b/src/com/android/email/activity/setup/AccountSetupNames.java
index 67d0c4535..8a040c3da 100644
--- a/src/com/android/email/activity/setup/AccountSetupNames.java
+++ b/src/com/android/email/activity/setup/AccountSetupNames.java
@@ -18,11 +18,11 @@ package com.android.email.activity.setup;
import com.android.email.AccountBackupRestore;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.activity.ActivityHelper;
import com.android.email.activity.Welcome;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.ContentValues;
diff --git a/src/com/android/email/activity/setup/AccountSetupOptions.java b/src/com/android/email/activity/setup/AccountSetupOptions.java
index d6447ce90..65e1df249 100644
--- a/src/com/android/email/activity/setup/AccountSetupOptions.java
+++ b/src/com/android/email/activity/setup/AccountSetupOptions.java
@@ -19,14 +19,15 @@ package com.android.email.activity.setup;
import com.android.email.Email;
import com.android.email.ExchangeUtils;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.email.activity.ActivityHelper;
import com.android.email.mail.Store;
import com.android.email.service.MailService;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.service.PolicySet;
import com.android.emailcommon.service.SyncWindow;
+import com.android.emailcommon.utility.Utility;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
@@ -276,11 +277,11 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
});
return;
} catch (OperationCanceledException e) {
- Log.d(Email.LOG_TAG, "addAccount was canceled");
+ Log.d(Logging.LOG_TAG, "addAccount was canceled");
} catch (IOException e) {
- Log.d(Email.LOG_TAG, "addAccount failed: " + e);
+ Log.d(Logging.LOG_TAG, "addAccount failed: " + e);
} catch (AuthenticatorException e) {
- Log.d(Email.LOG_TAG, "addAccount failed: " + e);
+ Log.d(Logging.LOG_TAG, "addAccount failed: " + e);
}
showErrorDialog(R.string.account_setup_failed_dlg_auth_message,
R.string.system_account_create_failed);
diff --git a/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java b/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java
index 3bdf290db..824bb4f65 100644
--- a/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java
+++ b/src/com/android/email/activity/setup/AccountSetupOutgoingFragment.java
@@ -19,9 +19,10 @@ package com.android.email.activity.setup;
import com.android.email.AccountBackupRestore;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
+import com.android.emailcommon.utility.Utility;
import android.app.Activity;
import android.content.Context;
@@ -83,7 +84,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onCreate");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onCreate");
}
super.onCreate(savedInstanceState);
@@ -96,7 +97,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onCreateView");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onCreateView");
}
int layoutId = mSettingsMode
? R.layout.account_settings_outgoing_fragment
@@ -170,7 +171,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onActivityCreated");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onActivityCreated");
}
super.onActivityCreated(savedInstanceState);
}
@@ -181,7 +182,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onStart");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onStart");
}
super.onStart();
mStarted = true;
@@ -194,7 +195,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onResume");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onResume");
}
super.onResume();
validateFields();
@@ -203,7 +204,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onPause");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onPause");
}
super.onPause();
}
@@ -214,7 +215,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onStop");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onStop");
}
super.onStop();
mStarted = false;
@@ -226,7 +227,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onDestroy");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onDestroy");
}
super.onDestroy();
}
@@ -234,7 +235,7 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupOutgoingFragment onSaveInstanceState");
+ Log.d(Logging.LOG_TAG, "AccountSetupOutgoingFragment onSaveInstanceState");
}
super.onSaveInstanceState(outState);
diff --git a/src/com/android/email/activity/setup/DebugFragment.java b/src/com/android/email/activity/setup/DebugFragment.java
index d1ae26800..f1dfc9be9 100644
--- a/src/com/android/email/activity/setup/DebugFragment.java
+++ b/src/com/android/email/activity/setup/DebugFragment.java
@@ -20,6 +20,7 @@ import com.android.email.Email;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.service.MailService;
+import com.android.emailcommon.Logging;
import com.android.exchange.Eas;
import com.android.exchange.utility.FileLogger;
@@ -51,7 +52,7 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "AccountSetupBasicsFragment onCreateView");
+ Log.d(Logging.LOG_TAG, "AccountSetupBasicsFragment onCreateView");
}
View view = inflater.inflate(R.layout.debug, container, false);
@@ -138,7 +139,7 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
WebView webview = new WebView(getActivity());
try {
webview.clearCache(true);
- Log.w(Email.LOG_TAG, "Cleard WebView cache.");
+ Log.w(Logging.LOG_TAG, "Cleard WebView cache.");
} finally {
webview.destroy();
}
diff --git a/src/com/android/email/data/ThrottlingCursorLoader.java b/src/com/android/email/data/ThrottlingCursorLoader.java
index d17ba7e5d..0f80e4fd5 100644
--- a/src/com/android/email/data/ThrottlingCursorLoader.java
+++ b/src/com/android/email/data/ThrottlingCursorLoader.java
@@ -16,8 +16,8 @@
package com.android.email.data;
-import com.android.email.Email;
import com.android.email.Throttle;
+import com.android.emailcommon.Logging;
import android.content.Context;
import android.content.CursorLoader;
@@ -56,7 +56,7 @@ public class ThrottlingCursorLoader extends CursorLoader {
}
private void debugLog(String message) {
- Log.d(Email.LOG_TAG, "ThrottlingCursorLoader: [" + getUri() + "] " + message);
+ Log.d(Logging.LOG_TAG, "ThrottlingCursorLoader: [" + getUri() + "] " + message);
}
@Override
diff --git a/src/com/android/email/mail/Sender.java b/src/com/android/email/mail/Sender.java
index 96a430bf2..43a4b778c 100644
--- a/src/com/android/email/mail/Sender.java
+++ b/src/com/android/email/mail/Sender.java
@@ -16,8 +16,8 @@
package com.android.email.mail;
-import com.android.email.Email;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import org.xmlpull.v1.XmlPullParserException;
@@ -53,7 +53,7 @@ public abstract class Sender {
c.getMethod("newInstance", Context.class, String.class);
o = m.invoke(null, context, uri);
} catch (Exception e) {
- Log.d(Email.LOG_TAG, String.format(
+ Log.d(Logging.LOG_TAG, String.format(
"exception %s invoking %s.newInstance.(Context, String) method for %s",
e.toString(), className, uri));
throw new MessagingException("can not instantiate Sender object for " + uri);
diff --git a/src/com/android/email/mail/Store.java b/src/com/android/email/mail/Store.java
index 9c3b06f63..fe48fc386 100644
--- a/src/com/android/email/mail/Store.java
+++ b/src/com/android/email/mail/Store.java
@@ -18,6 +18,7 @@ package com.android.email.mail;
import com.android.email.Email;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.Folder;
import com.android.emailcommon.mail.MessagingException;
@@ -81,7 +82,7 @@ public abstract class Store {
PersistentDataCallbacks.class);
o = m.invoke(null, uri, context, callbacks);
} catch (Exception e) {
- Log.d(Email.LOG_TAG, String.format(
+ Log.d(Logging.LOG_TAG, String.format(
"exception %s invoking %s.newInstance.(String, Context) method for %s",
e.toString(), className, uri));
throw new MessagingException("can not instantiate Store object for " + uri);
diff --git a/src/com/android/email/mail/store/ImapStore.java b/src/com/android/email/mail/store/ImapStore.java
index f18425f8e..bf9e5f260 100644
--- a/src/com/android/email/mail/store/ImapStore.java
+++ b/src/com/android/email/mail/store/ImapStore.java
@@ -18,7 +18,6 @@ package com.android.email.mail.store;
import com.android.email.Email;
import com.android.email.Preferences;
-import com.android.email.Utility;
import com.android.email.VendorPolicyLoader;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
@@ -32,6 +31,7 @@ import com.android.email.mail.transport.CountingOutputStream;
import com.android.email.mail.transport.DiscourseLogger;
import com.android.email.mail.transport.EOLConvertingOutputStream;
import com.android.email.mail.transport.MailTransport;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.BinaryTempFileBody;
import com.android.emailcommon.internet.MimeBodyPart;
import com.android.emailcommon.internet.MimeHeader;
@@ -48,6 +48,7 @@ import com.android.emailcommon.mail.Message;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Part;
import com.android.emailcommon.service.EmailServiceProxy;
+import com.android.emailcommon.utility.Utility;
import com.beetstra.jutf7.CharsetProvider;
import android.content.Context;
@@ -286,7 +287,7 @@ public class ImapStore extends Store {
id.append(hexUid);
id.append('\"');
} catch (NoSuchAlgorithmException e) {
- Log.d(Email.LOG_TAG, "couldn't obtain SHA-1 hash for device UID");
+ Log.d(Logging.LOG_TAG, "couldn't obtain SHA-1 hash for device UID");
}
return id.toString();
}
@@ -900,7 +901,7 @@ public class ImapStore extends Store {
try {
fetchInternal(messages, fp, listener);
} catch (RuntimeException e) { // Probably a parser error.
- Log.w(Email.LOG_TAG, "Exception detected: " + e.getMessage());
+ Log.w(Logging.LOG_TAG, "Exception detected: " + e.getMessage());
if (mConnection != null) {
mConnection.logLastDiscourse();
}
@@ -1021,7 +1022,7 @@ public class ImapStore extends Store {
parseBodyStructure(bs, message, ImapConstants.TEXT);
} catch (MessagingException e) {
if (Email.LOGD) {
- Log.v(Email.LOG_TAG, "Error handling message", e);
+ Log.v(Logging.LOG_TAG, "Error handling message", e);
}
message.setBody(null);
}
@@ -1439,7 +1440,7 @@ public class ImapStore extends Store {
private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "IO Exception detected: ", ioe);
+ Log.d(Logging.LOG_TAG, "IO Exception detected: ", ioe);
}
connection.destroyResponses();
connection.close();
@@ -1530,7 +1531,7 @@ public class ImapStore extends Store {
ensurePrefixIsValid();
} catch (SSLException e) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, e.toString());
+ Log.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
@@ -1538,7 +1539,7 @@ public class ImapStore extends Store {
// of other code here that catches IOException and I don't want to break it.
// This catch is only here to enhance logging of connection-time issues.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw ioe;
} finally {
@@ -1663,7 +1664,7 @@ public class ImapStore extends Store {
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ie.toString());
+ Log.d(Logging.LOG_TAG, ie.toString());
}
} catch (IOException ioe) {
// Special case to handle malformed OK responses and ignore them.
@@ -1688,7 +1689,7 @@ public class ImapStore extends Store {
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ie.toString());
+ Log.d(Logging.LOG_TAG, ie.toString());
}
} catch (IOException ioe) {
// Special case to handle malformed OK responses and ignore them.
@@ -1719,7 +1720,7 @@ public class ImapStore extends Store {
executeSimpleCommand(mLoginPhrase, true);
} catch (ImapException ie) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ie.toString());
+ Log.d(Logging.LOG_TAG, ie.toString());
}
throw new AuthenticationFailedException(ie.getAlertText(), ie);
@@ -1743,7 +1744,7 @@ public class ImapStore extends Store {
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ie.toString());
+ Log.d(Logging.LOG_TAG, ie.toString());
}
} catch (IOException ioe) {
// Special case to handle malformed OK responses and ignore them.
@@ -1776,7 +1777,7 @@ public class ImapStore extends Store {
return(queryCapabilities());
} else {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "TLS not supported but required");
+ Log.d(Logging.LOG_TAG, "TLS not supported but required");
}
throw new MessagingException(MessagingException.TLS_REQUIRED);
}
diff --git a/src/com/android/email/mail/store/Pop3Store.java b/src/com/android/email/mail/store/Pop3Store.java
index ee9d08078..36ca1abe4 100644
--- a/src/com/android/email/mail/store/Pop3Store.java
+++ b/src/com/android/email/mail/store/Pop3Store.java
@@ -17,11 +17,10 @@
package com.android.email.mail.store;
import com.android.email.Email;
-import com.android.email.Utility;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
-import com.android.email.mail.transport.LoggingInputStream;
import com.android.email.mail.transport.MailTransport;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeMessage;
import com.android.emailcommon.mail.AuthenticationFailedException;
import com.android.emailcommon.mail.FetchProfile;
@@ -31,6 +30,8 @@ import com.android.emailcommon.mail.Message;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Folder.OpenMode;
import com.android.emailcommon.service.EmailServiceProxy;
+import com.android.emailcommon.utility.LoggingInputStream;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.os.Bundle;
@@ -264,7 +265,7 @@ public class Pop3Store extends Store {
mTransport.reopenTls();
} else {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "TLS not supported but required");
+ Log.d(Logging.LOG_TAG, "TLS not supported but required");
}
throw new MessagingException(MessagingException.TLS_REQUIRED);
}
@@ -275,14 +276,14 @@ public class Pop3Store extends Store {
executeSensitiveCommand("PASS " + mPassword, "PASS /redacted/");
} catch (MessagingException me) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, me.toString());
+ Log.d(Logging.LOG_TAG, me.toString());
}
throw new AuthenticationFailedException(null, me);
}
} catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException(MessagingException.IOERROR, ioe.toString());
}
@@ -304,7 +305,7 @@ public class Pop3Store extends Store {
if (statException != null) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, statException.toString());
+ Log.d(Logging.LOG_TAG, statException.toString());
}
throw new MessagingException("POP3 STAT", statException);
}
@@ -375,7 +376,7 @@ public class Pop3Store extends Store {
} catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "Unable to index during getMessage " + ioe);
+ Log.d(Logging.LOG_TAG, "Unable to index during getMessage " + ioe);
}
throw new MessagingException("getMessages", ioe);
}
@@ -396,7 +397,7 @@ public class Pop3Store extends Store {
} catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException("getMessages", ioe);
}
@@ -645,7 +646,7 @@ public class Pop3Store extends Store {
} catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException("fetch", ioe);
}
@@ -680,7 +681,7 @@ public class Pop3Store extends Store {
} catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException("Unable to fetch message", ioe);
}
@@ -840,7 +841,7 @@ public class Pop3Store extends Store {
catch (IOException ioe) {
mTransport.close();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException("setFlags()", ioe);
}
diff --git a/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java b/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java
index 2a088db80..ea62d52d1 100644
--- a/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java
+++ b/src/com/android/email/mail/store/imap/ImapMemoryLiteral.java
@@ -16,9 +16,9 @@
package com.android.email.mail.store.imap;
-import com.android.email.Email;
import com.android.email.FixedLengthInputStream;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.utility.Utility;
import android.util.Log;
@@ -45,7 +45,7 @@ public class ImapMemoryLiteral extends ImapString {
pos += read;
}
if (pos != mData.length) {
- Log.w(Email.LOG_TAG, "");
+ Log.w(Logging.LOG_TAG, "");
}
}
diff --git a/src/com/android/email/mail/store/imap/ImapResponseParser.java b/src/com/android/email/mail/store/imap/ImapResponseParser.java
index 63df6dc64..beb092c23 100644
--- a/src/com/android/email/mail/store/imap/ImapResponseParser.java
+++ b/src/com/android/email/mail/store/imap/ImapResponseParser.java
@@ -20,8 +20,9 @@ import com.android.email.Email;
import com.android.email.FixedLengthInputStream;
import com.android.email.PeekableInputStream;
import com.android.email.mail.transport.DiscourseLogger;
-import com.android.email.mail.transport.LoggingInputStream;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.utility.LoggingInputStream;
import android.text.TextUtils;
import android.util.Log;
@@ -99,7 +100,7 @@ public class ImapResponseParser {
private static IOException newEOSException() {
final String message = "End of stream reached";
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, message);
+ Log.d(Logging.LOG_TAG, message);
}
return new IOException(message);
}
@@ -161,7 +162,7 @@ public class ImapResponseParser {
try {
response = parseResponse();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "<<< " + response.toString());
+ Log.d(Logging.LOG_TAG, "<<< " + response.toString());
}
} catch (RuntimeException e) {
@@ -176,7 +177,7 @@ public class ImapResponseParser {
// Handle this outside of try-catch. We don't have to dump protocol log when getting BYE.
if (response.is(0, ImapConstants.BYE)) {
- Log.w(Email.LOG_TAG, ByeException.MESSAGE);
+ Log.w(Logging.LOG_TAG, ByeException.MESSAGE);
response.destroy();
throw new ByeException();
}
@@ -200,7 +201,7 @@ public class ImapResponseParser {
}
} catch (IOException ignore) {
}
- Log.w(Email.LOG_TAG, "Exception detected: " + e.getMessage());
+ Log.w(Logging.LOG_TAG, "Exception detected: " + e.getMessage());
mDiscourseLogger.logLastDiscourse();
}
diff --git a/src/com/android/email/mail/store/imap/ImapSimpleString.java b/src/com/android/email/mail/store/imap/ImapSimpleString.java
index 735caa652..190c5237f 100644
--- a/src/com/android/email/mail/store/imap/ImapSimpleString.java
+++ b/src/com/android/email/mail/store/imap/ImapSimpleString.java
@@ -16,7 +16,7 @@
package com.android.email.mail.store.imap;
-import com.android.email.Utility;
+import com.android.emailcommon.utility.Utility;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
diff --git a/src/com/android/email/mail/store/imap/ImapString.java b/src/com/android/email/mail/store/imap/ImapString.java
index e90eeea8f..b0ee99d84 100644
--- a/src/com/android/email/mail/store/imap/ImapString.java
+++ b/src/com/android/email/mail/store/imap/ImapString.java
@@ -16,7 +16,7 @@
package com.android.email.mail.store.imap;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import android.util.Log;
@@ -132,7 +132,7 @@ public abstract class ImapString extends ImapElement {
mParsedDate = DATE_TIME_FORMAT.parse(getString());
return true;
} catch (ParseException e) {
- Log.w(Email.LOG_TAG, getString() + " can't be parsed as a date.");
+ Log.w(Logging.LOG_TAG, getString() + " can't be parsed as a date.");
return false;
}
}
diff --git a/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java b/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java
index fac5d2ef8..05de6760b 100644
--- a/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java
+++ b/src/com/android/email/mail/store/imap/ImapTempFileLiteral.java
@@ -16,9 +16,10 @@
package com.android.email.mail.store.imap;
-import com.android.email.Email;
import com.android.email.FixedLengthInputStream;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.TempDirectory;
+import com.android.emailcommon.utility.Utility;
import org.apache.commons.io.IOUtils;
@@ -44,7 +45,7 @@ public class ImapTempFileLiteral extends ImapString {
/* package */ ImapTempFileLiteral(FixedLengthInputStream stream) throws IOException {
mSize = stream.getLength();
- mFile = File.createTempFile("imap", ".tmp", Email.getTempDirectory());
+ mFile = File.createTempFile("imap", ".tmp", TempDirectory.getTempDirectory());
// Unfortunately, we can't really use deleteOnExit(), because temp filenames are random
// so it'd simply cause a memory leak.
@@ -76,7 +77,7 @@ public class ImapTempFileLiteral extends ImapString {
return new FileInputStream(mFile);
} catch (FileNotFoundException e) {
// It's probably possible if we're low on storage and the system clears the cache dir.
- Log.w(Email.LOG_TAG, "ImapTempFileLiteral: Temp file not found");
+ Log.w(Logging.LOG_TAG, "ImapTempFileLiteral: Temp file not found");
// Return 0 byte stream as a dummy...
return new ByteArrayInputStream(new byte[0]);
@@ -89,7 +90,7 @@ public class ImapTempFileLiteral extends ImapString {
try {
return Utility.fromAscii(IOUtils.toByteArray(getAsStream()));
} catch (IOException e) {
- Log.w(Email.LOG_TAG, "ImapTempFileLiteral: Error while reading temp file");
+ Log.w(Logging.LOG_TAG, "ImapTempFileLiteral: Error while reading temp file");
return "";
}
}
@@ -102,7 +103,7 @@ public class ImapTempFileLiteral extends ImapString {
}
} catch (RuntimeException re) {
// Just log and ignore.
- Log.w(Email.LOG_TAG, "Failed to remove temp file: " + re.getMessage());
+ Log.w(Logging.LOG_TAG, "Failed to remove temp file: " + re.getMessage());
}
super.destroy();
}
diff --git a/src/com/android/email/mail/transport/DiscourseLogger.java b/src/com/android/email/mail/transport/DiscourseLogger.java
index 10cb043e1..a8c85dbe4 100644
--- a/src/com/android/email/mail/transport/DiscourseLogger.java
+++ b/src/com/android/email/mail/transport/DiscourseLogger.java
@@ -16,7 +16,7 @@
package com.android.email.mail.transport;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import android.util.Log;
@@ -111,9 +111,9 @@ public class DiscourseLogger {
return;
}
- Log.w(Email.LOG_TAG, "Last network activities:");
+ Log.w(Logging.LOG_TAG, "Last network activities:");
for (String r : getLines()) {
- Log.w(Email.LOG_TAG, r);
+ Log.w(Logging.LOG_TAG, r);
}
initBuffer();
}
diff --git a/src/com/android/email/mail/transport/MailTransport.java b/src/com/android/email/mail/transport/MailTransport.java
index da69715fe..32e9821f7 100644
--- a/src/com/android/email/mail/transport/MailTransport.java
+++ b/src/com/android/email/mail/transport/MailTransport.java
@@ -18,6 +18,7 @@ package com.android.email.mail.transport;
import com.android.email.Email;
import com.android.email.mail.Transport;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.CertificateValidationException;
import com.android.emailcommon.mail.MessagingException;
@@ -150,7 +151,7 @@ public class MailTransport implements Transport {
*/
public void open() throws MessagingException, CertificateValidationException {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "*** " + mDebugLabel + " open " +
+ Log.d(Logging.LOG_TAG, "*** " + mDebugLabel + " open " +
getHost() + ":" + String.valueOf(getPort()));
}
@@ -171,12 +172,12 @@ public class MailTransport implements Transport {
} catch (SSLException e) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, e.toString());
+ Log.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException(MessagingException.IOERROR, ioe.toString());
}
@@ -200,12 +201,12 @@ public class MailTransport implements Transport {
} catch (SSLException e) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, e.toString());
+ Log.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException(MessagingException.IOERROR, ioe.toString());
}
@@ -301,9 +302,9 @@ public class MailTransport implements Transport {
public void writeLine(String s, String sensitiveReplacement) throws IOException {
if (Email.DEBUG) {
if (sensitiveReplacement != null && !Email.DEBUG_SENSITIVE) {
- Log.d(Email.LOG_TAG, ">>> " + sensitiveReplacement);
+ Log.d(Logging.LOG_TAG, ">>> " + sensitiveReplacement);
} else {
- Log.d(Email.LOG_TAG, ">>> " + s);
+ Log.d(Logging.LOG_TAG, ">>> " + s);
}
}
@@ -332,11 +333,11 @@ public class MailTransport implements Transport {
}
}
if (d == -1 && Email.DEBUG) {
- Log.d(Email.LOG_TAG, "End of stream reached while trying to read line.");
+ Log.d(Logging.LOG_TAG, "End of stream reached while trying to read line.");
}
String ret = sb.toString();
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "<<< " + ret);
+ Log.d(Logging.LOG_TAG, "<<< " + ret);
}
return ret;
}
diff --git a/src/com/android/email/mail/transport/SmtpSender.java b/src/com/android/email/mail/transport/SmtpSender.java
index a1a8853ae..603e29ad0 100644
--- a/src/com/android/email/mail/transport/SmtpSender.java
+++ b/src/com/android/email/mail/transport/SmtpSender.java
@@ -19,6 +19,8 @@ package com.android.email.mail.transport;
import com.android.email.Email;
import com.android.email.mail.Sender;
import com.android.email.mail.Transport;
+import com.android.emailcommon.Logging;
+import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.AuthenticationFailedException;
import com.android.emailcommon.mail.CertificateValidationException;
@@ -146,7 +148,7 @@ public class SmtpSender extends Sender {
result = executeSimpleCommand("EHLO " + localHost);
} else {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "TLS not supported but required");
+ Log.d(Logging.LOG_TAG, "TLS not supported but required");
}
throw new MessagingException(MessagingException.TLS_REQUIRED);
}
@@ -168,19 +170,19 @@ public class SmtpSender extends Sender {
}
else {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, "No valid authentication mechanism found.");
+ Log.d(Logging.LOG_TAG, "No valid authentication mechanism found.");
}
throw new MessagingException(MessagingException.AUTH_REQUIRED);
}
}
} catch (SSLException e) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, e.toString());
+ Log.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (Email.DEBUG) {
- Log.d(Email.LOG_TAG, ioe.toString());
+ Log.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException(MessagingException.IOERROR, ioe.toString());
}
diff --git a/src/com/android/email/mail/transport/StatusOutputStream.java b/src/com/android/email/mail/transport/StatusOutputStream.java
index e22991e4e..2c8672273 100644
--- a/src/com/android/email/mail/transport/StatusOutputStream.java
+++ b/src/com/android/email/mail/transport/StatusOutputStream.java
@@ -17,6 +17,7 @@
package com.android.email.mail.transport;
import com.android.email.Email;
+import com.android.emailcommon.Logging;
import android.util.Log;
@@ -37,7 +38,7 @@ public class StatusOutputStream extends FilterOutputStream {
mCount++;
if (Email.LOGD) {
if (mCount % 1024 == 0) {
- Log.v(Email.LOG_TAG, "# " + mCount);
+ Log.v(Logging.LOG_TAG, "# " + mCount);
}
}
}
diff --git a/src/com/android/email/provider/AttachmentProvider.java b/src/com/android/email/provider/AttachmentProvider.java
index f505770e4..841d7321e 100644
--- a/src/com/android/email/provider/AttachmentProvider.java
+++ b/src/com/android/email/provider/AttachmentProvider.java
@@ -16,7 +16,7 @@
package com.android.email.provider;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.AttachmentColumns;
@@ -177,10 +177,12 @@ public class AttachmentProvider extends ContentProvider {
out.close();
in.close();
} catch (IOException ioe) {
- Log.d(Email.LOG_TAG, "openFile/thumbnail failed with " + ioe.getMessage());
+ Log.d(Logging.LOG_TAG, "openFile/thumbnail failed with " +
+ ioe.getMessage());
return null;
} catch (OutOfMemoryError oome) {
- Log.d(Email.LOG_TAG, "openFile/thumbnail failed with " + oome.getMessage());
+ Log.d(Logging.LOG_TAG, "openFile/thumbnail failed with " +
+ oome.getMessage());
return null;
}
}
@@ -290,10 +292,10 @@ public class AttachmentProvider extends ContentProvider {
Bitmap bitmap = BitmapFactory.decodeStream(data);
return bitmap;
} catch (OutOfMemoryError oome) {
- Log.d(Email.LOG_TAG, "createImageThumbnail failed with " + oome.getMessage());
+ Log.d(Logging.LOG_TAG, "createImageThumbnail failed with " + oome.getMessage());
return null;
} catch (Exception e) {
- Log.d(Email.LOG_TAG, "createImageThumbnail failed with " + e.getMessage());
+ Log.d(Logging.LOG_TAG, "createImageThumbnail failed with " + e.getMessage());
return null;
}
}
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index e93244ad6..97f900af4 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -119,12 +119,6 @@ public class EmailProvider extends ContentProvider {
// Version 6: Adding Body.mIntroText column
public static final int BODY_DATABASE_VERSION = 6;
- public static final String EMAIL_AUTHORITY = "com.android.email.provider";
- // The notifier authority is used to send notifications regarding changes to messages (insert,
- // delete, or update) and is intended as an optimization for use by clients of message list
- // cursors (initially, the email AppWidget).
- public static final String EMAIL_NOTIFIER_AUTHORITY = "com.android.email.notifier";
-
private static final int ACCOUNT_BASE = 0;
private static final int ACCOUNT = ACCOUNT_BASE;
private static final int ACCOUNT_ID = ACCOUNT_BASE + 1;
@@ -240,56 +234,61 @@ public class EmailProvider extends ContentProvider {
UriMatcher matcher = sURIMatcher;
// All accounts
- matcher.addURI(EMAIL_AUTHORITY, "account", ACCOUNT);
+ matcher.addURI(EmailContent.AUTHORITY, "account", ACCOUNT);
// A specific account
// insert into this URI causes a mailbox to be added to the account
- matcher.addURI(EMAIL_AUTHORITY, "account/#", ACCOUNT_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "account/#", ACCOUNT_ID);
// Special URI to reset the new message count. Only update works, and content values
// will be ignored.
- matcher.addURI(EMAIL_AUTHORITY, "resetNewMessageCount", ACCOUNT_RESET_NEW_COUNT);
- matcher.addURI(EMAIL_AUTHORITY, "resetNewMessageCount/#", ACCOUNT_RESET_NEW_COUNT_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "resetNewMessageCount",
+ ACCOUNT_RESET_NEW_COUNT);
+ matcher.addURI(EmailContent.AUTHORITY, "resetNewMessageCount/#",
+ ACCOUNT_RESET_NEW_COUNT_ID);
// All mailboxes
- matcher.addURI(EMAIL_AUTHORITY, "mailbox", MAILBOX);
+ matcher.addURI(EmailContent.AUTHORITY, "mailbox", MAILBOX);
// A specific mailbox
// insert into this URI causes a message to be added to the mailbox
// ** NOTE For now, the accountKey must be set manually in the values!
- matcher.addURI(EMAIL_AUTHORITY, "mailbox/#", MAILBOX_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "mailbox/#", MAILBOX_ID);
// All messages
- matcher.addURI(EMAIL_AUTHORITY, "message", MESSAGE);
+ matcher.addURI(EmailContent.AUTHORITY, "message", MESSAGE);
// A specific message
// insert into this URI causes an attachment to be added to the message
- matcher.addURI(EMAIL_AUTHORITY, "message/#", MESSAGE_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "message/#", MESSAGE_ID);
// A specific attachment
- matcher.addURI(EMAIL_AUTHORITY, "attachment", ATTACHMENT);
+ matcher.addURI(EmailContent.AUTHORITY, "attachment", ATTACHMENT);
// A specific attachment (the header information)
- matcher.addURI(EMAIL_AUTHORITY, "attachment/#", ATTACHMENT_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "attachment/#", ATTACHMENT_ID);
// The attachments of a specific message (query only) (insert & delete TBD)
- matcher.addURI(EMAIL_AUTHORITY, "attachment/message/#", ATTACHMENTS_MESSAGE_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "attachment/message/#",
+ ATTACHMENTS_MESSAGE_ID);
// All mail bodies
- matcher.addURI(EMAIL_AUTHORITY, "body", BODY);
+ matcher.addURI(EmailContent.AUTHORITY, "body", BODY);
// A specific mail body
- matcher.addURI(EMAIL_AUTHORITY, "body/#", BODY_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "body/#", BODY_ID);
// All hostauth records
- matcher.addURI(EMAIL_AUTHORITY, "hostauth", HOSTAUTH);
+ matcher.addURI(EmailContent.AUTHORITY, "hostauth", HOSTAUTH);
// A specific hostauth
- matcher.addURI(EMAIL_AUTHORITY, "hostauth/#", HOSTAUTH_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "hostauth/#", HOSTAUTH_ID);
// Atomically a constant value to a particular field of a mailbox/account
- matcher.addURI(EMAIL_AUTHORITY, "mailboxIdAddToField/#", MAILBOX_ID_ADD_TO_FIELD);
- matcher.addURI(EMAIL_AUTHORITY, "accountIdAddToField/#", ACCOUNT_ID_ADD_TO_FIELD);
+ matcher.addURI(EmailContent.AUTHORITY, "mailboxIdAddToField/#",
+ MAILBOX_ID_ADD_TO_FIELD);
+ matcher.addURI(EmailContent.AUTHORITY, "accountIdAddToField/#",
+ ACCOUNT_ID_ADD_TO_FIELD);
/**
* THIS URI HAS SPECIAL SEMANTICS
* ITS USE IS INTENDED FOR THE UI APPLICATION TO MARK CHANGES THAT NEED TO BE SYNCED BACK
* TO A SERVER VIA A SYNC ADAPTER
*/
- matcher.addURI(EMAIL_AUTHORITY, "syncedMessage/#", SYNCED_MESSAGE_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "syncedMessage/#", SYNCED_MESSAGE_ID);
/**
* THE URIs BELOW THIS POINT ARE INTENDED TO BE USED BY SYNC ADAPTERS ONLY
@@ -297,14 +296,14 @@ public class EmailProvider extends ContentProvider {
* BY THE UI APPLICATION
*/
// All deleted messages
- matcher.addURI(EMAIL_AUTHORITY, "deletedMessage", DELETED_MESSAGE);
+ matcher.addURI(EmailContent.AUTHORITY, "deletedMessage", DELETED_MESSAGE);
// A specific deleted message
- matcher.addURI(EMAIL_AUTHORITY, "deletedMessage/#", DELETED_MESSAGE_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "deletedMessage/#", DELETED_MESSAGE_ID);
// All updated messages
- matcher.addURI(EMAIL_AUTHORITY, "updatedMessage", UPDATED_MESSAGE);
+ matcher.addURI(EmailContent.AUTHORITY, "updatedMessage", UPDATED_MESSAGE);
// A specific updated message
- matcher.addURI(EMAIL_AUTHORITY, "updatedMessage/#", UPDATED_MESSAGE_ID);
+ matcher.addURI(EmailContent.AUTHORITY, "updatedMessage/#", UPDATED_MESSAGE_ID);
CONTENT_VALUES_RESET_NEW_MESSAGE_COUNT = new ContentValues();
CONTENT_VALUES_RESET_NEW_MESSAGE_COUNT.put(Account.NEW_MESSAGE_COUNT, 0);
diff --git a/src/com/android/email/service/AttachmentDownloadService.java b/src/com/android/email/service/AttachmentDownloadService.java
index cce91a613..ea11ff063 100644
--- a/src/com/android/email/service/AttachmentDownloadService.java
+++ b/src/com/android/email/service/AttachmentDownloadService.java
@@ -20,7 +20,6 @@ import com.android.email.AttachmentInfo;
import com.android.email.Email;
import com.android.email.EmailConnectivityManager;
import com.android.email.NotificationController;
-import com.android.email.Utility;
import com.android.email.Controller.ControllerService;
import com.android.email.ExchangeUtils.NullEmailService;
import com.android.emailcommon.provider.EmailContent;
@@ -31,6 +30,7 @@ import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.IEmailServiceCallback;
import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.ExchangeService;
import android.accounts.AccountManager;
diff --git a/src/com/android/email/service/EasAuthenticatorService.java b/src/com/android/email/service/EasAuthenticatorService.java
index d787654e8..e97adbc3b 100644
--- a/src/com/android/email/service/EasAuthenticatorService.java
+++ b/src/com/android/email/service/EasAuthenticatorService.java
@@ -18,6 +18,7 @@ package com.android.email.service;
import com.android.email.Email;
import com.android.email.activity.setup.AccountSetupBasics;
+import com.android.emailcommon.CalendarProviderStub;
import com.android.emailcommon.provider.EmailContent;
import android.accounts.AbstractAccountAuthenticator;
@@ -31,7 +32,6 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
-import android.provider.Calendar;
import android.provider.ContactsContract;
/**
@@ -85,8 +85,9 @@ public class EasAuthenticatorService extends Service {
options.getBoolean(OPTIONS_CALENDAR_SYNC_ENABLED)) {
syncCalendar = true;
}
- ContentResolver.setIsSyncable(account, Calendar.AUTHORITY, 1);
- ContentResolver.setSyncAutomatically(account, Calendar.AUTHORITY, syncCalendar);
+ ContentResolver.setIsSyncable(account, CalendarProviderStub.AUTHORITY, 1);
+ ContentResolver.setSyncAutomatically(account, CalendarProviderStub.AUTHORITY,
+ syncCalendar);
// Set up email syncing, as above
boolean syncEmail = false;
@@ -95,7 +96,8 @@ public class EasAuthenticatorService extends Service {
syncEmail = true;
}
ContentResolver.setIsSyncable(account, EmailContent.AUTHORITY, 1);
- ContentResolver.setSyncAutomatically(account, EmailContent.AUTHORITY, syncEmail);
+ ContentResolver.setSyncAutomatically(account, EmailContent.AUTHORITY,
+ syncEmail);
Bundle b = new Bundle();
b.putString(AccountManager.KEY_ACCOUNT_NAME, options.getString(OPTIONS_USERNAME));
diff --git a/src/com/android/email/service/EmailBroadcastProcessorService.java b/src/com/android/email/service/EmailBroadcastProcessorService.java
index d91e5559c..9d14ce97d 100644
--- a/src/com/android/email/service/EmailBroadcastProcessorService.java
+++ b/src/com/android/email/service/EmailBroadcastProcessorService.java
@@ -23,6 +23,7 @@ import com.android.email.SecurityPolicy;
import com.android.email.VendorPolicyLoader;
import com.android.email.activity.setup.AccountSettingsXL;
import com.android.email.widget.WidgetManager;
+import com.android.emailcommon.Logging;
import android.accounts.AccountManager;
import android.app.IntentService;
@@ -145,7 +146,7 @@ public class EmailBroadcastProcessorService extends IntentService {
final int initialProgress = progress;
if (progress < 1) {
- Log.i(Email.LOG_TAG, "Onetime initialization: 1");
+ Log.i(Logging.LOG_TAG, "Onetime initialization: 1");
progress = 1;
if (VendorPolicyLoader.getInstance(this).useAlternateExchangeStrings()) {
setComponentEnabled(EasAuthenticatorServiceAlternate.class, true);
@@ -162,7 +163,7 @@ public class EmailBroadcastProcessorService extends IntentService {
if (progress != initialProgress) {
pref.setOneTimeInitializationProgress(progress);
- Log.i(Email.LOG_TAG, "Onetime initialization: completed.");
+ Log.i(Logging.LOG_TAG, "Onetime initialization: completed.");
}
}
@@ -175,7 +176,7 @@ public class EmailBroadcastProcessorService extends IntentService {
}
private void onSystemAccountChanged() {
- Log.i(Email.LOG_TAG, "System accouns updated.");
+ Log.i(Logging.LOG_TAG, "System accouns updated.");
MailService.reconcilePopImapAccountsSync(this);
// Let ExchangeService reconcile EAS accouts.
diff --git a/src/com/android/email/service/MailService.java b/src/com/android/email/service/MailService.java
index 3b8732756..0667977a7 100644
--- a/src/com/android/email/service/MailService.java
+++ b/src/com/android/email/service/MailService.java
@@ -23,8 +23,6 @@ import com.android.email.NotificationController;
import com.android.email.Preferences;
import com.android.email.SecurityPolicy;
import com.android.email.SingleRunningTask;
-import com.android.email.Utility;
-import com.android.email.provider.EmailProvider;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -32,6 +30,7 @@ import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.HostAuth;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.utility.AccountReconciler;
+import com.android.emailcommon.utility.Utility;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
@@ -655,7 +654,7 @@ public class MailService extends Service {
new android.accounts.Account(account.mEmailAddress,
Email.POP_IMAP_ACCOUNT_MANAGER_TYPE);
report.syncEnabled = ContentResolver.getSyncAutomatically(accountManagerAccount,
- EmailProvider.EMAIL_AUTHORITY);
+ EmailContent.AUTHORITY);
// TODO lookup # new in inbox
mSyncReports.put(report.accountId, report);
diff --git a/src/com/android/email/service/PopImapAuthenticatorService.java b/src/com/android/email/service/PopImapAuthenticatorService.java
index bcda556f0..39d388bb6 100644
--- a/src/com/android/email/service/PopImapAuthenticatorService.java
+++ b/src/com/android/email/service/PopImapAuthenticatorService.java
@@ -18,6 +18,7 @@ package com.android.email.service;
import com.android.email.Email;
import com.android.email.activity.setup.AccountSetupBasics;
+import com.android.emailcommon.CalendarProviderStub;
import com.android.emailcommon.provider.EmailContent;
import android.accounts.AbstractAccountAuthenticator;
@@ -31,7 +32,6 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
-import android.provider.Calendar;
import android.provider.ContactsContract;
/**
@@ -75,7 +75,7 @@ public class PopImapAuthenticatorService extends Service {
ContentResolver.setIsSyncable(account, EmailContent.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, EmailContent.AUTHORITY, syncEmail);
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 0);
- ContentResolver.setIsSyncable(account, Calendar.AUTHORITY, 0);
+ ContentResolver.setIsSyncable(account, CalendarProviderStub.AUTHORITY, 0);
Bundle b = new Bundle();
b.putString(AccountManager.KEY_ACCOUNT_NAME, options.getString(OPTIONS_USERNAME));
diff --git a/src/com/android/email/widget/EmailWidget.java b/src/com/android/email/widget/EmailWidget.java
index 466d5f10b..8dddda3aa 100644
--- a/src/com/android/email/widget/EmailWidget.java
+++ b/src/com/android/email/widget/EmailWidget.java
@@ -17,9 +17,9 @@
package com.android.email.widget;
import com.android.email.Email;
+import com.android.email.UiUtilities;
import com.android.email.R;
import com.android.email.ResourceHelper;
-import com.android.email.Utility;
import com.android.email.activity.MessageCompose;
import com.android.email.activity.Welcome;
import com.android.email.data.ThrottlingCursorLoader;
@@ -30,6 +30,7 @@ import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
+import com.android.emailcommon.utility.Utility;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
@@ -454,7 +455,7 @@ public class EmailWidget implements RemoteViewsService.RemoteViewsFactory {
views.setTextViewText(R.id.widget_tap, sConfigureText);
String count = "";
if (mCursorCount != TOTAL_COUNT_UNKNOWN) {
- count = Utility.getMessageCountForUi(mContext, mCursor.getCount(), false);
+ count = UiUtilities.getMessageCountForUi(mContext, mCursor.getCount(), false);
}
views.setTextViewText(R.id.widget_count, count);
}
diff --git a/src/com/android/emailcommon/CalendarProviderStub.java b/src/com/android/emailcommon/CalendarProviderStub.java
new file mode 100644
index 000000000..eac371ada
--- /dev/null
+++ b/src/com/android/emailcommon/CalendarProviderStub.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.emailcommon;
+
+/**
+ * This is the only non-SDK reference in the com.android.email project, referencing the once and
+ * future CalendarProvider authority name.
+ */
+public class CalendarProviderStub {
+ public static final String AUTHORITY = "com.android.calendar";
+}
diff --git a/src/com/android/emailcommon/Logging.java b/src/com/android/emailcommon/Logging.java
new file mode 100644
index 000000000..f9bf7b755
--- /dev/null
+++ b/src/com/android/emailcommon/Logging.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.emailcommon;
+
+public class Logging {
+ public static final String LOG_TAG = "Email";
+}
diff --git a/src/com/android/emailcommon/TempDirectory.java b/src/com/android/emailcommon/TempDirectory.java
new file mode 100644
index 000000000..252488c9f
--- /dev/null
+++ b/src/com/android/emailcommon/TempDirectory.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.emailcommon;
+
+import android.content.Context;
+
+import java.io.File;
+
+/**
+ * TempDirectory caches the directory used for caching file. It is set up during application
+ * initialization.
+ */
+public class TempDirectory {
+ private static File sTempDirectory = null;
+
+ public static void setTempDirectory(Context context) {
+ sTempDirectory = context.getCacheDir();
+ }
+
+ public static File getTempDirectory() {
+ if (sTempDirectory == null) {
+ throw new RuntimeException(
+ "TempDirectory not set. " +
+ "If in a unit test, call Email.setTempDirectory(context) in setUp().");
+ }
+ return sTempDirectory;
+ }
+}
diff --git a/src/com/android/emailcommon/internet/BinaryTempFileBody.java b/src/com/android/emailcommon/internet/BinaryTempFileBody.java
index 8c2f0b64c..f0821edd4 100644
--- a/src/com/android/emailcommon/internet/BinaryTempFileBody.java
+++ b/src/com/android/emailcommon/internet/BinaryTempFileBody.java
@@ -16,7 +16,7 @@
package com.android.emailcommon.internet;
-import com.android.email.Email;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.mail.Body;
import com.android.emailcommon.mail.MessagingException;
@@ -52,7 +52,7 @@ public class BinaryTempFileBody implements Body {
}
public OutputStream getOutputStream() throws IOException {
- mFile = File.createTempFile("body", null, Email.getTempDirectory());
+ mFile = File.createTempFile("body", null, TempDirectory.getTempDirectory());
mFile.deleteOnExit();
return new FileOutputStream(mFile);
}
diff --git a/src/com/android/emailcommon/internet/MimeHeader.java b/src/com/android/emailcommon/internet/MimeHeader.java
index 40c529db3..b0ad7772e 100644
--- a/src/com/android/emailcommon/internet/MimeHeader.java
+++ b/src/com/android/emailcommon/internet/MimeHeader.java
@@ -16,8 +16,8 @@
package com.android.emailcommon.internet;
-import com.android.email.Utility;
import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.utility.Utility;
import java.io.BufferedWriter;
import java.io.IOException;
diff --git a/src/com/android/emailcommon/internet/MimeUtility.java b/src/com/android/emailcommon/internet/MimeUtility.java
index 23dc23ae1..69330d76b 100644
--- a/src/com/android/emailcommon/internet/MimeUtility.java
+++ b/src/com/android/emailcommon/internet/MimeUtility.java
@@ -16,7 +16,7 @@
package com.android.emailcommon.internet;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.Body;
import com.android.emailcommon.mail.BodyPart;
import com.android.emailcommon.mail.Message;
@@ -303,14 +303,14 @@ public class MimeUtility {
* If we are not able to process the body there's nothing we can do about it. Return
* null and let the upper layers handle the missing content.
*/
- Log.e(Email.LOG_TAG, "Unable to getTextFromPart " + oom.toString());
+ Log.e(Logging.LOG_TAG, "Unable to getTextFromPart " + oom.toString());
}
catch (Exception e) {
/*
* If we are not able to process the body there's nothing we can do about it. Return
* null and let the upper layers handle the missing content.
*/
- Log.e(Email.LOG_TAG, "Unable to getTextFromPart " + e.toString());
+ Log.e(Logging.LOG_TAG, "Unable to getTextFromPart " + e.toString());
}
return null;
}
@@ -383,8 +383,9 @@ public class MimeUtility {
try {
IOUtils.copy(in, out);
} catch (Base64DataException bde) {
- String warning = "\n\n" + Email.getMessageDecodeErrorString();
- out.write(warning.getBytes());
+ // STOPSHIP Need to fix this somehow
+ //String warning = "\n\n" + Email.getMessageDecodeErrorString();
+ //out.write(warning.getBytes());
} finally {
out.close();
}
diff --git a/src/com/android/email/mail/transport/Rfc822Output.java b/src/com/android/emailcommon/internet/Rfc822Output.java
similarity index 99%
rename from src/com/android/email/mail/transport/Rfc822Output.java
rename to src/com/android/emailcommon/internet/Rfc822Output.java
index 9639cad81..9a3b017b9 100644
--- a/src/com/android/email/mail/transport/Rfc822Output.java
+++ b/src/com/android/emailcommon/internet/Rfc822Output.java
@@ -14,9 +14,8 @@
* limitations under the License.
*/
-package com.android.email.mail.transport;
+package com.android.emailcommon.internet;
-import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Attachment;
diff --git a/src/com/android/emailcommon/mail/Address.java b/src/com/android/emailcommon/mail/Address.java
index 2d6654e3c..76a3b7c6f 100644
--- a/src/com/android/emailcommon/mail/Address.java
+++ b/src/com/android/emailcommon/mail/Address.java
@@ -16,7 +16,7 @@
package com.android.emailcommon.mail;
-import com.android.email.Utility;
+import com.android.emailcommon.utility.Utility;
import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.decoder.DecoderUtil;
diff --git a/src/com/android/emailcommon/mail/AuthenticationFailedException.java b/src/com/android/emailcommon/mail/AuthenticationFailedException.java
index 18a3b8f51..af8d96c09 100644
--- a/src/com/android/emailcommon/mail/AuthenticationFailedException.java
+++ b/src/com/android/emailcommon/mail/AuthenticationFailedException.java
@@ -16,7 +16,6 @@
package com.android.emailcommon.mail;
-import com.android.email.R;
public class AuthenticationFailedException extends MessagingException {
public static final long serialVersionUID = -1;
@@ -32,9 +31,4 @@ public class AuthenticationFailedException extends MessagingException {
public AuthenticationFailedException(String message, Throwable throwable) {
super(MessagingException.AUTHENTICATION_FAILED, message, throwable);
}
-
- @Override
- public int getUiErrorMessageResourceId() {
- return R.string.account_setup_failed_dlg_auth_message;
- }
}
diff --git a/src/com/android/emailcommon/mail/CertificateValidationException.java b/src/com/android/emailcommon/mail/CertificateValidationException.java
index ac6811f7b..83c6224df 100644
--- a/src/com/android/emailcommon/mail/CertificateValidationException.java
+++ b/src/com/android/emailcommon/mail/CertificateValidationException.java
@@ -16,7 +16,6 @@
package com.android.emailcommon.mail;
-import com.android.email.R;
public class CertificateValidationException extends MessagingException {
public static final long serialVersionUID = -1;
@@ -28,9 +27,4 @@ public class CertificateValidationException extends MessagingException {
public CertificateValidationException(String message, Throwable throwable) {
super(MessagingException.CERTIFICATE_VALIDATION_ERROR, message, throwable);
}
-
- @Override
- public int getUiErrorMessageResourceId() {
- return R.string.account_setup_failed_dlg_certificate_message;
- }
}
\ No newline at end of file
diff --git a/src/com/android/emailcommon/mail/MessagingException.java b/src/com/android/emailcommon/mail/MessagingException.java
index c538801a5..ba3cf2383 100644
--- a/src/com/android/emailcommon/mail/MessagingException.java
+++ b/src/com/android/emailcommon/mail/MessagingException.java
@@ -16,9 +16,6 @@
package com.android.emailcommon.mail;
-import com.android.email.R;
-
-import android.content.Context;
/**
* This exception is used for most types of failures that occur during server interactions.
@@ -105,32 +102,4 @@ public class MessagingException extends Exception {
public int getExceptionType() {
return mExceptionType;
}
-
- /**
- * @return the error message associated with this exception.
- */
- public final String getUiErrorMessage(Context context) {
- return context.getResources().getString(getUiErrorMessageResourceId());
- }
-
- /**
- * @return the resource ID of the error message associated with this exception.
- */
- public int getUiErrorMessageResourceId() {
- switch (getExceptionType()) {
- case MessagingException.IOERROR:
- return R.string.account_setup_failed_ioerror;
- case MessagingException.TLS_REQUIRED:
- return R.string.account_setup_failed_tls_required;
- case MessagingException.AUTH_REQUIRED:
- return R.string.account_setup_failed_auth_required;
- case MessagingException.GENERAL_SECURITY:
- return R.string.account_setup_failed_security;
- // TODO Generate a unique string for this case, which is the case
- // where the security policy needs to be updated.
- case MessagingException.SECURITY_POLICIES_REQUIRED:
- return R.string.account_setup_failed_security;
- }
- return R.string.status_network_error; // default
- }
}
\ No newline at end of file
diff --git a/src/com/android/emailcommon/provider/EmailContent.java b/src/com/android/emailcommon/provider/EmailContent.java
index e1821e988..3ea955c9a 100644
--- a/src/com/android/emailcommon/provider/EmailContent.java
+++ b/src/com/android/emailcommon/provider/EmailContent.java
@@ -16,9 +16,8 @@
package com.android.emailcommon.provider;
-import com.android.email.Utility;
-import com.android.email.provider.EmailProvider;
import com.android.emailcommon.mail.Snippet;
+import com.android.emailcommon.utility.Utility;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
@@ -63,8 +62,13 @@ import java.util.UUID;
*
*/
public abstract class EmailContent {
- public static final String AUTHORITY = EmailProvider.EMAIL_AUTHORITY;
- public static final String NOTIFIER_AUTHORITY = EmailProvider.EMAIL_NOTIFIER_AUTHORITY;
+
+ public static final String AUTHORITY = "com.android.email.provider";
+ // The notifier authority is used to send notifications regarding changes to messages (insert,
+ // delete, or update) and is intended as an optimization for use by clients of message list
+ // cursors (initially, the email AppWidget).
+ public static final String NOTIFIER_AUTHORITY = "com.android.email.notifier";
+
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
public static final String PARAMETER_LIMIT = "limit";
@@ -798,7 +802,7 @@ public abstract class EmailContent {
addSaveOps(ops);
try {
ContentProviderResult[] results =
- context.getContentResolver().applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
+ context.getContentResolver().applyBatch(AUTHORITY, ops);
// If saving, set the mId's of the various saved objects
if (doSave) {
Uri u = results[0].uri;
@@ -1469,7 +1473,7 @@ public abstract class EmailContent {
public static long getAccountIdFromShortcutSafeUri(Context context, Uri uri) {
// Make sure the URI is in the correct format.
if (!"content".equals(uri.getScheme())
- || !EmailContent.AUTHORITY.equals(uri.getAuthority())) {
+ || !AUTHORITY.equals(uri.getAuthority())) {
return -1;
}
@@ -1635,7 +1639,7 @@ public abstract class EmailContent {
.newUpdate(ContentUris.withAppendedId(CONTENT_URI, mId))
.withValues(cv).build());
try {
- context.getContentResolver().applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
+ context.getContentResolver().applyBatch(AUTHORITY, ops);
return 1;
} catch (RemoteException e) {
// There is nothing to be done here; fail by returning 0
@@ -1714,7 +1718,7 @@ public abstract class EmailContent {
try {
ContentProviderResult[] results =
- context.getContentResolver().applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
+ context.getContentResolver().applyBatch(AUTHORITY, ops);
// If saving, set the mId's of the various saved objects
if (recvIndex >= 0) {
long newId = getId(results[recvIndex].uri);
diff --git a/src/com/android/emailcommon/utility/AccountReconciler.java b/src/com/android/emailcommon/utility/AccountReconciler.java
index 63bbc2cf2..6958d205c 100644
--- a/src/com/android/emailcommon/utility/AccountReconciler.java
+++ b/src/com/android/emailcommon/utility/AccountReconciler.java
@@ -16,7 +16,7 @@
package com.android.emailcommon.utility;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Account;
import android.accounts.AccountManager;
@@ -65,14 +65,13 @@ public class AccountReconciler {
}
if (!found) {
if ((providerAccount.mFlags & Account.FLAGS_INCOMPLETE) != 0) {
- if (Email.DEBUG) {
- Log.d(Email.LOG_TAG,
- "Account reconciler noticed incomplete account; ignoring");
- }
+ Log.w(Logging.LOG_TAG,
+ "Account reconciler noticed incomplete account; ignoring");
continue;
}
// This account has been deleted in the AccountManager!
- Log.d(Email.LOG_TAG, "Account deleted in AccountManager; deleting from provider: " +
+ Log.d(Logging.LOG_TAG,
+ "Account deleted in AccountManager; deleting from provider: " +
providerAccountName);
// TODO This will orphan downloaded attachments; need to handle this
resolver.delete(ContentUris.withAppendedId(Account.CONTENT_URI,
@@ -92,7 +91,7 @@ public class AccountReconciler {
}
if (!found) {
// This account has been deleted from the EmailProvider database
- Log.d(Email.LOG_TAG,
+ Log.d(Logging.LOG_TAG,
"Account deleted from provider; deleting from AccountManager: " +
accountManagerAccountName);
// Delete the account
@@ -103,11 +102,11 @@ public class AccountReconciler {
// here, as there is nothing to actually do about them.
blockingResult.getResult();
} catch (OperationCanceledException e) {
- Log.w(Email.LOG_TAG, e.toString());
+ Log.w(Logging.LOG_TAG, e.toString());
} catch (AuthenticatorException e) {
- Log.w(Email.LOG_TAG, e.toString());
+ Log.w(Logging.LOG_TAG, e.toString());
} catch (IOException e) {
- Log.w(Email.LOG_TAG, e.toString());
+ Log.w(Logging.LOG_TAG, e.toString());
}
accountsDeleted = true;
}
diff --git a/src/com/android/emailcommon/utility/AttachmentUtilities.java b/src/com/android/emailcommon/utility/AttachmentUtilities.java
index 81725bf33..12954c667 100644
--- a/src/com/android/emailcommon/utility/AttachmentUtilities.java
+++ b/src/com/android/emailcommon/utility/AttachmentUtilities.java
@@ -16,7 +16,7 @@
package com.android.emailcommon.utility;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
@@ -46,6 +46,83 @@ public class AttachmentUtilities {
public static final String SIZE = "_size";
}
+ /**
+ * The MIME type(s) of attachments we're willing to send via attachments.
+ *
+ * Any attachments may be added via Intents with Intent.ACTION_SEND or ACTION_SEND_MULTIPLE.
+ */
+ public static final String[] ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES = new String[] {
+ "*/*",
+ };
+ /**
+ * The MIME type(s) of attachments we're willing to send from the internal UI.
+ *
+ * NOTE: At the moment it is not possible to open a chooser with a list of filter types, so
+ * the chooser is only opened with the first item in the list.
+ */
+ public static final String[] ACCEPTABLE_ATTACHMENT_SEND_UI_TYPES = new String[] {
+ "image/*",
+ "video/*",
+ };
+ /**
+ * The MIME type(s) of attachments we're willing to view.
+ */
+ public static final String[] ACCEPTABLE_ATTACHMENT_VIEW_TYPES = new String[] {
+ "*/*",
+ };
+ /**
+ * The MIME type(s) of attachments we're not willing to view.
+ */
+ public static final String[] UNACCEPTABLE_ATTACHMENT_VIEW_TYPES = new String[] {
+ };
+ /**
+ * The MIME type(s) of attachments we're willing to download to SD.
+ */
+ public static final String[] ACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES = new String[] {
+ "*/*",
+ };
+ /**
+ * The MIME type(s) of attachments we're not willing to download to SD.
+ */
+ public static final String[] UNACCEPTABLE_ATTACHMENT_DOWNLOAD_TYPES = new String[] {
+ };
+ /**
+ * Filename extensions of attachments we're never willing to download (potential malware).
+ * Entries in this list are compared to the end of the lower-cased filename, so they must
+ * be lower case, and should not include a "."
+ */
+ public static final String[] UNACCEPTABLE_ATTACHMENT_EXTENSIONS = new String[] {
+ // File types that contain malware
+ "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "dll", "exe",
+ "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
+ "mst", "pif", "scr", "sct", "shb", "sys", "vb", "vbe",
+ "vbs", "vxd", "wsc", "wsf", "wsh",
+ // File types of common compression/container formats (again, to avoid malware)
+ "zip", "gz", "z", "tar", "tgz", "bz2",
+ };
+ /**
+ * Filename extensions of attachments that can be installed.
+ * Entries in this list are compared to the end of the lower-cased filename, so they must
+ * be lower case, and should not include a "."
+ */
+ public static final String[] INSTALLABLE_ATTACHMENT_EXTENSIONS = new String[] {
+ "apk",
+ };
+ /**
+ * The maximum size of an attachment we're willing to download (either View or Save)
+ * Attachments that are base64 encoded (most) will be about 1.375x their actual size
+ * so we should probably factor that in. A 5MB attachment will generally be around
+ * 6.8MB downloaded but only 5MB saved.
+ */
+ public static final int MAX_ATTACHMENT_DOWNLOAD_SIZE = (5 * 1024 * 1024);
+ /**
+ * The maximum size of an attachment we're willing to upload (measured as stored on disk).
+ * Attachments that are base64 encoded (most) will be about 1.375x their actual size
+ * so we should probably factor that in. A 5MB attachment will generally be around
+ * 6.8MB uploaded.
+ */
+ public static final int MAX_ATTACHMENT_UPLOAD_SIZE = (5 * 1024 * 1024);
+
public static Uri getAttachmentUri(long accountId, long id) {
return CONTENT_URI.buildUpon()
.appendPath(Long.toString(accountId))
@@ -251,7 +328,7 @@ public class AttachmentUtilities {
for (File file : files) {
boolean result = file.delete();
if (!result) {
- Log.e(Email.LOG_TAG, "Failed to delete attachment file " + file.getName());
+ Log.e(Logging.LOG_TAG, "Failed to delete attachment file " + file.getName());
}
}
}
diff --git a/src/com/android/email/mail/transport/LoggingInputStream.java b/src/com/android/emailcommon/utility/LoggingInputStream.java
similarity index 93%
rename from src/com/android/email/mail/transport/LoggingInputStream.java
rename to src/com/android/emailcommon/utility/LoggingInputStream.java
index 202b779ac..212efa183 100644
--- a/src/com/android/email/mail/transport/LoggingInputStream.java
+++ b/src/com/android/emailcommon/utility/LoggingInputStream.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package com.android.email.mail.transport;
+package com.android.emailcommon.utility;
-import com.android.email.Email;
-import com.android.email.Utility;
+import com.android.emailcommon.Logging;
import android.util.Log;
@@ -45,7 +44,7 @@ public class LoggingInputStream extends FilterInputStream {
mTag = tag + " ";
mDumpEmptyLines = dumpEmptyLines;
initBuffer();
- Log.d(Email.LOG_TAG, mTag + "dump start");
+ Log.d(Logging.LOG_TAG, mTag + "dump start");
}
private void initBuffer() {
@@ -97,7 +96,7 @@ public class LoggingInputStream extends FilterInputStream {
private void flushLog() {
if (mDumpEmptyLines || (mSb.length() > mTag.length())) {
- Log.d(Email.LOG_TAG, mSb.toString());
+ Log.d(Logging.LOG_TAG, mSb.toString());
initBuffer();
}
}
diff --git a/src/com/android/email/Utility.java b/src/com/android/emailcommon/utility/Utility.java
similarity index 87%
rename from src/com/android/email/Utility.java
rename to src/com/android/emailcommon/utility/Utility.java
index c03a8cc07..a02529e89 100644
--- a/src/com/android/email/Utility.java
+++ b/src/com/android/emailcommon/utility/Utility.java
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package com.android.email;
+package com.android.emailcommon.utility;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
@@ -34,12 +35,9 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
@@ -327,106 +325,6 @@ public class Utility {
return selection.toString();
}
-
- // TODO When the UI is settled, cache all strings/drawables
- // TODO When the UI is settled, write up tests
- // TODO When the UI is settled, remove backward-compatibility methods
- public static class FolderProperties {
-
- private static FolderProperties sInstance;
-
- private final Context mContext;
-
- // Caches for frequently accessed resources.
- private final String[] mSpecialMailbox;
- private final TypedArray mSpecialMailboxDrawable;
- private final Drawable mSummaryStarredMailboxDrawable;
- private final Drawable mSummaryCombinedInboxDrawable;
-
- private FolderProperties(Context context) {
- mContext = context.getApplicationContext();
- mSpecialMailbox = context.getResources().getStringArray(R.array.mailbox_display_names);
- for (int i = 0; i < mSpecialMailbox.length; ++i) {
- if ("".equals(mSpecialMailbox[i])) {
- // there is no localized name, so use the display name from the server
- mSpecialMailbox[i] = null;
- }
- }
- mSpecialMailboxDrawable =
- context.getResources().obtainTypedArray(R.array.mailbox_display_icons);
- mSummaryStarredMailboxDrawable =
- context.getResources().getDrawable(R.drawable.ic_folder_star_holo_light);
- mSummaryCombinedInboxDrawable =
- context.getResources().getDrawable(R.drawable.ic_list_combined_inbox);
- }
-
- public static synchronized FolderProperties getInstance(Context context) {
- if (sInstance == null) {
- sInstance = new FolderProperties(context);
- }
- return sInstance;
- }
-
- // For backward compatibility.
- public String getDisplayName(int type) {
- return getDisplayName(type, -1);
- }
-
- // For backward compatibility.
- public Drawable getSummaryMailboxIconIds(long id) {
- return getIcon(-1, id);
- }
-
- /**
- * Lookup names of localized special mailboxes
- */
- public String getDisplayName(int type, long mailboxId) {
- // Special combined mailboxes
- int resId = 0;
-
- // Can't use long for switch!?
- if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
- resId = R.string.account_folder_list_summary_inbox;
- } else if (mailboxId == Mailbox.QUERY_ALL_FAVORITES) {
- resId = R.string.account_folder_list_summary_starred;
- } else if (mailboxId == Mailbox.QUERY_ALL_DRAFTS) {
- resId = R.string.account_folder_list_summary_drafts;
- } else if (mailboxId == Mailbox.QUERY_ALL_OUTBOX) {
- resId = R.string.account_folder_list_summary_outbox;
- }
- if (resId != 0) {
- return mContext.getString(resId);
- }
-
- if (type < mSpecialMailbox.length) {
- return mSpecialMailbox[type];
- }
- return null;
- }
-
- /**
- * Lookup icons of special mailboxes
- */
- public Drawable getIcon(int type, long mailboxId) {
- if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
- return mSummaryCombinedInboxDrawable;
- } else if (mailboxId == Mailbox.QUERY_ALL_FAVORITES) {
- return mSummaryStarredMailboxDrawable;
- } else if (mailboxId == Mailbox.QUERY_ALL_DRAFTS) {
- return mSpecialMailboxDrawable.getDrawable(Mailbox.TYPE_DRAFTS);
- } else if (mailboxId == Mailbox.QUERY_ALL_OUTBOX) {
- return mSpecialMailboxDrawable.getDrawable(Mailbox.TYPE_OUTBOX);
- }
- if (0 <= type && type < mSpecialMailboxDrawable.length()) {
- final int resId = mSpecialMailboxDrawable.getResourceId(type, -1);
- if (resId != -1) {
- return mContext.getResources().getDrawable(resId);
- }
- }
- return null; // No icon
- }
- }
-
private final static String HOSTAUTH_WHERE_CREDENTIALS = HostAuthColumns.ADDRESS + " like ?"
+ " and " + HostAuthColumns.LOGIN + " like ?"
+ " and " + HostAuthColumns.PROTOCOL + " not like \"smtp\"";
@@ -623,7 +521,7 @@ public class Utility {
return null;
}
} catch (Exception e) {
- Log.d(Email.LOG_TAG, "Error in TelephonyManager.getDeviceId(): " + e.getMessage());
+ Log.d(Logging.LOG_TAG, "Error in TelephonyManager.getDeviceId(): " + e.getMessage());
return null;
}
return getSmallHash(deviceId);
@@ -712,34 +610,6 @@ public class Utility {
}.execute();
}
- /**
- * Formats the given size as a String in bytes, kB, MB or GB. Ex: 12,315,000 = 11 MB
- */
- public static String formatSize(Context context, long size) {
- final Resources res = context.getResources();
- final long KB = 1024;
- final long MB = (KB * 1024);
- final long GB = (MB * 1024);
-
- int resId;
- int value;
-
- if (size < KB) {
- resId = R.plurals.message_view_attachment_bytes;
- value = (int) size;
- } else if (size < MB) {
- resId = R.plurals.message_view_attachment_kilobytes;
- value = (int) (size / KB);
- } else if (size < GB) {
- resId = R.plurals.message_view_attachment_megabytes;
- value = (int) (size / MB);
- } else {
- resId = R.plurals.message_view_attachment_gigabytes;
- value = (int) (size / GB);
- }
- return res.getQuantityString(resId, value, value);
- }
-
/**
* Interface used in {@link #createUniqueFile} instead of {@link File#createNewFile()} to make
* it testable.
@@ -984,7 +854,7 @@ public class Utility {
return false;
}
} catch (RuntimeException re) {
- Log.w(Email.LOG_TAG, "attachmentExists RuntimeException=" + re);
+ Log.w(Logging.LOG_TAG, "attachmentExists RuntimeException=" + re);
return false;
}
}
@@ -1009,7 +879,7 @@ public class Utility {
// alternative. In theory, this situation shouldn't be possible.
if ((att.mFlags & (Attachment.FLAG_DOWNLOAD_FORWARD |
Attachment.FLAG_DOWNLOAD_USER_REQUEST)) == 0) {
- Log.d(Email.LOG_TAG, "Unloaded attachment isn't marked for download: " +
+ Log.d(Logging.LOG_TAG, "Unloaded attachment isn't marked for download: " +
att.mFileName + ", #" + att.mId);
Attachment.delete(context, Attachment.CONTENT_URI, att.mId);
} else if (att.mContentUri != null) {
@@ -1232,9 +1102,10 @@ public class Utility {
return;
}
if (c.isClosed()) {
- Log.w(Email.LOG_TAG, "Cursor was closed here: Cursor=" + c, getTraceIfAvailable(c));
+ Log.w(Logging.LOG_TAG, "Cursor was closed here: Cursor=" + c,
+ getTraceIfAvailable(c));
} else {
- Log.w(Email.LOG_TAG, "Cursor not closed. Cursor=" + c);
+ Log.w(Logging.LOG_TAG, "Cursor not closed. Cursor=" + c);
}
}
@@ -1259,15 +1130,4 @@ public class Utility {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return i;
}
-
- public static String getMessageCountForUi(Context context, int count,
- boolean replaceZeroWithBlank) {
- if (replaceZeroWithBlank && (count == 0)) {
- return "";
- } else if (count > 999) {
- return context.getString(R.string.more_than_999);
- } else {
- return Integer.toString(count);
- }
- }
}
diff --git a/src/com/android/exchange/CalendarSyncEnabler.java b/src/com/android/exchange/CalendarSyncEnabler.java
index 0754885fe..fd2110642 100644
--- a/src/com/android/exchange/CalendarSyncEnabler.java
+++ b/src/com/android/exchange/CalendarSyncEnabler.java
@@ -19,6 +19,7 @@ package com.android.exchange;
import com.android.email.Email;
import com.android.email.NotificationController;
import com.android.email.R;
+import com.android.emailcommon.Logging;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -73,7 +74,7 @@ public class CalendarSyncEnabler {
.getAccountsByType(Email.EXCHANGE_ACCOUNT_MANAGER_TYPE);
for (Account account : exchangeAccounts) {
final String emailAddress = account.name;
- Log.i(Email.LOG_TAG, "Enabling Exchange calendar sync for " + emailAddress);
+ Log.i(Logging.LOG_TAG, "Enabling Exchange calendar sync for " + emailAddress);
ContentResolver.setIsSyncable(account, Calendar.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, Calendar.AUTHORITY, true);
diff --git a/src/com/android/exchange/ContactsSyncAdapterService.java b/src/com/android/exchange/ContactsSyncAdapterService.java
index f43d1ae95..579e7ae86 100644
--- a/src/com/android/exchange/ContactsSyncAdapterService.java
+++ b/src/com/android/exchange/ContactsSyncAdapterService.java
@@ -105,9 +105,6 @@ public class ContactsSyncAdapterService extends Service {
String authority, ContentProviderClient provider, SyncResult syncResult)
throws OperationCanceledException {
ContentResolver cr = context.getContentResolver();
- if (Email.DEBUG) {
- Log.d(TAG, "performSync");
- }
// If we've been asked to do an upload, make sure we've got work to do
if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD)) {
diff --git a/src/com/android/exchange/EasOutboxService.java b/src/com/android/exchange/EasOutboxService.java
index de341ad35..3633911d4 100644
--- a/src/com/android/exchange/EasOutboxService.java
+++ b/src/com/android/exchange/EasOutboxService.java
@@ -17,8 +17,7 @@
package com.android.exchange;
-import com.android.email.Utility;
-import com.android.email.mail.transport.Rfc822Output;
+import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Body;
@@ -29,6 +28,7 @@ import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
import com.android.emailcommon.provider.EmailContent.SyncColumns;
import com.android.emailcommon.service.EmailServiceStatus;
+import com.android.emailcommon.utility.Utility;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index cd4e8397d..27f4760a9 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -17,7 +17,6 @@
package com.android.exchange;
-import com.android.email.Utility;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MeetingInfo;
import com.android.emailcommon.mail.MessagingException;
@@ -37,6 +36,7 @@ import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.PolicyServiceProxy;
import com.android.emailcommon.service.PolicySet;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.adapter.AbstractSyncAdapter;
import com.android.exchange.adapter.AccountSyncAdapter;
import com.android.exchange.adapter.CalendarSyncAdapter;
@@ -46,11 +46,11 @@ import com.android.exchange.adapter.FolderSyncParser;
import com.android.exchange.adapter.GalParser;
import com.android.exchange.adapter.MeetingResponseParser;
import com.android.exchange.adapter.MoveItemsParser;
+import com.android.exchange.adapter.Parser.EasParserException;
import com.android.exchange.adapter.PingParser;
import com.android.exchange.adapter.ProvisionParser;
import com.android.exchange.adapter.Serializer;
import com.android.exchange.adapter.Tags;
-import com.android.exchange.adapter.Parser.EasParserException;
import com.android.exchange.provider.GalResult;
import com.android.exchange.utility.CalendarUtilities;
diff --git a/src/com/android/exchange/ExchangeService.java b/src/com/android/exchange/ExchangeService.java
index a3b153dc3..8f8083534 100644
--- a/src/com/android/exchange/ExchangeService.java
+++ b/src/com/android/exchange/ExchangeService.java
@@ -18,10 +18,9 @@
package com.android.exchange;
import com.android.email.Email;
-import com.android.email.Utility;
import com.android.email.mail.transport.SSLUtils;
-import com.android.email.provider.EmailProvider;
import com.android.emailcommon.Api;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Attachment;
@@ -36,6 +35,7 @@ import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.IEmailService;
import com.android.emailcommon.service.IEmailServiceCallback;
import com.android.emailcommon.utility.AccountReconciler;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.adapter.CalendarSyncAdapter;
import com.android.exchange.adapter.ContactsSyncAdapter;
import com.android.exchange.utility.FileLogger;
@@ -67,21 +67,21 @@ import android.database.ContentObserver;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
-import android.net.Uri;
import android.net.NetworkInfo.State;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
-import android.os.PowerManager.WakeLock;
import android.provider.Calendar;
-import android.provider.ContactsContract;
import android.provider.Calendar.Calendars;
import android.provider.Calendar.Events;
+import android.provider.ContactsContract;
import android.util.Log;
import java.io.BufferedReader;
@@ -1112,10 +1112,10 @@ public class ExchangeService extends Service implements Runnable {
rdr.close();
return id;
} else {
- Log.w(Email.LOG_TAG, f.getAbsolutePath() + ": File exists, but can't read?" +
+ Log.w(Logging.LOG_TAG, f.getAbsolutePath() + ": File exists, but can't read?" +
" Trying to remove.");
if (!f.delete()) {
- Log.w(Email.LOG_TAG, "Remove failed. Tring to overwrite.");
+ Log.w(Logging.LOG_TAG, "Remove failed. Tring to overwrite.");
}
}
}
@@ -1530,7 +1530,7 @@ public class ExchangeService extends Service implements Runnable {
for (Account account : mAccountList) {
updatePIMSyncSettings(account, Mailbox.TYPE_CONTACTS, ContactsContract.AUTHORITY);
updatePIMSyncSettings(account, Mailbox.TYPE_CALENDAR, Calendar.AUTHORITY);
- updatePIMSyncSettings(account, Mailbox.TYPE_INBOX, EmailProvider.EMAIL_AUTHORITY);
+ updatePIMSyncSettings(account, Mailbox.TYPE_INBOX, EmailContent.AUTHORITY);
}
}
}
@@ -2109,7 +2109,7 @@ public class ExchangeService extends Service implements Runnable {
continue;
} else if (type < Mailbox.TYPE_NOT_EMAIL &&
!ContentResolver.getSyncAutomatically(accountManagerAccount,
- EmailProvider.EMAIL_AUTHORITY)) {
+ EmailContent.AUTHORITY)) {
// Don't sync mail if user hasn't chosen to sync it automatically
continue;
}
diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
index edfc1c3f8..7a3066074 100644
--- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java
+++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
@@ -18,9 +18,9 @@
package com.android.exchange.adapter;
import com.android.email.Email;
-import com.android.email.Utility;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.Eas;
import com.android.exchange.EasOutboxService;
import com.android.exchange.EasSyncService;
diff --git a/src/com/android/exchange/adapter/EmailSyncAdapter.java b/src/com/android/exchange/adapter/EmailSyncAdapter.java
index 81f9c50e5..1ab904e4b 100644
--- a/src/com/android/exchange/adapter/EmailSyncAdapter.java
+++ b/src/com/android/exchange/adapter/EmailSyncAdapter.java
@@ -17,8 +17,6 @@
package com.android.exchange.adapter;
-import com.android.email.Utility;
-import com.android.email.provider.EmailProvider;
import com.android.emailcommon.internet.MimeMessage;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.mail.Address;
@@ -39,6 +37,7 @@ import com.android.emailcommon.service.AccountServiceProxy;
import com.android.emailcommon.service.SyncWindow;
import com.android.emailcommon.utility.AttachmentUtilities;
import com.android.emailcommon.utility.ConversionUtilities;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.Eas;
import com.android.exchange.EasSyncService;
import com.android.exchange.MessageMoveRequest;
@@ -805,7 +804,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
synchronized (mService.getSynchronizer()) {
if (mService.isStopped()) return;
try {
- mContentResolver.applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
+ mContentResolver.applyBatch(EmailContent.AUTHORITY, ops);
userLog(mMailbox.mDisplayName, " SyncKey saved as: ", mMailbox.mSyncKey);
} catch (RemoteException e) {
// There is nothing to be done here; fail by returning null
@@ -863,7 +862,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
addCleanupOps(ops);
try {
mContext.getContentResolver()
- .applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
+ .applyBatch(EmailContent.AUTHORITY, ops);
} catch (RemoteException e) {
// There is nothing to be done here; fail by returning null
} catch (OperationApplicationException e) {
diff --git a/src/com/android/exchange/adapter/FolderSyncParser.java b/src/com/android/exchange/adapter/FolderSyncParser.java
index e2b493526..22466d0d9 100644
--- a/src/com/android/exchange/adapter/FolderSyncParser.java
+++ b/src/com/android/exchange/adapter/FolderSyncParser.java
@@ -17,18 +17,16 @@
package com.android.exchange.adapter;
-import com.android.email.Utility;
-import com.android.email.provider.EmailProvider;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.Eas;
import com.android.exchange.ExchangeService;
import com.android.exchange.MockParserStream;
-import com.android.exchange.adapter.Parser.EasParserException;
import android.content.ContentProviderOperation;
import android.content.ContentUris;
@@ -396,7 +394,7 @@ public class FolderSyncParser extends AbstractSyncParser {
// Execute the batch; throw IOExceptions if this fails, hoping the issue isn't repeatable
// If it IS repeatable, there's no good result, since the folder list will be invalid
try {
- mContentResolver.applyBatch(EmailProvider.EMAIL_AUTHORITY, mOperations);
+ mContentResolver.applyBatch(EmailContent.AUTHORITY, mOperations);
return true;
} catch (RemoteException e) {
userLog("RemoteException in commitMailboxes");
diff --git a/src/com/android/exchange/adapter/Serializer.java b/src/com/android/exchange/adapter/Serializer.java
index bd16909f4..ec1122dbb 100644
--- a/src/com/android/exchange/adapter/Serializer.java
+++ b/src/com/android/exchange/adapter/Serializer.java
@@ -23,7 +23,6 @@
package com.android.exchange.adapter;
-import com.android.email.Email;
import com.android.exchange.Eas;
import com.android.exchange.utility.FileLogger;
@@ -38,7 +37,7 @@ import java.util.Hashtable;
public class Serializer {
private static final String TAG = "Serializer";
- private boolean logging = Email.DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
+ private boolean logging = Log.isLoggable(TAG, Log.VERBOSE);
private static final int NOT_PENDING = -1;
diff --git a/src/com/android/exchange/provider/ExchangeDirectoryProvider.java b/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
index 4ead4c16c..77937634d 100644
--- a/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
+++ b/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
@@ -17,13 +17,13 @@
package com.android.exchange.provider;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.Configuration;
import com.android.emailcommon.mail.PackedString;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.service.AccountServiceProxy;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.EasSyncService;
import com.android.exchange.provider.GalResult.GalData;
diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java
index 76eac7830..96ba438d9 100644
--- a/src/com/android/exchange/utility/CalendarUtilities.java
+++ b/src/com/android/exchange/utility/CalendarUtilities.java
@@ -18,7 +18,6 @@ package com.android.exchange.utility;
import com.android.email.Email;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -26,6 +25,7 @@ import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.service.AccountServiceProxy;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.Eas;
import com.android.exchange.EasSyncService;
import com.android.exchange.ExchangeService;
@@ -37,8 +37,8 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Entity;
-import android.content.EntityIterator;
import android.content.Entity.NamedContentValues;
+import android.content.EntityIterator;
import android.content.res.Resources;
import android.net.Uri;
import android.os.RemoteException;
diff --git a/src/com/android/exchange/utility/SimpleIcsWriter.java b/src/com/android/exchange/utility/SimpleIcsWriter.java
index f39b8d339..9980c962f 100644
--- a/src/com/android/exchange/utility/SimpleIcsWriter.java
+++ b/src/com/android/exchange/utility/SimpleIcsWriter.java
@@ -15,13 +15,12 @@
package com.android.exchange.utility;
-import com.android.email.Utility;
+import com.android.emailcommon.utility.Utility;
import android.text.TextUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
/**
* Class to generate iCalender object (*.ics) per RFC 5545.
diff --git a/src/org/apache/james/mime4j/Log.java b/src/org/apache/james/mime4j/Log.java
index 1752a9795..e7f33fcc7 100644
--- a/src/org/apache/james/mime4j/Log.java
+++ b/src/org/apache/james/mime4j/Log.java
@@ -16,7 +16,7 @@
package org.apache.james.mime4j;
-import com.android.email.Email;
+import com.android.emailcommon.Logging;
/**
* Empty stub for the apache logging library.
@@ -26,7 +26,7 @@ public class Log {
}
public boolean isDebugEnabled() {
- return Email.LOGD;
+ return false;
}
public boolean isErrorEnabled() {
@@ -38,69 +38,69 @@ public class Log {
}
public boolean isInfoEnabled() {
- return Email.LOGD;
+ return false;
}
public boolean isTraceEnabled() {
- return Email.LOGD;
+ return false;
}
public boolean isWarnEnabled() {
- return Email.DEBUG;
+ return true;
}
public void trace(Object message) {
if (!isTraceEnabled()) return;
- android.util.Log.v(Email.LOG_TAG, toString(message, null));
+ android.util.Log.v(Logging.LOG_TAG, toString(message, null));
}
public void trace(Object message, Throwable t) {
if (!isTraceEnabled()) return;
- android.util.Log.v(Email.LOG_TAG, toString(message, t));
+ android.util.Log.v(Logging.LOG_TAG, toString(message, t));
}
public void debug(Object message) {
if (!isDebugEnabled()) return;
- android.util.Log.d(Email.LOG_TAG, toString(message, null));
+ android.util.Log.d(Logging.LOG_TAG, toString(message, null));
}
public void debug(Object message, Throwable t) {
if (!isDebugEnabled()) return;
- android.util.Log.d(Email.LOG_TAG, toString(message, t));
+ android.util.Log.d(Logging.LOG_TAG, toString(message, t));
}
public void info(Object message) {
if (!isInfoEnabled()) return;
- android.util.Log.i(Email.LOG_TAG, toString(message, null));
+ android.util.Log.i(Logging.LOG_TAG, toString(message, null));
}
public void info(Object message, Throwable t) {
if (!isInfoEnabled()) return;
- android.util.Log.i(Email.LOG_TAG, toString(message, t));
+ android.util.Log.i(Logging.LOG_TAG, toString(message, t));
}
public void warn(Object message) {
- android.util.Log.w(Email.LOG_TAG, toString(message, null));
+ android.util.Log.w(Logging.LOG_TAG, toString(message, null));
}
public void warn(Object message, Throwable t) {
- android.util.Log.w(Email.LOG_TAG, toString(message, t));
+ android.util.Log.w(Logging.LOG_TAG, toString(message, t));
}
public void error(Object message) {
- android.util.Log.e(Email.LOG_TAG, toString(message, null));
+ android.util.Log.e(Logging.LOG_TAG, toString(message, null));
}
public void error(Object message, Throwable t) {
- android.util.Log.e(Email.LOG_TAG, toString(message, t));
+ android.util.Log.e(Logging.LOG_TAG, toString(message, t));
}
public void fatal(Object message) {
- android.util.Log.e(Email.LOG_TAG, toString(message, null));
+ android.util.Log.e(Logging.LOG_TAG, toString(message, null));
}
public void fatal(Object message, Throwable t) {
- android.util.Log.e(Email.LOG_TAG, toString(message, t));
+ android.util.Log.e(Logging.LOG_TAG, toString(message, t));
}
private static String toString(Object o, Throwable t) {
diff --git a/src/org/apache/james/mime4j/MimeStreamParser.java b/src/org/apache/james/mime4j/MimeStreamParser.java
index fc4bb3557..e5fe97cdd 100644
--- a/src/org/apache/james/mime4j/MimeStreamParser.java
+++ b/src/org/apache/james/mime4j/MimeStreamParser.java
@@ -19,8 +19,7 @@
package org.apache.james.mime4j;
-import com.android.email.Email;
-import com.android.email.mail.transport.LoggingInputStream;
+import com.android.emailcommon.utility.LoggingInputStream;
import org.apache.james.mime4j.decoder.Base64InputStream;
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
@@ -85,7 +84,7 @@ public class MimeStreamParser {
* @throws IOException on I/O errors.
*/
public void parse(InputStream is) throws IOException {
- if (DEBUG_LOG_MESSAGE && Email.DEBUG) {
+ if (DEBUG_LOG_MESSAGE) {
is = new LoggingInputStream(is, "MIME", true);
}
rootStream = new RootInputStream(is);
diff --git a/src/org/apache/james/mime4j/field/DateTimeField.java b/src/org/apache/james/mime4j/field/DateTimeField.java
index a3bc71126..e65551fcd 100644
--- a/src/org/apache/james/mime4j/field/DateTimeField.java
+++ b/src/org/apache/james/mime4j/field/DateTimeField.java
@@ -20,9 +20,11 @@
package org.apache.james.mime4j.field;
//BEGIN android-changed: Stubbing out logging
+import com.android.emailcommon.utility.Utility;
+
import org.apache.james.mime4j.Log;
import org.apache.james.mime4j.LogFactory;
-//END android-changed
+//END
import org.apache.james.mime4j.field.datetime.DateTime;
import org.apache.james.mime4j.field.datetime.parser.ParseException;
@@ -53,7 +55,7 @@ public class DateTimeField extends Field {
Date date = null;
ParseException parseException = null;
//BEGIN android-changed
- body = com.android.email.Utility.cleanUpMimeDate(body);
+ body = Utility.cleanUpMimeDate(body);
//END android-changed
try {
date = DateTime.parse(body).getDate();
diff --git a/tests/src/com/android/email/AccountBackupRestoreTests.java b/tests/src/com/android/email/AccountBackupRestoreTests.java
index 577d4d2ba..00cb34734 100644
--- a/tests/src/com/android/email/AccountBackupRestoreTests.java
+++ b/tests/src/com/android/email/AccountBackupRestoreTests.java
@@ -42,7 +42,7 @@ public class AccountBackupRestoreTests extends ProviderTestCase2
private Context mMockContext;
public AccountBackupRestoreTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/AccountTestCase.java b/tests/src/com/android/email/AccountTestCase.java
index 10ae5864f..f6fff0301 100644
--- a/tests/src/com/android/email/AccountTestCase.java
+++ b/tests/src/com/android/email/AccountTestCase.java
@@ -18,6 +18,7 @@ package com.android.email;
import com.android.email.provider.EmailProvider;
import com.android.email.provider.ProviderTestUtils;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import android.accounts.AccountManager;
@@ -40,7 +41,7 @@ public abstract class AccountTestCase extends ProviderTestCase2 {
protected static final String TEST_ACCOUNT_SUFFIX = "@android.com";
public AccountTestCase() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
protected android.accounts.Account[] getExchangeAccounts() {
diff --git a/tests/src/com/android/email/AccountUnitTests.java b/tests/src/com/android/email/AccountUnitTests.java
index 177355899..89fb4b53a 100644
--- a/tests/src/com/android/email/AccountUnitTests.java
+++ b/tests/src/com/android/email/AccountUnitTests.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.utility.Utility;
+
import android.content.SharedPreferences;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
diff --git a/tests/src/com/android/email/ControllerProviderOpsTests.java b/tests/src/com/android/email/ControllerProviderOpsTests.java
index ede2d1fd7..4495907f8 100644
--- a/tests/src/com/android/email/ControllerProviderOpsTests.java
+++ b/tests/src/com/android/email/ControllerProviderOpsTests.java
@@ -51,7 +51,7 @@ public class ControllerProviderOpsTests extends ProviderTestCase2
public ControllerProviderOpsTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/DBTestHelper.java b/tests/src/com/android/email/DBTestHelper.java
index d8b3a26e0..964973a16 100644
--- a/tests/src/com/android/email/DBTestHelper.java
+++ b/tests/src/com/android/email/DBTestHelper.java
@@ -55,7 +55,7 @@ public final class DBTestHelper {
public MyContext() {
mProvider = new MyProvider();
mContentResolver = new MockContentResolver();
- mContentResolver.addProvider(EmailProvider.EMAIL_AUTHORITY, mProvider);
+ mContentResolver.addProvider(EmailContent.AUTHORITY, mProvider);
}
@Override
diff --git a/tests/src/com/android/email/LegacyConversionsTests.java b/tests/src/com/android/email/LegacyConversionsTests.java
index 246bed232..4bc0954ff 100644
--- a/tests/src/com/android/email/LegacyConversionsTests.java
+++ b/tests/src/com/android/email/LegacyConversionsTests.java
@@ -27,12 +27,12 @@ import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.BodyPart;
import com.android.emailcommon.mail.Flag;
import com.android.emailcommon.mail.Message;
-import com.android.emailcommon.mail.MessageTestUtils;
-import com.android.emailcommon.mail.MessagingException;
-import com.android.emailcommon.mail.Part;
import com.android.emailcommon.mail.Message.RecipientType;
+import com.android.emailcommon.mail.MessageTestUtils;
import com.android.emailcommon.mail.MessageTestUtils.MessageBuilder;
import com.android.emailcommon.mail.MessageTestUtils.MultipartBuilder;
+import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.mail.Part;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.utility.ConversionUtilities;
@@ -76,7 +76,7 @@ public class LegacyConversionsTests extends ProviderTestCase2 {
Preferences mPreferences = null;
public LegacyConversionsTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/RefreshManagerTest.java b/tests/src/com/android/email/RefreshManagerTest.java
index 097417e46..30fdd8c51 100644
--- a/tests/src/com/android/email/RefreshManagerTest.java
+++ b/tests/src/com/android/email/RefreshManagerTest.java
@@ -17,6 +17,7 @@
package com.android.email;
import com.android.email.provider.ProviderTestUtils;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -172,7 +173,7 @@ public class RefreshManagerTest extends InstrumentationTestCase {
assertEquals(0, mTarget.getMailboxListStatusForTest(ACCOUNT_1).getLastRefreshTime());
// Done.
- Log.w(Email.LOG_TAG, "" + mController.mListener.getClass());
+ Log.w(Logging.LOG_TAG, "" + mController.mListener.getClass());
mController.mListener.updateMailboxListCallback(null, ACCOUNT_1, 100);
assertTrue(mListener.mCalledOnRefreshStatusChanged);
@@ -207,7 +208,8 @@ public class RefreshManagerTest extends InstrumentationTestCase {
assertTrue(mListener.mCalledOnConnectionError);
assertEquals(ACCOUNT_2, mListener.mAccountId);
assertEquals(-1, mListener.mMailboxId);
- assertEquals(EXCEPTION.getUiErrorMessage(mContext), mListener.mMessage);
+ assertEquals(MessagingExceptionStrings.getErrorString(mContext, EXCEPTION),
+ mListener.mMessage);
mListener.reset();
assertFalse(mTarget.isMailboxListRefreshing(ACCOUNT_2));
assertEquals(mClock.mTime, mTarget.getMailboxListStatusForTest(ACCOUNT_2)
@@ -269,7 +271,7 @@ public class RefreshManagerTest extends InstrumentationTestCase {
assertEquals(0, mTarget.getMessageListStatusForTest(MAILBOX_1).getLastRefreshTime());
// Done.
- Log.w(Email.LOG_TAG, "" + mController.mListener.getClass());
+ Log.w(Logging.LOG_TAG, "" + mController.mListener.getClass());
mController.mListener.updateMailboxCallback(null, ACCOUNT_1, MAILBOX_1, 100, 0);
assertTrue(mListener.mCalledOnRefreshStatusChanged);
@@ -304,7 +306,8 @@ public class RefreshManagerTest extends InstrumentationTestCase {
assertTrue(mListener.mCalledOnConnectionError);
assertEquals(ACCOUNT_2, mListener.mAccountId);
assertEquals(MAILBOX_2, mListener.mMailboxId);
- assertEquals(EXCEPTION.getUiErrorMessage(mContext), mListener.mMessage);
+ assertEquals(MessagingExceptionStrings.getErrorString(mContext, EXCEPTION),
+ mListener.mMessage);
mListener.reset();
assertFalse(mTarget.isMessageListRefreshing(MAILBOX_2));
assertEquals(mClock.mTime, mTarget.getMessageListStatusForTest(MAILBOX_2)
@@ -358,7 +361,8 @@ public class RefreshManagerTest extends InstrumentationTestCase {
mController.mListener.sendMailCallback(EXCEPTION, ACCOUNT_1, 102, 0);
assertTrue(mListener.mCalledOnConnectionError);
- assertEquals(EXCEPTION.getUiErrorMessage(mContext), mListener.mMessage);
+ assertEquals(MessagingExceptionStrings.getErrorString(mContext, EXCEPTION),
+ mListener.mMessage);
mListener.reset();
// Exception again -- no more error callbacks
@@ -369,7 +373,7 @@ public class RefreshManagerTest extends InstrumentationTestCase {
mListener.reset();
// Done.
- Log.w(Email.LOG_TAG, "" + mController.mListener.getClass());
+ Log.w(Logging.LOG_TAG, "" + mController.mListener.getClass());
mController.mListener.sendMailCallback(null, ACCOUNT_1, -1, 100);
assertFalse(mListener.mCalledOnConnectionError);
diff --git a/tests/src/com/android/email/SecurityPolicyTests.java b/tests/src/com/android/email/SecurityPolicyTests.java
index 68fba913c..82fa5844d 100644
--- a/tests/src/com/android/email/SecurityPolicyTests.java
+++ b/tests/src/com/android/email/SecurityPolicyTests.java
@@ -52,7 +52,7 @@ public class SecurityPolicyTests extends ProviderTestCase2 {
new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, 0, 0, false, 0, 0, 0, false);
public SecurityPolicyTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/SingleRunningTaskTest.java b/tests/src/com/android/email/SingleRunningTaskTest.java
index 652c07a60..b41299f24 100644
--- a/tests/src/com/android/email/SingleRunningTaskTest.java
+++ b/tests/src/com/android/email/SingleRunningTaskTest.java
@@ -17,6 +17,7 @@
package com.android.email;
import com.android.email.TestUtils.Condition;
+import com.android.emailcommon.utility.Utility;
import java.util.concurrent.atomic.AtomicInteger;
diff --git a/tests/src/com/android/email/TestUtils.java b/tests/src/com/android/email/TestUtils.java
index ef74d52fe..2eaf37435 100644
--- a/tests/src/com/android/email/TestUtils.java
+++ b/tests/src/com/android/email/TestUtils.java
@@ -16,6 +16,8 @@
package com.android.email;
+import com.android.emailcommon.Logging;
+
import android.app.KeyguardManager;
import android.content.Context;
import android.os.PowerManager;
@@ -112,7 +114,7 @@ public class TestUtils extends TestCase /* It tests itself */ {
* Wait until a {@code Condition} is met.
*/
public static void waitUntil(String message, Condition condition, int timeoutSeconds) {
- Log.d(Email.LOG_TAG, message + ": Waiting...");
+ Log.d(Logging.LOG_TAG, message + ": Waiting...");
final long timeout = System.currentTimeMillis() + timeoutSeconds * 1000;
while (System.currentTimeMillis() < timeout) {
if (condition.isMet()) {
diff --git a/tests/src/com/android/email/UtilityLargeTest.java b/tests/src/com/android/email/UtilityLargeTest.java
index 5b0f08da7..3a7162f8d 100644
--- a/tests/src/com/android/email/UtilityLargeTest.java
+++ b/tests/src/com/android/email/UtilityLargeTest.java
@@ -18,6 +18,7 @@ package com.android.email;
import com.android.email.provider.ProviderTestUtils;
import com.android.emailcommon.provider.EmailContent.Account;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.test.InstrumentationTestCase;
diff --git a/tests/src/com/android/email/activity/MailboxesAdapterTest.java b/tests/src/com/android/email/activity/MailboxesAdapterTest.java
index c0d212de5..fbfa5a492 100644
--- a/tests/src/com/android/email/activity/MailboxesAdapterTest.java
+++ b/tests/src/com/android/email/activity/MailboxesAdapterTest.java
@@ -18,6 +18,7 @@ package com.android.email.activity;
import com.android.email.provider.EmailProvider;
import com.android.email.provider.ProviderTestUtils;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
@@ -33,7 +34,7 @@ public class MailboxesAdapterTest extends ProviderTestCase2 {
private Context mMockContext;
public MailboxesAdapterTest() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/activity/MessageComposeTests.java b/tests/src/com/android/email/activity/MessageComposeTests.java
index 2220ea27f..0fb8fb070 100644
--- a/tests/src/com/android/email/activity/MessageComposeTests.java
+++ b/tests/src/com/android/email/activity/MessageComposeTests.java
@@ -20,6 +20,7 @@ import com.android.email.Email;
import com.android.email.EmailAddressValidator;
import com.android.email.R;
import com.android.email.TestUtils;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -919,7 +920,7 @@ public class MessageComposeTests
*/
public void testCommaInserting() throws Throwable {
if (!TestUtils.isScreenOnAndNotLocked(mContext)) {
- Log.w(Email.LOG_TAG, "SKIP testCommaInserting: Screen off or locked");
+ Log.w(Logging.LOG_TAG, "SKIP testCommaInserting: Screen off or locked");
return;
}
diff --git a/tests/src/com/android/email/activity/MessageOrderManagerTest.java b/tests/src/com/android/email/activity/MessageOrderManagerTest.java
index 18b464723..1b3be4700 100644
--- a/tests/src/com/android/email/activity/MessageOrderManagerTest.java
+++ b/tests/src/com/android/email/activity/MessageOrderManagerTest.java
@@ -39,7 +39,7 @@ public class MessageOrderManagerTest extends ProviderTestCase2 {
}
public MessageOrderManagerTest() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
private static void assertCanMove(MessageOrderManager mom, boolean newer, boolean older) {
diff --git a/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java b/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java
index 0c7520785..d2e7929ea 100644
--- a/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java
+++ b/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java
@@ -16,9 +16,7 @@
package com.android.email.mail.store;
-import com.android.email.Email;
import com.android.email.MockVendorPolicy;
-import com.android.email.Utility;
import com.android.email.VendorPolicyLoader;
import com.android.email.mail.Transport;
import com.android.email.mail.store.ImapStore.ImapConnection;
@@ -26,6 +24,7 @@ import com.android.email.mail.store.ImapStore.ImapMessage;
import com.android.email.mail.store.imap.ImapResponse;
import com.android.email.mail.store.imap.ImapTestUtils;
import com.android.email.mail.transport.MockTransport;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.internet.MimeBodyPart;
import com.android.emailcommon.internet.MimeMultipart;
import com.android.emailcommon.internet.MimeUtility;
@@ -36,12 +35,13 @@ import com.android.emailcommon.mail.Body;
import com.android.emailcommon.mail.FetchProfile;
import com.android.emailcommon.mail.Flag;
import com.android.emailcommon.mail.Folder;
-import com.android.emailcommon.mail.Message;
-import com.android.emailcommon.mail.MessagingException;
-import com.android.emailcommon.mail.Part;
import com.android.emailcommon.mail.Folder.FolderType;
import com.android.emailcommon.mail.Folder.OpenMode;
+import com.android.emailcommon.mail.Message;
import com.android.emailcommon.mail.Message.RecipientType;
+import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.mail.Part;
+import com.android.emailcommon.utility.Utility;
import org.apache.commons.io.IOUtils;
@@ -94,7 +94,7 @@ public class ImapStoreUnitTests extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Email.setTempDirectory(getContext());
+ TempDirectory.setTempDirectory(getContext());
// These are needed so we can get at the inner classes
mStore = (ImapStore) ImapStore.newInstance("imap://user:password@server:999",
diff --git a/tests/src/com/android/email/mail/store/Pop3StoreUnitTests.java b/tests/src/com/android/email/mail/store/Pop3StoreUnitTests.java
index 684965017..9417bbd48 100644
--- a/tests/src/com/android/email/mail/store/Pop3StoreUnitTests.java
+++ b/tests/src/com/android/email/mail/store/Pop3StoreUnitTests.java
@@ -16,19 +16,19 @@
package com.android.email.mail.store;
-import com.android.email.Email;
import com.android.email.mail.Transport;
import com.android.email.mail.transport.MockTransport;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.internet.MimeMessage;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.FetchProfile;
import com.android.emailcommon.mail.Flag;
import com.android.emailcommon.mail.Folder;
-import com.android.emailcommon.mail.Message;
-import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Folder.FolderType;
import com.android.emailcommon.mail.Folder.OpenMode;
+import com.android.emailcommon.mail.Message;
import com.android.emailcommon.mail.Message.RecipientType;
+import com.android.emailcommon.mail.MessagingException;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -54,7 +54,7 @@ public class Pop3StoreUnitTests extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Email.setTempDirectory(getContext());
+ TempDirectory.setTempDirectory(getContext());
// These are needed so we can get at the inner classes
mStore = (Pop3Store) Pop3Store.newInstance("pop3://user:password@server:999",
diff --git a/tests/src/com/android/email/mail/store/imap/ImapResponseParserTest.java b/tests/src/com/android/email/mail/store/imap/ImapResponseParserTest.java
index 3ba42e4f6..377fe52b5 100644
--- a/tests/src/com/android/email/mail/store/imap/ImapResponseParserTest.java
+++ b/tests/src/com/android/email/mail/store/imap/ImapResponseParserTest.java
@@ -21,17 +21,11 @@ import static com.android.email.mail.store.imap.ImapTestUtils.buildList;
import static com.android.email.mail.store.imap.ImapTestUtils.buildResponse;
import static com.android.email.mail.store.imap.ImapTestUtils.createFixedLengthInputStream;
-import com.android.email.Email;
-import com.android.email.Utility;
-import com.android.email.mail.store.imap.ImapMemoryLiteral;
-import com.android.email.mail.store.imap.ImapResponse;
-import com.android.email.mail.store.imap.ImapResponseParser;
-import com.android.email.mail.store.imap.ImapSimpleString;
-import com.android.email.mail.store.imap.ImapString;
-import com.android.email.mail.store.imap.ImapTempFileLiteral;
import com.android.email.mail.store.imap.ImapResponseParser.ByeException;
import com.android.email.mail.transport.DiscourseLogger;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.utility.Utility;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -50,7 +44,7 @@ public class ImapResponseParserTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Email.setTempDirectory(getContext());
+ TempDirectory.setTempDirectory(getContext());
}
public void testExpect() throws Exception {
diff --git a/tests/src/com/android/email/mail/store/imap/ImapStringTest.java b/tests/src/com/android/email/mail/store/imap/ImapStringTest.java
index 9327f95b2..a6dc20ab1 100644
--- a/tests/src/com/android/email/mail/store/imap/ImapStringTest.java
+++ b/tests/src/com/android/email/mail/store/imap/ImapStringTest.java
@@ -16,14 +16,10 @@
package com.android.email.mail.store.imap;
-import static com.android.email.mail.store.imap.ImapTestUtils.*;
+import static com.android.email.mail.store.imap.ImapTestUtils.createFixedLengthInputStream;
-import com.android.email.Email;
-import com.android.email.Utility;
-import com.android.email.mail.store.imap.ImapMemoryLiteral;
-import com.android.email.mail.store.imap.ImapSimpleString;
-import com.android.email.mail.store.imap.ImapString;
-import com.android.email.mail.store.imap.ImapTempFileLiteral;
+import com.android.emailcommon.TempDirectory;
+import com.android.emailcommon.utility.Utility;
import org.apache.commons.io.IOUtils;
@@ -44,7 +40,7 @@ public class ImapStringTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Email.setTempDirectory(getContext());
+ TempDirectory.setTempDirectory(getContext());
}
public void testEmpty() throws Exception {
diff --git a/tests/src/com/android/email/mail/store/imap/ImapTestUtils.java b/tests/src/com/android/email/mail/store/imap/ImapTestUtils.java
index 16d056375..b1043e8f8 100644
--- a/tests/src/com/android/email/mail/store/imap/ImapTestUtils.java
+++ b/tests/src/com/android/email/mail/store/imap/ImapTestUtils.java
@@ -17,13 +17,13 @@
package com.android.email.mail.store.imap;
import com.android.email.FixedLengthInputStream;
-import com.android.email.Utility;
import com.android.email.mail.store.imap.ImapElement;
import com.android.email.mail.store.imap.ImapList;
import com.android.email.mail.store.imap.ImapResponse;
import com.android.email.mail.store.imap.ImapSimpleString;
import com.android.email.mail.store.imap.ImapString;
import com.android.email.mail.transport.DiscourseLogger;
+import com.android.emailcommon.utility.Utility;
import java.io.ByteArrayInputStream;
diff --git a/tests/src/com/android/email/provider/AttachmentProviderTests.java b/tests/src/com/android/email/provider/AttachmentProviderTests.java
index b4ed09bb6..40f031d5e 100644
--- a/tests/src/com/android/email/provider/AttachmentProviderTests.java
+++ b/tests/src/com/android/email/provider/AttachmentProviderTests.java
@@ -68,7 +68,7 @@ public class AttachmentProviderTests extends ProviderTestCase2 {
Context mMockContext;
public ContentCacheTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/provider/ProviderTestUtils.java b/tests/src/com/android/email/provider/ProviderTestUtils.java
index 3eb684417..fb17b2c17 100644
--- a/tests/src/com/android/email/provider/ProviderTestUtils.java
+++ b/tests/src/com/android/email/provider/ProviderTestUtils.java
@@ -16,8 +16,7 @@
package com.android.email.provider;
-import com.android.email.Utility;
-import com.android.email.mail.transport.Rfc822Output;
+import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Attachment;
@@ -25,6 +24,7 @@ import com.android.emailcommon.provider.EmailContent.Body;
import com.android.emailcommon.provider.EmailContent.HostAuth;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.net.Uri;
diff --git a/tests/src/com/android/email/provider/ProviderTests.java b/tests/src/com/android/email/provider/ProviderTests.java
index 7b2a143e8..ba3bcfad5 100644
--- a/tests/src/com/android/email/provider/ProviderTests.java
+++ b/tests/src/com/android/email/provider/ProviderTests.java
@@ -16,7 +16,6 @@
package com.android.email.provider;
-import com.android.email.Utility;
import com.android.emailcommon.mail.Snippet;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -30,6 +29,7 @@ import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
+import com.android.emailcommon.utility.Utility;
import android.content.ContentResolver;
import android.content.ContentUris;
@@ -67,7 +67,7 @@ public class ProviderTests extends ProviderTestCase2 {
private Context mMockContext;
public ProviderTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/service/MailServiceTests.java b/tests/src/com/android/email/service/MailServiceTests.java
index 5871ff26d..963329229 100644
--- a/tests/src/com/android/email/service/MailServiceTests.java
+++ b/tests/src/com/android/email/service/MailServiceTests.java
@@ -19,13 +19,13 @@ package com.android.email.service;
import com.android.email.AccountTestCase;
import com.android.email.Controller;
import com.android.email.Email;
-import com.android.email.Utility;
import com.android.email.provider.EmailProvider;
import com.android.email.provider.ProviderTestUtils;
import com.android.email.service.MailService.AccountSyncReport;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.HostAuth;
+import com.android.emailcommon.utility.Utility;
import android.accounts.AccountManager;
import android.content.ContentResolver;
diff --git a/tests/src/com/android/email/widget/EmailWidgetTests.java b/tests/src/com/android/email/widget/EmailWidgetTests.java
index 75091db06..8c489f504 100644
--- a/tests/src/com/android/email/widget/EmailWidgetTests.java
+++ b/tests/src/com/android/email/widget/EmailWidgetTests.java
@@ -35,7 +35,7 @@ public class EmailWidgetTests extends ProviderTestCase2 {
private Context mMockContext;
public EmailWidgetTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/emailcommon/internet/MimeMessageTest.java b/tests/src/com/android/emailcommon/internet/MimeMessageTest.java
index 4c999d3b5..ee811bd03 100644
--- a/tests/src/com/android/emailcommon/internet/MimeMessageTest.java
+++ b/tests/src/com/android/emailcommon/internet/MimeMessageTest.java
@@ -16,18 +16,15 @@
package com.android.emailcommon.internet;
-import com.android.email.Email;
-import com.android.emailcommon.internet.MimeHeader;
-import com.android.emailcommon.internet.MimeMessage;
-import com.android.emailcommon.internet.MimeUtility;
+import com.android.emailcommon.TempDirectory;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.Flag;
-import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Message.RecipientType;
+import com.android.emailcommon.mail.MessagingException;
import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.SmallTest;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -67,7 +64,7 @@ public class MimeMessageTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Email.setTempDirectory(getContext());
+ TempDirectory.setTempDirectory(getContext());
}
/**
@@ -533,7 +530,7 @@ public class MimeMessageTest extends AndroidTestCase {
* Make sure the parser accepts the "eBay style" date format.
*
* Messages from ebay have been seen that they use the wrong date format.
- * @see com.android.email.Utility#cleanUpMimeDate
+ * @see com.android.emailcommon.utility.Utility#cleanUpMimeDate
*/
public void testEbayDate() throws MessagingException, IOException {
String entireMessage =
diff --git a/tests/src/com/android/email/mail/transport/Rfc822OutputTests.java b/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java
similarity index 98%
rename from tests/src/com/android/email/mail/transport/Rfc822OutputTests.java
rename to tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java
index 930fe5e99..d34a6f859 100644
--- a/tests/src/com/android/email/mail/transport/Rfc822OutputTests.java
+++ b/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java
@@ -14,16 +14,17 @@
* limitations under the License.
*/
-package com.android.email.mail.transport;
+package com.android.emailcommon.internet;
import com.android.email.R;
import com.android.email.provider.EmailProvider;
+import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.mail.MessagingException;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Message;
import org.apache.james.mime4j.field.Field;
-import org.apache.james.mime4j.message.Body;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.james.mime4j.message.Entity;
import org.apache.james.mime4j.message.Header;
@@ -61,7 +62,7 @@ public class Rfc822OutputTests extends ProviderTestCase2 {
private String mReplyBody;
public Rfc822OutputTests () {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/UtilityMediumTests.java b/tests/src/com/android/emailcommon/utility/UtilityMediumTests.java
similarity index 99%
rename from tests/src/com/android/email/UtilityMediumTests.java
rename to tests/src/com/android/emailcommon/utility/UtilityMediumTests.java
index 634f57567..02a157221 100644
--- a/tests/src/com/android/email/UtilityMediumTests.java
+++ b/tests/src/com/android/emailcommon/utility/UtilityMediumTests.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.email;
+package com.android.emailcommon.utility;
import com.android.email.provider.EmailProvider;
import com.android.email.provider.ProviderTestUtils;
@@ -48,7 +48,7 @@ public class UtilityMediumTests extends ProviderTestCase2 {
Context mMockContext;
public UtilityMediumTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/email/UtilityUnitTests.java b/tests/src/com/android/emailcommon/utility/UtilityUnitTests.java
similarity index 87%
rename from tests/src/com/android/email/UtilityUnitTests.java
rename to tests/src/com/android/emailcommon/utility/UtilityUnitTests.java
index 59465bd0c..52002f5e1 100644
--- a/tests/src/com/android/email/UtilityUnitTests.java
+++ b/tests/src/com/android/emailcommon/utility/UtilityUnitTests.java
@@ -14,14 +14,19 @@
* limitations under the License.
*/
-package com.android.email;
+package com.android.emailcommon.utility;
-import com.android.email.Utility.NewFileCreator;
+import com.android.email.DBTestHelper;
+import com.android.email.FolderProperties;
+import com.android.email.R;
+import com.android.email.TestUtils;
+import com.android.email.UiUtilities;
import com.android.email.provider.ProviderTestUtils;
+import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Mailbox;
-import com.android.emailcommon.utility.AttachmentUtilities;
+import com.android.emailcommon.utility.Utility.NewFileCreator;
import android.content.Context;
import android.database.Cursor;
@@ -86,32 +91,32 @@ public class UtilityUnitTests extends AndroidTestCase {
Context context = getContext();
String expect, name;
expect = context.getString(R.string.mailbox_name_display_inbox);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_INBOX);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_INBOX);
assertEquals(expect, name);
expect = null;
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_MAIL);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_MAIL);
assertEquals(expect, name);
expect = null;
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_PARENT);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_PARENT);
assertEquals(expect, name);
expect = context.getString(R.string.mailbox_name_display_drafts);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_DRAFTS);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_DRAFTS);
assertEquals(expect, name);
expect = context.getString(R.string.mailbox_name_display_outbox);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_OUTBOX);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_OUTBOX);
assertEquals(expect, name);
expect = context.getString(R.string.mailbox_name_display_sent);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_SENT);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_SENT);
assertEquals(expect, name);
expect = context.getString(R.string.mailbox_name_display_trash);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_TRASH);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_TRASH);
assertEquals(expect, name);
expect = context.getString(R.string.mailbox_name_display_junk);
- name = Utility.FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_JUNK);
+ name = FolderProperties.getInstance(context).getDisplayName(Mailbox.TYPE_JUNK);
assertEquals(expect, name);
// Testing illegal index
expect = null;
- name = Utility.FolderProperties.getInstance(context).getDisplayName(8);
+ name = FolderProperties.getInstance(context).getDisplayName(8);
assertEquals(expect, name);
}
@@ -119,7 +124,7 @@ public class UtilityUnitTests extends AndroidTestCase {
* Confirm that all of the special icons are available and unique
*/
public void testSpecialIcons() {
- Utility.FolderProperties fp = Utility.FolderProperties.getInstance(mContext);
+ FolderProperties fp = FolderProperties.getInstance(mContext);
// Make sure they're available
Drawable inbox = fp.getIcon(Mailbox.TYPE_INBOX, -1);
@@ -206,7 +211,7 @@ public class UtilityUnitTests extends AndroidTestCase {
TelephonyManager tm =
(TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
- Log.w(Email.LOG_TAG, "TelephonyManager not supported. Skipping.");
+ Log.w(Logging.LOG_TAG, "TelephonyManager not supported. Skipping.");
return;
}
@@ -262,15 +267,15 @@ public class UtilityUnitTests extends AndroidTestCase {
if (!"en".equalsIgnoreCase(Locale.getDefault().getLanguage())) {
return; // Only works on the EN locale.
}
- assertEquals("0B", Utility.formatSize(getContext(), 0));
- assertEquals("1B", Utility.formatSize(getContext(), 1));
- assertEquals("1023B", Utility.formatSize(getContext(), 1023));
- assertEquals("1KB", Utility.formatSize(getContext(), 1024));
- assertEquals("1023KB", Utility.formatSize(getContext(), 1024 * 1024 - 1));
- assertEquals("1MB", Utility.formatSize(getContext(), 1024 * 1024));
- assertEquals("1023MB", Utility.formatSize(getContext(), 1024 * 1024 * 1024 - 1));
- assertEquals("1GB", Utility.formatSize(getContext(), 1024 * 1024 * 1024));
- assertEquals("5GB", Utility.formatSize(getContext(), 5L * 1024 * 1024 * 1024));
+ assertEquals("0B", UiUtilities.formatSize(getContext(), 0));
+ assertEquals("1B", UiUtilities.formatSize(getContext(), 1));
+ assertEquals("1023B", UiUtilities.formatSize(getContext(), 1023));
+ assertEquals("1KB", UiUtilities.formatSize(getContext(), 1024));
+ assertEquals("1023KB", UiUtilities.formatSize(getContext(), 1024 * 1024 - 1));
+ assertEquals("1MB", UiUtilities.formatSize(getContext(), 1024 * 1024));
+ assertEquals("1023MB", UiUtilities.formatSize(getContext(), 1024 * 1024 * 1024 - 1));
+ assertEquals("1GB", UiUtilities.formatSize(getContext(), 1024 * 1024 * 1024));
+ assertEquals("5GB", UiUtilities.formatSize(getContext(), 5L * 1024 * 1024 * 1024));
}
private static class MyNewFileCreator implements NewFileCreator {
@@ -494,25 +499,25 @@ public class UtilityUnitTests extends AndroidTestCase {
final Context c = getContext();
// Negavive valeus not really expected, but at least shouldn't crash.
- assertEquals("-1", Utility.getMessageCountForUi(c, -1, true));
- assertEquals("-1", Utility.getMessageCountForUi(c, -1, false));
+ assertEquals("-1", UiUtilities.getMessageCountForUi(c, -1, true));
+ assertEquals("-1", UiUtilities.getMessageCountForUi(c, -1, false));
- assertEquals("", Utility.getMessageCountForUi(c, 0, true));
- assertEquals("0", Utility.getMessageCountForUi(c, 0, false));
+ assertEquals("", UiUtilities.getMessageCountForUi(c, 0, true));
+ assertEquals("0", UiUtilities.getMessageCountForUi(c, 0, false));
- assertEquals("1", Utility.getMessageCountForUi(c, 1, true));
- assertEquals("1", Utility.getMessageCountForUi(c, 1, false));
+ assertEquals("1", UiUtilities.getMessageCountForUi(c, 1, true));
+ assertEquals("1", UiUtilities.getMessageCountForUi(c, 1, false));
- assertEquals("999", Utility.getMessageCountForUi(c, 999, true));
- assertEquals("999", Utility.getMessageCountForUi(c, 999, false));
+ assertEquals("999", UiUtilities.getMessageCountForUi(c, 999, true));
+ assertEquals("999", UiUtilities.getMessageCountForUi(c, 999, false));
final String moreThan999 = c.getString(R.string.more_than_999);
- assertEquals(moreThan999, Utility.getMessageCountForUi(c, 1000, true));
- assertEquals(moreThan999, Utility.getMessageCountForUi(c, 1000, false));
+ assertEquals(moreThan999, UiUtilities.getMessageCountForUi(c, 1000, true));
+ assertEquals(moreThan999, UiUtilities.getMessageCountForUi(c, 1000, false));
- assertEquals(moreThan999, Utility.getMessageCountForUi(c, 1001, true));
- assertEquals(moreThan999, Utility.getMessageCountForUi(c, 1001, false));
+ assertEquals(moreThan999, UiUtilities.getMessageCountForUi(c, 1001, true));
+ assertEquals(moreThan999, UiUtilities.getMessageCountForUi(c, 1001, false));
}
/**
diff --git a/tests/src/com/android/exchange/CalendarSyncEnablerTest.java b/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
index b244c93bb..2a4117fc1 100644
--- a/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
+++ b/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
@@ -19,6 +19,7 @@ package com.android.exchange;
import com.android.email.AccountTestCase;
import com.android.email.Email;
import com.android.email.NotificationController;
+import com.android.emailcommon.Logging;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -172,7 +173,7 @@ public class CalendarSyncEnablerTest extends AccountTestCase {
// set up on the device. Otherwise there'll be no difference from
// testEnableEasCalendarSync.
if (AccountManager.get(getContext()).getAccountsByType(EAT).length > 0) {
- Log.w(Email.LOG_TAG, "testEnableEasCalendarSyncWithNoExchangeAccounts skipped:"
+ Log.w(Logging.LOG_TAG, "testEnableEasCalendarSyncWithNoExchangeAccounts skipped:"
+ " It only runs when there's no Exchange account on the device.");
return;
}
diff --git a/tests/src/com/android/exchange/adapter/SyncAdapterTestCase.java b/tests/src/com/android/exchange/adapter/SyncAdapterTestCase.java
index 98fcb5ea7..79685270e 100644
--- a/tests/src/com/android/exchange/adapter/SyncAdapterTestCase.java
+++ b/tests/src/com/android/exchange/adapter/SyncAdapterTestCase.java
@@ -17,6 +17,7 @@
package com.android.exchange.adapter;
import com.android.email.provider.EmailProvider;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.exchange.EasSyncService;
@@ -43,7 +44,7 @@ public class SyncAdapterTestCase
EasEmailSyncParser mSyncParser;
public SyncAdapterTestCase() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
@Override
diff --git a/tests/src/com/android/exchange/provider/ExchangeDirectoryProviderTests.java b/tests/src/com/android/exchange/provider/ExchangeDirectoryProviderTests.java
index 5c19977de..05750045d 100644
--- a/tests/src/com/android/exchange/provider/ExchangeDirectoryProviderTests.java
+++ b/tests/src/com/android/exchange/provider/ExchangeDirectoryProviderTests.java
@@ -19,6 +19,7 @@ package com.android.exchange.provider;
import com.android.email.provider.EmailProvider;
import com.android.email.provider.ProviderTestUtils;
import com.android.emailcommon.mail.PackedString;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.exchange.provider.GalResult.GalData;
@@ -37,7 +38,7 @@ import android.test.ProviderTestCase2;
public class ExchangeDirectoryProviderTests extends ProviderTestCase2 {
public ExchangeDirectoryProviderTests() {
- super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
+ super(EmailProvider.class, EmailContent.AUTHORITY);
}
// Create a test projection; we should only get back values for display name and email address
diff --git a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
index 1accf8c89..9425bc032 100644
--- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
+++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
@@ -17,17 +17,17 @@
package com.android.exchange.utility;
import com.android.email.R;
-import com.android.email.Utility;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Message;
+import com.android.emailcommon.utility.Utility;
import com.android.exchange.adapter.CalendarSyncAdapter;
+import com.android.exchange.adapter.CalendarSyncAdapter.EasCalendarSyncParser;
import com.android.exchange.adapter.Parser;
import com.android.exchange.adapter.Serializer;
import com.android.exchange.adapter.SyncAdapterTestCase;
import com.android.exchange.adapter.Tags;
-import com.android.exchange.adapter.CalendarSyncAdapter.EasCalendarSyncParser;
import android.content.ContentValues;
import android.content.Entity;
diff --git a/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java b/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java
index 372643a18..f9a93a309 100644
--- a/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java
+++ b/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java
@@ -15,7 +15,7 @@
package com.android.exchange.utility;
-import com.android.email.Utility;
+import com.android.emailcommon.utility.Utility;
import junit.framework.TestCase;