summaryrefslogtreecommitdiffstats
path: root/src/com/android/mail/browse/ConversationItemViewCoordinates.java
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-03-21 06:04:46 -0700
committerMark Wei <markwei@google.com>2013-07-08 20:26:23 -0700
commit479505d71969e26b0785d8e0e1b81108731cf827 (patch)
tree069a592e9b3b2c8d43836e2b8ccaf47bced2fc13 /src/com/android/mail/browse/ConversationItemViewCoordinates.java
parentbb8dca879c88ad5f6de3a5ffc80b0a8e2d9e5f72 (diff)
downloadandroid_packages_apps_UnifiedEmail-479505d71969e26b0785d8e0e1b81108731cf827.tar.gz
android_packages_apps_UnifiedEmail-479505d71969e26b0785d8e0e1b81108731cf827.tar.bz2
android_packages_apps_UnifiedEmail-479505d71969e26b0785d8e0e1b81108731cf827.zip
Attachments in Conversation List: Backend changes so that the appropriate
attachments are passed to the UI. Implement PhotoManager so we can start showing images. Upon sync, we extract two image attachments from the first unread message, and add them to the conversations table. UI changes as well. Load BEST if that is available, else load SIMPLE. No vertical dividers in attachment previews. Attachment previews are above labels. Round badge appears for unread conversations when there are more images than shown. Only appears after the previews have loaded. Clicking on the attachment previews launches photoviewer. Attempt to load bigger images than necessary to prevent reloading during mark read/unread and rotate. Show animated loading icon while previews are loading. Previews load from top to bottom, from left to right. Big performance improvements: No longer decoding bitmap on UI thread. This kills most of the jank. Only load when we are not scrolling. This kills a lot of jank. Remaining jank will be delt with later: DividedImageCanvas.setDimensions() creates a huge empty bitmap on the UI thread, which causes a GC. ath will fix. Multiple images in one line now load whatever's ready first. Added tracing. Bitmap cache given more memory. Following ath's advice, decode Bitmap from InputStream rather than byte[]. Don't compress into BitmapHolder. Only use the bigger Bitmap cache. Bug: 7481049 Change-Id: Icf823f56abc9345e6d0b800a1e6d45444d8fa028
Diffstat (limited to 'src/com/android/mail/browse/ConversationItemViewCoordinates.java')
-rw-r--r--src/com/android/mail/browse/ConversationItemViewCoordinates.java151
1 files changed, 91 insertions, 60 deletions
diff --git a/src/com/android/mail/browse/ConversationItemViewCoordinates.java b/src/com/android/mail/browse/ConversationItemViewCoordinates.java
index 85b016651..34b5596b3 100644
--- a/src/com/android/mail/browse/ConversationItemViewCoordinates.java
+++ b/src/com/android/mail/browse/ConversationItemViewCoordinates.java
@@ -28,9 +28,12 @@ import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
+import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.mail.R;
+import com.android.mail.R.dimen;
+import com.android.mail.R.id;
import com.android.mail.ui.ViewMode;
import com.android.mail.utils.Utils;
import com.google.common.base.Objects;
@@ -56,10 +59,9 @@ public class ConversationItemViewCoordinates {
static final int GADGET_CHECKBOX = 2;
// Attachment previews modes
- static final int ATTACHMENT_PREVIEW_MODE_COUNT = 3;
static final int ATTACHMENT_PREVIEW_NONE = 0;
- static final int ATTACHMENT_PREVIEW_TALL = 1;
- static final int ATTACHMENT_PREVIEW_SHORT = 2;
+ static final int ATTACHMENT_PREVIEW_UNREAD = 1;
+ static final int ATTACHMENT_PREVIEW_READ = 2;
// For combined views
private static int COLOR_BLOCK_WIDTH = -1;
@@ -167,13 +169,6 @@ public class ConversationItemViewCoordinates {
final int height;
- // Attachments view
- static int sAttachmentPreviewsHeights[];
- static int sAttachmentPreviewsMarginTops[];
- final int attachmentPreviewsX;
- final int attachmentPreviewsY;
- final int attachmentPreviewsWidth;
-
// Checkmark.
final int checkmarkX;
final int checkmarkY;
@@ -181,6 +176,7 @@ public class ConversationItemViewCoordinates {
// Star.
final int starX;
final int starY;
+ final int starWidth;
// Senders.
final int sendersX;
@@ -241,6 +237,24 @@ public class ConversationItemViewCoordinates {
final int contactImagesX;
final int contactImagesY;
+ // Attachment previews
+ final int attachmentPreviewsX;
+ final int attachmentPreviewsY;
+ final int attachmentPreviewsWidth;
+ final int attachmentPreviewsHeight;
+
+ // Attachment previews overflow badge and count
+ final int overflowXEnd;
+ final int overflowYEnd;
+ final int overflowDiameter;
+ final float overflowFontSize;
+ final Typeface overflowTypeface;
+
+ // Attachment previews progress bar
+ final int progressBarY;
+ final int progressBarWidth;
+ final int progressBarHeight;
+
/**
* The smallest item width for which we use the "wide" layout.
*/
@@ -255,6 +269,7 @@ public class ConversationItemViewCoordinates {
private final int mFolderMinimumWidth;
private ConversationItemViewCoordinates(Context context, Config config) {
+ Utils.traceBeginSection("CIV coordinates constructor");
final Resources res = context.getResources();
mFolderCellWidth = res.getDimensionPixelSize(R.dimen.folder_cell_width);
mMinListWidthForWide = res.getDimensionPixelSize(R.dimen.list_min_width_is_wide);
@@ -276,22 +291,27 @@ public class ConversationItemViewCoordinates {
}
final ViewGroup view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null);
- final TextView folders = (TextView) view.findViewById(R.id.folders);
- folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE);
-
// Show/hide optional views before measure/layout call
+
View attachmentPreviews = null;
if (config.getAttachmentPreviewMode() != ATTACHMENT_PREVIEW_NONE) {
attachmentPreviews = view.findViewById(R.id.attachment_previews);
- if (attachmentPreviews != null) {
- LayoutParams params = attachmentPreviews.getLayoutParams();
- attachmentPreviews.setVisibility(View.VISIBLE);
- params.height = getAttachmentPreviewsHeight(
- context, config.getAttachmentPreviewMode());
- attachmentPreviews.setLayoutParams(params);
- }
+ LayoutParams params = attachmentPreviews.getLayoutParams();
+ attachmentPreviews.setVisibility(View.VISIBLE);
+ params.height = getAttachmentPreviewsHeight(context, config.getAttachmentPreviewMode());
+ attachmentPreviews.setLayoutParams(params);
}
+ final TextView folders = (TextView) view.findViewById(R.id.folders);
+ folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE);
+
+ // Add margin between attachment previews and folders
+ View attachmentPreviewsBottomMargin = view
+ .findViewById(R.id.attachment_previews_bottom_margin);
+ attachmentPreviewsBottomMargin.setVisibility(
+ attachmentPreviews != null && config.areFoldersVisible() ? View.VISIBLE
+ : View.GONE);
+
View contactImagesView = view.findViewById(R.id.contact_image);
View checkmark = view.findViewById(R.id.checkmark);
@@ -351,6 +371,7 @@ public class ConversationItemViewCoordinates {
final View star = view.findViewById(R.id.star);
starX = getX(star);
starY = getY(star);
+ starWidth = star.getWidth();
final TextView senders = (TextView) view.findViewById(R.id.senders);
final int sendersTopAdjust = getLatinTopAdjustment(senders);
@@ -440,16 +461,50 @@ public class ConversationItemViewCoordinates {
paperclipPaddingLeft = paperclip.getPaddingLeft();
if (attachmentPreviews != null) {
- attachmentPreviewsX = getX(attachmentPreviews);
- attachmentPreviewsY = getY(attachmentPreviews);
- attachmentPreviewsWidth = attachmentPreviews.getWidth();
+ attachmentPreviewsX = getAttachmentPreviewsX(attachmentPreviews,
+ config.mAttachmentPreviewMode);
+ attachmentPreviewsY = getY(attachmentPreviews) + sendersTopAdjust;
+ final int attachmentPreviewsXEnd;
+ if (isWide()) {
+ attachmentPreviewsXEnd = subjectX + subjectWidth;
+ } else {
+ attachmentPreviewsXEnd = starX + starWidth;
+ }
+
+ attachmentPreviewsWidth = attachmentPreviewsXEnd - attachmentPreviewsX;
+ attachmentPreviewsHeight = attachmentPreviews.getHeight();
+
+ // We only care about the right and bottom of the overflow count
+ final TextView overflow = (TextView) view.findViewById(id.ap_overflow);
+ FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) overflow.getLayoutParams();
+ overflowXEnd = attachmentPreviewsX + attachmentPreviewsWidth - params.rightMargin;
+ overflowYEnd = attachmentPreviewsY + attachmentPreviewsHeight - params.bottomMargin;
+ overflowDiameter = overflow.getWidth();
+ overflowFontSize = overflow.getTextSize();
+ overflowTypeface = overflow.getTypeface();
+
+ final View progressBar = view.findViewById(id.ap_progress_bar);
+ progressBarWidth = progressBar.getWidth();
+ progressBarHeight = progressBar.getHeight();
+ progressBarY = attachmentPreviewsY + attachmentPreviewsHeight / 2
+ - progressBarHeight / 2;
} else {
attachmentPreviewsX = 0;
attachmentPreviewsY = 0;
attachmentPreviewsWidth = 0;
+ attachmentPreviewsHeight = 0;
+ overflowXEnd = 0;
+ overflowYEnd = 0;
+ overflowDiameter = 0;
+ overflowFontSize = 0;
+ overflowTypeface = null;
+ progressBarY = 0;
+ progressBarWidth = 0;
+ progressBarHeight = 0;
}
height = view.getHeight() + (isWide() ? 0 : sendersTopAdjust);
+ Utils.traceEndSection();
}
public int getMode() {
@@ -490,48 +545,24 @@ public class ConversationItemViewCoordinates {
}
}
- /**
- * Returns a value array multiplied by the specified density.
- */
- public static int[] getDensityDependentArray(int[] values, float density) {
- int result[] = new int[values.length];
- for (int i = 0; i < values.length; ++i) {
- result[i] = (int) (values[i] * density);
+ private int getAttachmentPreviewsX(View attachmentPreviews, int attachmentPreviewMode) {
+ if (isWide() || attachmentPreviewMode == ATTACHMENT_PREVIEW_READ) {
+ return subjectX;
}
- return result;
+ return getX(attachmentPreviews);
}
- /**
- * Refreshes the conversation heights array.
- */
- @Deprecated
- // TODO: heights are now dynamic and should be members of this class. the fixed attachment
- // heights can still be stored in a dimensional array, but should only be used as input into
- // forConfig's measure/layout
- public static void refreshConversationDimens(Context context) {
+ private int getAttachmentPreviewsHeight(Context context, int attachmentPreviewMode) {
Resources res = context.getResources();
-
- // Attachment previews height
- sAttachmentPreviewsHeights = new int[ATTACHMENT_PREVIEW_MODE_COUNT];
- sAttachmentPreviewsHeights[ATTACHMENT_PREVIEW_TALL] = 0;
- sAttachmentPreviewsHeights[ATTACHMENT_PREVIEW_TALL] = (int) res.getDimension(
- R.dimen.attachment_preview_height_tall);
- sAttachmentPreviewsHeights[ATTACHMENT_PREVIEW_SHORT] = (int) res.getDimension(
- R.dimen.attachment_preview_height_short);
-
- // Attachment previews margin top
- sAttachmentPreviewsMarginTops = new int[MODE_COUNT];
- sAttachmentPreviewsMarginTops[NORMAL_MODE] = (int) res.getDimension(
- R.dimen.attachment_preview_margin_top);
- sAttachmentPreviewsMarginTops[WIDE_MODE] = (int) res.getDimension(
- R.dimen.attachment_preview_margin_top_wide);
- }
-
- public static int getAttachmentPreviewsHeight(Context context, int attachmentPreviewMode) {
- if (sAttachmentPreviewsHeights == null) {
- refreshConversationDimens(context);
+ switch (attachmentPreviewMode) {
+ case ATTACHMENT_PREVIEW_UNREAD:
+ return (int) (isWide() ? res.getDimension(dimen.attachment_preview_height_tall_wide)
+ : res.getDimension(dimen.attachment_preview_height_tall));
+ case ATTACHMENT_PREVIEW_READ:
+ return (int) res.getDimension(dimen.attachment_preview_height_short);
+ default:
+ return 0;
}
- return sAttachmentPreviewsHeights[attachmentPreviewMode];
}
/**