diff options
author | yingying <yingying@codeaurora.org> | 2014-04-02 19:31:06 +0800 |
---|---|---|
committer | Adnan <adnan@cyngn.com> | 2014-09-03 15:41:22 -0700 |
commit | 50c99ad4996a23d1c45fd3631abe2f6e18df296a (patch) | |
tree | 7ac013c2e3c279460bfe0ce1510eb28d3cebaf02 | |
parent | 5446d6bfbb2efce3bf1f3f912adb8980559b191d (diff) | |
download | android_packages_apps_UnifiedEmail-50c99ad4996a23d1c45fd3631abe2f6e18df296a.tar.gz android_packages_apps_UnifiedEmail-50c99ad4996a23d1c45fd3631abe2f6e18df296a.tar.bz2 android_packages_apps_UnifiedEmail-50c99ad4996a23d1c45fd3631abe2f6e18df296a.zip |
UnifiedEmail: Display the load more view at the bottom of the mail.
- Display the load more view at the bottom of the uncompleted mail.
- Update the mail list if some mail's attachment flag changed.
- Fix the test build error.
CRs-fixed: 642921
Change-Id: I1dabef5d52cf0f221843627bacbc8093616664a8
13 files changed, 183 insertions, 62 deletions
diff --git a/res/layout/conversation_message_footer.xml b/res/layout/conversation_message_footer.xml index dc783b2c1..29b7227ee 100644 --- a/res/layout/conversation_message_footer.xml +++ b/res/layout/conversation_message_footer.xml @@ -22,6 +22,14 @@ android:layout_height="wrap_content" android:orientation="vertical" style="@style/ConversationViewSideMarginStyle" > + <LinearLayout + android:id="@+id/attachment_placeholder_load_more" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + android:orientation="vertical" + style="@style/AttachmentMarginStyle" /> + <TextView android:id="@+id/attachments_header_text" android:layout_width="wrap_content" @@ -37,6 +45,7 @@ android:layout_height="wrap_content" android:visibility="gone" style="@style/AttachmentMarginStyle" /> + <LinearLayout android:id="@+id/attachment_bar_list" android:layout_width="match_parent" diff --git a/src/com/android/mail/browse/AttachmentActionHandler.java b/src/com/android/mail/browse/AttachmentActionHandler.java index 4527b4c49..fda1f85f9 100644 --- a/src/com/android/mail/browse/AttachmentActionHandler.java +++ b/src/com/android/mail/browse/AttachmentActionHandler.java @@ -282,7 +282,6 @@ public class AttachmentActionHandler { } private File performAttachmentSave(final Attachment attachment) { - Uri attachmentUri = attachment.uri; try { File downloads = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS); diff --git a/src/com/android/mail/browse/MessageAttachmentBar.java b/src/com/android/mail/browse/MessageAttachmentBar.java index c4c74d093..c870e8b80 100644 --- a/src/com/android/mail/browse/MessageAttachmentBar.java +++ b/src/com/android/mail/browse/MessageAttachmentBar.java @@ -20,6 +20,8 @@ package com.android.mail.browse; import android.app.AlertDialog; import android.app.FragmentManager; import android.content.ActivityNotFoundException; +import android.content.AsyncQueryHandler; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -59,6 +61,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener OnMenuItemClickListener, AttachmentViewInterface { private Attachment mAttachment; + private ImageView mIcon; private TextView mTitle; private TextView mSubTitle; private String mAttachmentSizeText; @@ -125,8 +128,10 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener attachment.destination, attachment.downloadedSize, attachment.contentUri, attachment.getContentType(), attachment.flags); - if ((attachment.flags & Attachment.FLAG_DUMMY_ATTACHMENT) != 0) { - mTitle.setText(R.string.load_attachment); + if (attachment.isLoadMore()) { + mIcon.setImageResource(R.drawable.ic_load_more_holo_light); + mTitle.setText(R.string.load_more); + mOverflowButton.setVisibility(View.GONE); } else if (prevAttachment == null || !TextUtils.equals(attachment.getName(), prevAttachment.getName())) { mTitle.setText(attachment.getName()); @@ -147,6 +152,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener protected void onFinishInflate() { super.onFinishInflate(); + mIcon = (ImageView) findViewById(R.id.attachment_icon); mTitle = (TextView) findViewById(R.id.attachment_title); mSubTitle = (TextView) findViewById(R.id.attachment_subtitle); mProgress = (ProgressBar) findViewById(R.id.attachment_progress); @@ -223,11 +229,13 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener final String mime = Utils.normalizeMimeType(mAttachment.getContentType()); final String action; - if ((mAttachment.flags & Attachment.FLAG_DUMMY_ATTACHMENT) != 0) { - // This is a dummy. We need to download it, but not attempt to open or preview. - mActionHandler.showDownloadingDialog(); - mActionHandler.setViewOnFinish(false); - mActionHandler.startDownloadingAttachment(AttachmentDestination.CACHE); + if (mAttachment.isLoadMore()) { + // Changed to use the Message's load more uri to get the entire mail. + if (mAttachment.messageLoadMoreUri != null) { + LoadMoreAction loadmore = new LoadMoreAction(getContext().getContentResolver(), + mAttachment.messageLoadMoreUri); + loadmore.sendCommand(); + } action = null; } @@ -291,7 +299,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener } private boolean shouldShowSave() { - return mAttachment.canSave() && !mSaveClicked; + return mAttachment.canSave() && !mSaveClicked && !mAttachment.isLoadMore(); } private boolean shouldShowDownloadAgain() { @@ -413,4 +421,17 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener } mSubTitle.setText(sb.toString()); } + + private class LoadMoreAction extends AsyncQueryHandler { + private final Uri mLoadMoreUri; + + public LoadMoreAction(ContentResolver resolver, Uri loadMoreUri) { + super(resolver); + mLoadMoreUri = loadMoreUri; + } + + public void sendCommand() { + startQuery(0, null, mLoadMoreUri, null, null, null, null); + } + } } diff --git a/src/com/android/mail/browse/MessageFooterView.java b/src/com/android/mail/browse/MessageFooterView.java index a3f851641..f73253fc6 100644 --- a/src/com/android/mail/browse/MessageFooterView.java +++ b/src/com/android/mail/browse/MessageFooterView.java @@ -54,6 +54,7 @@ public class MessageFooterView extends LinearLayout implements DetachListener, private LoaderManager mLoaderManager; private FragmentManager mFragmentManager; private AttachmentCursor mAttachmentsCursor; + private LinearLayout mAttachmentLoadMore; private TextView mTitleText; private AttachmentTileGrid mAttachmentGrid; private LinearLayout mAttachmentBarList; @@ -78,6 +79,7 @@ public class MessageFooterView extends LinearLayout implements DetachListener, protected void onFinishInflate() { super.onFinishInflate(); + mAttachmentLoadMore = (LinearLayout) findViewById(R.id.attachment_placeholder_load_more); mTitleText = (TextView) findViewById(R.id.attachments_header_text); mAttachmentGrid = (AttachmentTileGrid) findViewById(R.id.attachment_tile_grid); mAttachmentBarList = (LinearLayout) findViewById(R.id.attachment_bar_list); @@ -97,11 +99,11 @@ public class MessageFooterView extends LinearLayout implements DetachListener, // we're only updating the attachments. if (mMessageHeaderItem != null && mMessageHeaderItem.getMessage() != null && - mMessageHeaderItem.getMessage().attachmentListUri != null && - !mMessageHeaderItem.getMessage().attachmentListUri.equals( - headerItem.getMessage().attachmentListUri)) { + mMessageHeaderItem.getMessage().attachmentListUri != null) { + mAttachmentLoadMore.removeAllViewsInLayout(); mAttachmentGrid.removeAllViewsInLayout(); mAttachmentBarList.removeAllViewsInLayout(); + mAttachmentLoadMore.setVisibility(View.GONE); mTitleText.setVisibility(View.GONE); mAttachmentGrid.setVisibility(View.GONE); mAttachmentBarList.setVisibility(View.GONE); @@ -129,8 +131,9 @@ public class MessageFooterView extends LinearLayout implements DetachListener, } // Do an initial render if initLoader didn't already do one - if (mAttachmentGrid.getChildCount() == 0 && - mAttachmentBarList.getChildCount() == 0) { + if (mAttachmentLoadMore.getChildCount() == 0 + && mAttachmentGrid.getChildCount() == 0 + && mAttachmentBarList.getChildCount() == 0) { renderAttachments(false); } setVisibility(mMessageHeaderItem.isExpanded() ? VISIBLE : GONE); @@ -159,11 +162,21 @@ public class MessageFooterView extends LinearLayout implements DetachListener, // filter the attachments into tiled and non-tiled final int maxSize = attachments.size(); + Attachment loadMore = null; final List<Attachment> tiledAttachments = new ArrayList<Attachment>(maxSize); final List<Attachment> barAttachments = new ArrayList<Attachment>(maxSize); for (Attachment attachment : attachments) { - if (AttachmentTile.isTiledAttachment(attachment)) { + if (attachment.isInlineAttachment()) { + LogUtils.d(LOG_TAG, "attachment(" + attachment.contentUri + + ") is inline attachment. Ignore and do not show it!"); + continue; + } + + if (attachment.isLoadMore()) { + loadMore = attachment; + loadMore.messageLoadMoreUri = mMessageHeaderItem.getMessage().loadMoreUri; + } else if (AttachmentTile.isTiledAttachment(attachment)) { tiledAttachments.add(attachment); } else { barAttachments.add(attachment); @@ -171,12 +184,24 @@ public class MessageFooterView extends LinearLayout implements DetachListener, } mMessageHeaderItem.getMessage().attachmentsJson = Attachment.toJSONArray(attachments); - mTitleText.setVisibility(View.VISIBLE); + if (tiledAttachments.size() > 0 || barAttachments.size() > 0) { + // If there isn't any tiled attachment or bar attachment, + // then we needn't to show the title. + mTitleText.setVisibility(View.VISIBLE); + } + renderLoadMore(loadMore, loaderResult); renderTiledAttachments(tiledAttachments, loaderResult); renderBarAttachments(barAttachments, loaderResult); } + private void renderLoadMore(Attachment loadMore, boolean loaderResult) { + if (loadMore == null) return; + + mAttachmentLoadMore.setVisibility(View.VISIBLE); + renderAttachment(mAttachmentLoadMore, loadMore, loaderResult); + } + private void renderTiledAttachments(List<Attachment> tiledAttachments, boolean loaderResult) { mAttachmentGrid.setVisibility(View.VISIBLE); @@ -189,19 +214,24 @@ public class MessageFooterView extends LinearLayout implements DetachListener, mAttachmentBarList.setVisibility(View.VISIBLE); for (Attachment attachment : barAttachments) { - final Uri id = attachment.getIdentifierUri(); - MessageAttachmentBar barAttachmentView = - (MessageAttachmentBar) mAttachmentBarList.findViewWithTag(id); - - if (barAttachmentView == null) { - barAttachmentView = MessageAttachmentBar.inflate(mInflater, this); - barAttachmentView.setTag(id); - barAttachmentView.initialize(mFragmentManager); - mAttachmentBarList.addView(barAttachmentView); - } + renderAttachment(mAttachmentBarList, attachment, loaderResult); + } + } - barAttachmentView.render(attachment, mAccountUri, loaderResult); + private void renderAttachment(LinearLayout parentView, Attachment attachment, + boolean loaderResult) { + final Uri id = attachment.getIdentifierUri(); + MessageAttachmentBar barAttachmentView = + (MessageAttachmentBar) parentView.findViewWithTag(id); + + if (barAttachmentView == null) { + barAttachmentView = MessageAttachmentBar.inflate(mInflater, this); + barAttachmentView.setTag(id); + barAttachmentView.initialize(mFragmentManager); + parentView.addView(barAttachmentView); } + + barAttachmentView.render(attachment, mAccountUri, loaderResult); } private Integer getAttachmentLoaderId() { diff --git a/src/com/android/mail/browse/MessageHeaderView.java b/src/com/android/mail/browse/MessageHeaderView.java index bc929e90d..9f207a8a6 100644 --- a/src/com/android/mail/browse/MessageHeaderView.java +++ b/src/com/android/mail/browse/MessageHeaderView.java @@ -705,8 +705,8 @@ public class MessageHeaderView extends LinearLayout implements OnClickListener, } private void setLoadMoreVisible() { - if (mMessage.messageFlagLoaded == MessageFlagLoaded.FLAG_LOADED_PARTIAL_COMPLETE - && mOverflowButton == null) { + if (mOverflowButton == null + && mMessage.messageFlagLoaded == MessageFlagLoaded.FLAG_LOADED_PARTIAL_COMPLETE) { setChildVisibility(VISIBLE, mLoadMoreButton); return; } else { diff --git a/src/com/android/mail/providers/Attachment.java b/src/com/android/mail/providers/Attachment.java index 3fba99328..bc73fcff1 100644 --- a/src/com/android/mail/providers/Attachment.java +++ b/src/com/android/mail/providers/Attachment.java @@ -34,11 +34,11 @@ import com.android.mail.providers.UIProvider.AttachmentDestination; import com.android.mail.providers.UIProvider.AttachmentRendition; import com.android.mail.providers.UIProvider.AttachmentState; import com.android.mail.providers.UIProvider.AttachmentType; +import com.android.mail.providers.UIProvider.MessageColumns; import com.android.mail.utils.LogTag; import com.android.mail.utils.LogUtils; import com.android.mail.utils.MimeType; import com.android.mail.utils.Utils; -import com.google.common.base.Objects; import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; @@ -168,6 +168,19 @@ public class Attachment implements Parcelable { */ private boolean supportsDownloadAgain; + /** + * Might be null. + * + * @see AttachmentColumns#CONTENT_ID + */ + public String contentId; + + /** + * Might be null. + * + * @see MessageColumns#MESSAGE_LOAD_MORE_URI + */ + public Uri messageLoadMoreUri = null; public Attachment() { } @@ -187,6 +200,8 @@ public class Attachment implements Parcelable { supportsDownloadAgain = in.readInt() == 1; type = in.readInt(); flags = in.readInt(); + contentId = in.readString(); + messageLoadMoreUri = in.readParcelable(null); } public Attachment(Cursor cursor) { @@ -212,6 +227,7 @@ public class Attachment implements Parcelable { cursor.getColumnIndex(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN)) == 1; type = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.TYPE)); flags = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.FLAGS)); + contentId = cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_ID)); } public Attachment(JSONObject srcJson) { @@ -229,6 +245,7 @@ public class Attachment implements Parcelable { supportsDownloadAgain = srcJson.optBoolean(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, true); type = srcJson.optInt(AttachmentColumns.TYPE); flags = srcJson.optInt(AttachmentColumns.FLAGS); + contentId = srcJson.optString(AttachmentColumns.CONTENT_ID, null); } /** @@ -256,6 +273,8 @@ public class Attachment implements Parcelable { destination = AttachmentDestination.CACHE; type = AttachmentType.STANDARD; flags = 0; + contentId = part.getContentId(); + messageLoadMoreUri = null; // insert attachment into content provider so that we can open the file final ContentResolver resolver = context.getContentResolver(); @@ -301,6 +320,7 @@ public class Attachment implements Parcelable { supportsDownloadAgain = values.getAsBoolean(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN); type = values.getAsInteger(AttachmentColumns.TYPE); flags = values.getAsInteger(AttachmentColumns.FLAGS); + contentId = values.getAsString(AttachmentColumns.CONTENT_ID); } /** @@ -325,6 +345,7 @@ public class Attachment implements Parcelable { values.put(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, supportsDownloadAgain); values.put(AttachmentColumns.TYPE, type); values.put(AttachmentColumns.FLAGS, flags); + values.put(AttachmentColumns.CONTENT_ID, contentId); return values; } @@ -345,6 +366,8 @@ public class Attachment implements Parcelable { dest.writeInt(supportsDownloadAgain ? 1 : 0); dest.writeInt(type); dest.writeInt(flags); + dest.writeString(contentId); + dest.writeParcelable(messageLoadMoreUri, flags); } public JSONObject toJSON() throws JSONException { @@ -364,6 +387,7 @@ public class Attachment implements Parcelable { result.put(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, supportsDownloadAgain); result.put(AttachmentColumns.TYPE, type); result.put(AttachmentColumns.FLAGS, flags); + result.put(AttachmentColumns.CONTENT_ID, contentId); return result; } @@ -448,6 +472,14 @@ public class Attachment implements Parcelable { return state == AttachmentState.FAILED || state == AttachmentState.SAVED; } + public boolean isInlineAttachment() { + return !TextUtils.isEmpty(contentId); + } + + public boolean isLoadMore() { + return (flags & Attachment.FLAG_DUMMY_ATTACHMENT) != 0; + } + public boolean supportsDownloadAgain() { return supportsDownloadAgain; } @@ -578,6 +610,9 @@ public class Attachment implements Parcelable { if (uri != null ? !uri.equals(that.uri) : that.uri != null) { return false; } + if (contentId != null ? !contentId.equals(that.contentId) : that.contentId != null) { + return false; + } return true; } @@ -598,6 +633,7 @@ public class Attachment implements Parcelable { result = 31 * result + type; result = 31 * result + (providerData != null ? providerData.hashCode() : 0); result = 31 * result + (supportsDownloadAgain ? 1 : 0); + result = 31 * result + (contentId != null ? contentId.hashCode() : 0); return result; } @@ -648,7 +684,8 @@ public class Attachment implements Parcelable { contentUri != null ? SERVER_ATTACHMENT : LOCAL_FILE, contentUri != null ? contentUri.toString() : "", "" /* cachedFileUri */, - String.valueOf(type))); + String.valueOf(type), + contentId)); } /** diff --git a/src/com/android/mail/providers/MessageInfo.java b/src/com/android/mail/providers/MessageInfo.java index b197b7cd9..c4fe3fb86 100644 --- a/src/com/android/mail/providers/MessageInfo.java +++ b/src/com/android/mail/providers/MessageInfo.java @@ -26,6 +26,7 @@ public class MessageInfo implements Parcelable { public boolean read; public boolean starred; + public boolean hasAttachments; public String sender; public String senderEmail; public int priority; @@ -33,14 +34,15 @@ public class MessageInfo implements Parcelable { public MessageInfo() { } - public MessageInfo(boolean isRead, boolean isStarred, String senderString, int p, + public MessageInfo(boolean isRead, boolean isStarred, boolean has, String senderString, int p, String email) { - set(isRead, isStarred, senderString, p, email); + set(isRead, isStarred, has, senderString, p, email); } private MessageInfo(Parcel in) { read = (in.readInt() != 0); starred = (in.readInt() != 0); + hasAttachments = (in.readInt() != 0); sender = in.readString(); priority = in.readInt(); senderEmail = in.readString(); @@ -55,14 +57,17 @@ public class MessageInfo implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(read ? 1 : 0); dest.writeInt(starred ? 1 : 0); + dest.writeInt(hasAttachments ? 1 : 0); dest.writeString(sender); dest.writeInt(priority); dest.writeString(senderEmail); } - public void set(boolean isRead, boolean isStarred, String senderString, int p, String email) { + public void set(boolean isRead, boolean isStarred, boolean has, String senderString, int p, + String email) { read = isRead; starred = isStarred; + hasAttachments = has; sender = senderString; priority = p; senderEmail = email; @@ -78,7 +83,7 @@ public class MessageInfo implements Parcelable { @Override public int hashCode() { - return Objects.hashCode(read, starred, sender, senderEmail); + return Objects.hashCode(read, starred, hasAttachments, sender, senderEmail); } public static final Creator<MessageInfo> CREATOR = new Creator<MessageInfo>() { @@ -100,6 +105,10 @@ public class MessageInfo implements Parcelable { final StringBuilder builder = new StringBuilder(); builder.append("[MessageInfo: read = "); builder.append(read); + builder.append(", starred = "); + builder.append(starred); + builder.append(", hasAttachments = "); + builder.append(hasAttachments); builder.append(", sender = "); builder.append(sender); builder.append(", senderEmail = "); diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java index 71c27518f..cb2302a27 100644 --- a/src/com/android/mail/providers/UIProvider.java +++ b/src/com/android/mail/providers/UIProvider.java @@ -1907,7 +1907,8 @@ public class UIProvider { AttachmentColumns.PROVIDER_DATA, AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, AttachmentColumns.TYPE, - AttachmentColumns.FLAGS + AttachmentColumns.FLAGS, + AttachmentColumns.CONTENT_ID }; public static final int ATTACHMENT_NAME_COLUMN = 0; public static final int ATTACHMENT_SIZE_COLUMN = 1; @@ -1922,6 +1923,7 @@ public class UIProvider { public static final int ATTACHMENT_SUPPORTS_DOWNLOAD_AGAIN_COLUMN = 10; public static final int ATTACHMENT_TYPE_COLUMN = 11; public static final int ATTACHMENT_FLAGS_COLUMN = 12; + public static final int ATTACHMENT_CONTENT_ID_COLUMN = 13; /** Separates attachment info parts in strings in the database. */ public static final String ATTACHMENT_INFO_SEPARATOR = "\n"; // use to join @@ -2085,7 +2087,6 @@ public class UIProvider { * This column contains provider-specific private data as JSON string. */ public static final String PROVIDER_DATA = "providerData"; - /** * This column represents whether this attachment supports the ability to be downloaded * again. @@ -2096,11 +2097,15 @@ public class UIProvider { * {@link AttachmentType} constants. */ public static final String TYPE = "type"; - /** * This column holds various bitwise flags for status information. */ public static final String FLAGS = "flags"; + /** + * The column saved (internal) contentId of the attachment + * (inline attachments will have these) + */ + public static final String CONTENT_ID = "contentId"; private AttachmentColumns() {} } diff --git a/src/com/android/mail/providers/protos/mock/MockUiProvider.java b/src/com/android/mail/providers/protos/mock/MockUiProvider.java index af8889d69..67e5275a8 100644 --- a/src/com/android/mail/providers/protos/mock/MockUiProvider.java +++ b/src/com/android/mail/providers/protos/mock/MockUiProvider.java @@ -231,14 +231,14 @@ public final class MockUiProvider extends ContentProvider { "firstUnread", "last"); for (int i = 0; i < messageCount; i++) { if (i % 2 == 0) { - info.addMessage(new MessageInfo(false, false, + info.addMessage(new MessageInfo(false, false, false, i + "Test <testsender@test.com>", -1, "testsender@test.com")); } else if (i % 3 == 0) { - info.addMessage(new MessageInfo(true, false, i + "sender@test.com", -1, - "sender@test.com")); + info.addMessage(new MessageInfo(true, false, false, + i + "sender@test.com", -1, "sender@test.com")); } else { - info.addMessage(new MessageInfo(false, false, MessageInfo.SENDER_LIST_TOKEN_ELIDED, - -1, null)); + info.addMessage(new MessageInfo(false, false, false, + MessageInfo.SENDER_LIST_TOKEN_ELIDED, -1, null)); } } return info.toBlob(); diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java index 45bc56b23..220c8033b 100644 --- a/src/com/android/mail/ui/AbstractActivityController.java +++ b/src/com/android/mail/ui/AbstractActivityController.java @@ -28,6 +28,7 @@ import android.app.Fragment; import android.app.FragmentManager; import android.app.LoaderManager; import android.app.SearchManager; +import android.content.AsyncQueryHandler; import android.content.ContentProviderOperation; import android.content.ContentResolver; import android.content.ContentValues; @@ -422,7 +423,6 @@ public abstract class AbstractActivityController implements ActivityController, /** The pending destructive action to be carried out before swapping the conversation cursor.*/ private DestructiveAction mPendingDestruction; protected AsyncRefreshTask mFolderSyncTask; - protected AsyncRefreshTask mLoadMoreTask; private Folder mFolderListFolder; private boolean mIsDragHappening; private final int mShowUndoBarDelay; @@ -1896,16 +1896,22 @@ public abstract class AbstractActivityController implements ActivityController, @Override public void loadMore(ConversationMessage msg) { if (msg != null && msg.loadMoreUri != null) { - startLoadMoreTask(msg.loadMoreUri); + LoadMoreAction action = new LoadMoreAction(mResolver, msg.loadMoreUri); + action.sendCommand(); } } - private void startLoadMoreTask(Uri uri) { - if (mLoadMoreTask != null) { - mLoadMoreTask.cancel(true); + private class LoadMoreAction extends AsyncQueryHandler { + private final Uri mLoadMoreUri; + + public LoadMoreAction(ContentResolver resolver, Uri loadMoreUri) { + super(resolver); + mLoadMoreUri = loadMoreUri; + } + + public void sendCommand() { + startQuery(0, null, mLoadMoreUri, null, null, null, null); } - mLoadMoreTask = new AsyncRefreshTask(mActivity.getActivityContext(), uri); - mLoadMoreTask.execute(); } @Override diff --git a/src/com/android/mail/ui/SecureConversationViewController.java b/src/com/android/mail/ui/SecureConversationViewController.java index 7c40a722c..b03c72d2d 100644 --- a/src/com/android/mail/ui/SecureConversationViewController.java +++ b/src/com/android/mail/ui/SecureConversationViewController.java @@ -166,9 +166,14 @@ public class SecureConversationViewController implements // Clear out the old info from the header before (re)binding mMessageHeaderView.unbind(); mMessageHeaderView.bind(item, false); - if (mMessage.hasAttachments) { + if (mMessage.hasAttachments + || mMessage.messageFlagLoaded == MessageFlagLoaded.FLAG_LOADED_PARTIAL_COMPLETE) { + // Do not have the attachment, but the flag is partial complete, it must contains + // the load more placeholder, and we will show it. mMessageFooterView.setVisibility(View.VISIBLE); mMessageFooterView.bind(item, mCallbacks.getAccountUri(), false); + } else { + mMessageFooterView.setVisibility(View.GONE); } if (mMessage.messageFlagLoaded == MessageFlagLoaded.FLAG_LOADED_PARTIAL || mMessage.messageFlagLoaded == MessageFlagLoaded.FLAG_LOADED_PARTIAL_FETCHING) { diff --git a/tests/src/com/android/mail/browse/SendersFormattingTests.java b/tests/src/com/android/mail/browse/SendersFormattingTests.java index 2020c055b..200b7c72c 100644 --- a/tests/src/com/android/mail/browse/SendersFormattingTests.java +++ b/tests/src/com/android/mail/browse/SendersFormattingTests.java @@ -38,8 +38,8 @@ public class SendersFormattingTests extends AndroidTestCase { public void testMe() { // Blank sender == from "me" ConversationInfo conv = createConversationInfo(1); - boolean read = false, starred = false; - MessageInfo info = new MessageInfo(read, starred, null, -1, null); + boolean read = false, starred = false, hasAttachments = false; + MessageInfo info = new MessageInfo(read, starred, hasAttachments, null, -1, null); conv.addMessage(info); ArrayList<SpannableString> strings = new ArrayList<SpannableString>(); ArrayList<String> emailDisplays = null; @@ -49,7 +49,7 @@ public class SendersFormattingTests extends AndroidTestCase { assertEquals(strings.get(0).toString(), "me"); ConversationInfo conv2 = createConversationInfo(1); - MessageInfo info2 = new MessageInfo(read, starred, "", -1, null); + MessageInfo info2 = new MessageInfo(read, starred, hasAttachments, "", -1, null); strings.clear(); conv2.addMessage(info2); SendersView.format(getContext(), conv, "", 100, strings, emailDisplays, emailDisplays, @@ -58,9 +58,9 @@ public class SendersFormattingTests extends AndroidTestCase { assertEquals(strings.get(0).toString(), "me"); ConversationInfo conv3 = createConversationInfo(2); - MessageInfo info3 = new MessageInfo(read, starred, "", -1, null); + MessageInfo info3 = new MessageInfo(read, starred, hasAttachments, "", -1, null); conv3.addMessage(info3); - MessageInfo info4 = new MessageInfo(read, starred, "", -1, null); + MessageInfo info4 = new MessageInfo(read, starred, hasAttachments, "", -1, null); conv3.addMessage(info4); strings.clear(); SendersView.format(getContext(), conv, "", 100, strings, emailDisplays, emailDisplays, @@ -74,11 +74,11 @@ public class SendersFormattingTests extends AndroidTestCase { ArrayList<SpannableString> strings = new ArrayList<SpannableString>(); ArrayList<String> emailDisplays = null; ConversationInfo conv = createConversationInfo(2); - boolean read = false, starred = false; + boolean read = false, starred = false, hasAttachments = false; String sender = "sender@sender.com"; - MessageInfo info = new MessageInfo(read, starred, sender, -1, null); + MessageInfo info = new MessageInfo(read, starred, hasAttachments, sender, -1, null); conv.addMessage(info); - MessageInfo info2 = new MessageInfo(read, starred, sender, -1, null); + MessageInfo info2 = new MessageInfo(read, starred, hasAttachments, sender, -1, null); conv.addMessage(info2); SendersView.format(getContext(), conv, "", 100, strings, emailDisplays, emailDisplays, null, false); @@ -96,7 +96,7 @@ public class SendersFormattingTests extends AndroidTestCase { public void testSenderNameBadInput() { final ConversationInfo conv = createConversationInfo(1); - final MessageInfo msg = new MessageInfo(false, false, "****^****", 0, null); + final MessageInfo msg = new MessageInfo(false, false, false, "****^****", 0, null); conv.addMessage(msg); final byte[] serialized = conv.toBlob(); @@ -113,7 +113,7 @@ public class SendersFormattingTests extends AndroidTestCase { final ConversationInfo conv = new ConversationInfo(42, 49, firstSnippet, firstUnreadSnippet, lastSnippet); - final MessageInfo msg = new MessageInfo(false, false, "Foo Bar", 0, null); + final MessageInfo msg = new MessageInfo(false, false, false, "Foo Bar", 0, null); conv.addMessage(msg); assertEquals(firstSnippet, conv.firstSnippet); diff --git a/tests/src/com/android/mail/compose/ComposeActivityTest.java b/tests/src/com/android/mail/compose/ComposeActivityTest.java index b6cc4eea8..0f324a46d 100644 --- a/tests/src/com/android/mail/compose/ComposeActivityTest.java +++ b/tests/src/com/android/mail/compose/ComposeActivityTest.java @@ -984,7 +984,7 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos @Override public void run() { activity.mRefMessage = refMessage; - activity.initAttachments(refMessage); + activity.initAttachments(refMessage, true); assertEquals(activity.getAttachments().size(), 2); activity.onNavigationItemSelected(1, ComposeActivity.REPLY); assertEquals(activity.getAttachments().size(), 0); |