am 09eca807: Fallback to "Delivery-date" if message has no "Date"
* commit '09eca8072a2396527baede2b312d91daf1c9c2b9':
Fallback to "Delivery-date" if message has no "Date"
diff --git a/src/com/android/bitmap/DecodeTask.java b/src/com/android/bitmap/DecodeTask.java
index 2210ec6..8fa11f1 100644
--- a/src/com/android/bitmap/DecodeTask.java
+++ b/src/com/android/bitmap/DecodeTask.java
@@ -54,6 +54,7 @@
public interface Request {
AssetFileDescriptor createFd() throws IOException;
InputStream createInputStream() throws IOException;
+ boolean hasOrientationExif() throws IOException;
}
/**
@@ -130,20 +131,26 @@
Trace.endSection();
Trace.beginSection("get orientation");
- if (fd != null) {
- // Creating an input stream from the file descriptor makes it useless afterwards.
- Trace.beginSection("create fd and stream");
- final AssetFileDescriptor orientationFd = mKey.createFd();
- in = orientationFd.createInputStream();
- Trace.endSection();
- }
- final int orientation = Exif.getOrientation(in, byteSize);
- if (fd != null) {
- try {
- // Close the temporary file descriptor.
- in.close();
- } catch (IOException ex) {
+ final int orientation;
+ if (mKey.hasOrientationExif()) {
+ if (fd != null) {
+ // Creating an input stream from the file descriptor makes it useless
+ // afterwards.
+ Trace.beginSection("create fd and stream");
+ final AssetFileDescriptor orientationFd = mKey.createFd();
+ in = orientationFd.createInputStream();
+ Trace.endSection();
}
+ orientation = Exif.getOrientation(in, byteSize);
+ if (fd != null) {
+ try {
+ // Close the temporary file descriptor.
+ in.close();
+ } catch (IOException ex) {
+ }
+ }
+ } else {
+ orientation = 0;
}
final boolean isNotRotatedOr180 = orientation == 0 || orientation == 180;
Trace.endSection();
diff --git a/src/com/android/mail/bitmap/ImageAttachmentRequest.java b/src/com/android/mail/bitmap/ImageAttachmentRequest.java
index 6c58772..b680db5 100644
--- a/src/com/android/mail/bitmap/ImageAttachmentRequest.java
+++ b/src/com/android/mail/bitmap/ImageAttachmentRequest.java
@@ -1,6 +1,5 @@
package com.android.mail.bitmap;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
@@ -25,6 +24,9 @@
private final int mRendition;
public final int mDestW;
+ private Uri mCachedUri;
+ private String mCachedMimeType;
+
public ImageAttachmentRequest(final Context context, final String lookupUri,
final int rendition, final int destW) {
mContext = context;
@@ -78,26 +80,40 @@
@Override
public AssetFileDescriptor createFd() throws IOException {
- AssetFileDescriptor result = null;
+ if (mCachedUri == null) {
+ cacheValues();
+ }
+ return mContext.getContentResolver().openAssetFileDescriptor(mCachedUri, "r");
+ }
+
+ private void cacheValues() throws IOException {
Cursor cursor = null;
- final ContentResolver cr = mContext.getContentResolver();
try {
- cursor = cr.query(Uri.parse(mLookupUri), UIProvider.ATTACHMENT_PROJECTION, null, null,
- null);
+ cursor = mContext.getContentResolver().query(Uri.parse(mLookupUri),
+ UIProvider.ATTACHMENT_PROJECTION, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
final Attachment a = new Attachment(cursor);
- result = cr.openAssetFileDescriptor(a.getUriForRendition(mRendition), "r");
+ mCachedUri = a.getUriForRendition(mRendition);
+ final String mimeType = a.getContentType();
+ mCachedMimeType = mimeType != null ? mimeType.toLowerCase() : null;
}
} finally {
if (cursor != null) {
cursor.close();
}
}
- return result;
}
@Override
public InputStream createInputStream() throws IOException {
return null;
}
+
+ @Override
+ public boolean hasOrientationExif() throws IOException {
+ if (mCachedUri == null) {
+ cacheValues();
+ }
+ return mCachedMimeType == null || mCachedMimeType.equals("image/jpeg");
+ }
}
diff --git a/src/com/android/mail/browse/ConversationCursor.java b/src/com/android/mail/browse/ConversationCursor.java
index b648804..15457ab 100644
--- a/src/com/android/mail/browse/ConversationCursor.java
+++ b/src/com/android/mail/browse/ConversationCursor.java
@@ -1946,6 +1946,15 @@
}
@Override
+ public Uri getNotificationUri() {
+ if (mUnderlyingCursor == null) {
+ return null;
+ } else {
+ return mUnderlyingCursor.getNotificationUri();
+ }
+ }
+
+ @Override
public void setNotificationUri(ContentResolver cr, Uri uri) {
throw new UnsupportedOperationException();
}
diff --git a/src/com/android/mail/preferences/MailPrefs.java b/src/com/android/mail/preferences/MailPrefs.java
index f13e298..c6146c8 100644
--- a/src/com/android/mail/preferences/MailPrefs.java
+++ b/src/com/android/mail/preferences/MailPrefs.java
@@ -40,7 +40,7 @@
*/
public final class MailPrefs extends VersionedPrefs {
- public static final boolean SHOW_EXPERIMENTAL_PREFS = false;
+ public static final boolean SHOW_EXPERIMENTAL_PREFS = true;
private static final String PREFS_NAME = "UnifiedEmail";
diff --git a/src/com/android/mail/ui/AbstractMailActivity.java b/src/com/android/mail/ui/AbstractMailActivity.java
index 33a7da2..43f3b23 100644
--- a/src/com/android/mail/ui/AbstractMailActivity.java
+++ b/src/com/android/mail/ui/AbstractMailActivity.java
@@ -39,7 +39,7 @@
private final UiHandler mUiHandler = new UiHandler();
- private static final boolean STRICT_MODE = false;
+ private static final boolean STRICT_MODE = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/src/com/android/mail/utils/LogUtils.java b/src/com/android/mail/utils/LogUtils.java
index 5d4f434..3203422 100644
--- a/src/com/android/mail/utils/LogUtils.java
+++ b/src/com/android/mail/utils/LogUtils.java
@@ -64,7 +64,7 @@
* production releases. This should be set to DEBUG for production releases, and VERBOSE for
* internal builds.
*/
- private static final int MAX_ENABLED_LOG_LEVEL = DEBUG;
+ private static final int MAX_ENABLED_LOG_LEVEL = VERBOSE;
private static Boolean sDebugLoggingEnabledForTests = null;