summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2014-07-06 14:00:42 +0200
committerJorge Ruesga <jorge@ruesga.com>2014-07-07 01:35:32 +0000
commit7716fdfb028a2b2ad70c239680cb4369bcbafa31 (patch)
treed28f13ad66105d3d57c325d942073c8810b57703
parent012620492471e229a8856659a5d036639b24fb06 (diff)
downloadandroid_packages_apps_UnifiedEmail-7716fdfb028a2b2ad70c239680cb4369bcbafa31.tar.gz
android_packages_apps_UnifiedEmail-7716fdfb028a2b2ad70c239680cb4369bcbafa31.tar.bz2
android_packages_apps_UnifiedEmail-7716fdfb028a2b2ad70c239680cb4369bcbafa31.zip
unifiedemail: display a "load more" button
If the message is partial loaded, then show a "load more" button instead of an attachment bar. A partial message doesn't implies that the message contains attachments or that all attachment were loaded. Require http://review.cyanogenmod.org/#/c/67523/ Change-Id: I8998ac7f7c46d7e6698ee471fb89185504d1ecf0 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--res/drawable-hdpi/ic_menu_sync_grey_holo.pngbin0 -> 1683 bytes
-rw-r--r--res/drawable-mdpi/ic_menu_sync_grey_holo.pngbin0 -> 1092 bytes
-rw-r--r--res/drawable-xhdpi/ic_menu_sync_grey_holo.pngbin0 -> 2333 bytes
-rw-r--r--res/layout/conversation_message_footer.xml8
-rw-r--r--res/layout/conversation_message_load_more_bar.xml77
-rw-r--r--res/values/cm_strings.xml23
-rw-r--r--src/com/android/mail/browse/AttachmentActionHandler.java10
-rw-r--r--src/com/android/mail/browse/AttachmentProgressDialogFragment.java7
-rw-r--r--src/com/android/mail/browse/ConversationMessage.java2
-rw-r--r--src/com/android/mail/browse/MessageAttachmentBar.java10
-rw-r--r--src/com/android/mail/browse/MessageCursor.java13
-rw-r--r--src/com/android/mail/browse/MessageFooterView.java76
-rw-r--r--src/com/android/mail/browse/MessageLoadMoreBar.java100
-rw-r--r--src/com/android/mail/providers/Message.java9
-rw-r--r--src/com/android/mail/providers/MessageInfo.java15
-rw-r--r--src/com/android/mail/providers/UIProvider.java15
-rw-r--r--src/com/android/mail/providers/protos/mock/MockUiProvider.java7
17 files changed, 340 insertions, 32 deletions
diff --git a/res/drawable-hdpi/ic_menu_sync_grey_holo.png b/res/drawable-hdpi/ic_menu_sync_grey_holo.png
new file mode 100644
index 000000000..4c7060d91
--- /dev/null
+++ b/res/drawable-hdpi/ic_menu_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_sync_grey_holo.png b/res/drawable-mdpi/ic_menu_sync_grey_holo.png
new file mode 100644
index 000000000..bb4267f0b
--- /dev/null
+++ b/res/drawable-mdpi/ic_menu_sync_grey_holo.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_sync_grey_holo.png b/res/drawable-xhdpi/ic_menu_sync_grey_holo.png
new file mode 100644
index 000000000..10cc48abd
--- /dev/null
+++ b/res/drawable-xhdpi/ic_menu_sync_grey_holo.png
Binary files differ
diff --git a/res/layout/conversation_message_footer.xml b/res/layout/conversation_message_footer.xml
index dc783b2c1..4d632b0e6 100644
--- a/res/layout/conversation_message_footer.xml
+++ b/res/layout/conversation_message_footer.xml
@@ -45,4 +45,12 @@
android:orientation="vertical"
style="@style/AttachmentMarginStyle" />
+ <include layout="@layout/conversation_message_load_more_bar"
+ android:id="@+id/message_load_more"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:visibility="gone"
+ style="@style/AttachmentMarginStyle" />
+
</com.android.mail.browse.MessageFooterView>
diff --git a/res/layout/conversation_message_load_more_bar.xml b/res/layout/conversation_message_load_more_bar.xml
new file mode 100644
index 000000000..b36a52fd0
--- /dev/null
+++ b/res/layout/conversation_message_load_more_bar.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012 Google Inc.
+ Licensed to 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.
+-->
+<com.android.mail.browse.MessageLoadMoreBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dip"
+ android:background="@drawable/attachment_bg_holo"
+ android:minHeight="48dip" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/load_more_icon"
+ android:layout_width="48dip"
+ android:layout_height="match_parent"
+ android:layout_marginRight="8dip"
+ android:background="@color/attachment_image_background_color"
+ android:scaleType="center"
+ android:src="@drawable/ic_menu_sync_grey_holo" />
+
+ <RelativeLayout
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1" >
+
+ <TextView
+ android:id="@+id/load_more_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="8dip"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#333333"
+ android:textSize="14sp"
+ android:text="@string/load_more" />
+
+ <TextView
+ android:id="@+id/load_more_subtitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/load_more_title"
+ android:layout_marginRight="8dip"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#aaaaaa"
+ android:textSize="12sp"
+ android:text="@string/load_more_summary" />
+ </RelativeLayout>
+ </LinearLayout>
+
+ <View
+ android:id="@+id/attachment_push_state"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:attr/selectableItemBackground"
+ android:focusable="true" />
+
+</com.android.mail.browse.MessageLoadMoreBar> \ No newline at end of file
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
new file mode 100644
index 000000000..c1ca4fed6
--- /dev/null
+++ b/res/values/cm_strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The CyanogenMod 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- On conversation message, the message for the summary for load more button -->
+ <string name="load_more_summary">Tap here to load the rest of the message</string>
+
+ <!-- Dialog title for fetching the rest of the message -->
+ <string name="fetching_message">Fetching message</string>
+</resources>
diff --git a/src/com/android/mail/browse/AttachmentActionHandler.java b/src/com/android/mail/browse/AttachmentActionHandler.java
index 9c1fa0064..2b1723de6 100644
--- a/src/com/android/mail/browse/AttachmentActionHandler.java
+++ b/src/com/android/mail/browse/AttachmentActionHandler.java
@@ -88,7 +88,7 @@ public class AttachmentActionHandler {
mAttachment.destination == destination)) {
mView.viewAttachment();
} else {
- showDownloadingDialog();
+ showDownloadingDialog(false);
startDownloadingAttachment(destination);
}
}
@@ -138,8 +138,11 @@ public class AttachmentActionHandler {
/**
* Displays a loading dialog to be used for downloading attachments.
* Must be called on the UI thread.
+ *
+ * @param isForLoadRestOfMessage If the dialog is showed for load the rest of the message
+ * {@code true} or just for attachments {@code false}
*/
- public void showDownloadingDialog() {
+ public DialogFragment showDownloadingDialog(boolean isForLoadRestOfMessage) {
final FragmentTransaction ft = mFragmentManager.beginTransaction();
final Fragment prev = mFragmentManager.findFragmentByTag(PROGRESS_FRAGMENT_TAG);
if (prev != null) {
@@ -149,8 +152,9 @@ public class AttachmentActionHandler {
// Create and show the dialog.
final DialogFragment newFragment = AttachmentProgressDialogFragment.newInstance(
- mAttachment);
+ mAttachment, isForLoadRestOfMessage);
newFragment.show(ft, PROGRESS_FRAGMENT_TAG);
+ return newFragment;
}
/**
diff --git a/src/com/android/mail/browse/AttachmentProgressDialogFragment.java b/src/com/android/mail/browse/AttachmentProgressDialogFragment.java
index 81a3f6c9e..e6c4bbc7b 100644
--- a/src/com/android/mail/browse/AttachmentProgressDialogFragment.java
+++ b/src/com/android/mail/browse/AttachmentProgressDialogFragment.java
@@ -33,10 +33,12 @@ public class AttachmentProgressDialogFragment extends DialogFragment {
private AttachmentCommandHandler mCommandHandler;
private Attachment mAttachment;
+ private boolean mIsForLoadRestOfMessage;
private ProgressDialog mDialog;
- static AttachmentProgressDialogFragment newInstance(Attachment attachment) {
+ static AttachmentProgressDialogFragment newInstance(Attachment attachment,
+ boolean isForLoadRestOfMessage) {
final AttachmentProgressDialogFragment f = new AttachmentProgressDialogFragment();
// Supply the attachment as an argument.
@@ -66,7 +68,8 @@ public class AttachmentProgressDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
mDialog = new ProgressDialog(getActivity());
- mDialog.setTitle(R.string.fetching_attachment);
+ mDialog.setTitle(mIsForLoadRestOfMessage ? R.string.fetching_message
+ : R.string.fetching_attachment);
mDialog.setMessage(mAttachment.getName());
mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mDialog.setIndeterminate(true);
diff --git a/src/com/android/mail/browse/ConversationMessage.java b/src/com/android/mail/browse/ConversationMessage.java
index e9aa875a1..01243f5a4 100644
--- a/src/com/android/mail/browse/ConversationMessage.java
+++ b/src/com/android/mail/browse/ConversationMessage.java
@@ -72,7 +72,7 @@ public final class ConversationMessage extends Message {
*
*/
public int getStateHashCode() {
- return Objects.hashCode(uri, read, starred, getAttachmentsStateHashCode());
+ return Objects.hashCode(uri, loaded, read, starred, getAttachmentsStateHashCode());
}
private int getAttachmentsStateHashCode() {
diff --git a/src/com/android/mail/browse/MessageAttachmentBar.java b/src/com/android/mail/browse/MessageAttachmentBar.java
index cfcbb34b7..41c880a65 100644
--- a/src/com/android/mail/browse/MessageAttachmentBar.java
+++ b/src/com/android/mail/browse/MessageAttachmentBar.java
@@ -90,6 +90,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
super(context, attrs);
mActionHandler = new AttachmentActionHandler(context, this);
+ mActionHandler.setViewOnFinish(false);
}
public void initialize(FragmentManager fragmentManager) {
@@ -108,6 +109,8 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
* cause sub-views to update.
*/
public void render(Attachment attachment, Uri accountUri, boolean loaderResult) {
+ mActionHandler.setViewOnFinish(false);
+
// get account uri for potential eml viewer usage
mAccountUri = accountUri;
@@ -170,6 +173,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
}
private boolean onClick(final int res, final View v) {
+ mActionHandler.setViewOnFinish(true);
if (res == R.id.preview_attachment) {
previewAttachment();
} else if (res == R.id.save_attachment) {
@@ -183,7 +187,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
}
} else if (res == R.id.download_again) {
if (mAttachment.isPresentLocally()) {
- mActionHandler.showDownloadingDialog();
+ mActionHandler.showDownloadingDialog(false);
mActionHandler.startRedownloadingAttachment(mAttachment);
Analytics.getInstance().sendEvent("redownload_attachment",
@@ -226,7 +230,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
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.showDownloadingDialog(false);
mActionHandler.setViewOnFinish(false);
mActionHandler.startDownloadingAttachment(AttachmentDestination.CACHE);
@@ -312,6 +316,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
@Override
public void viewAttachment() {
+System.out.println("JRC::viewAttachment(): " + mAttachment.contentUri);
if (mAttachment.contentUri == null) {
LogUtils.e(LOG_TAG, "viewAttachment with null content uri");
return;
@@ -342,6 +347,7 @@ public class MessageAttachmentBar extends FrameLayout implements OnClickListener
private void previewAttachment() {
if (mAttachment.canPreview()) {
+System.out.println("JRC::previewAttachment(): " + mAttachment.previewIntentUri);
final Intent previewIntent =
new Intent(Intent.ACTION_VIEW, mAttachment.previewIntentUri);
getContext().startActivity(previewIntent);
diff --git a/src/com/android/mail/browse/MessageCursor.java b/src/com/android/mail/browse/MessageCursor.java
index 5a4146a7b..e41108f92 100644
--- a/src/com/android/mail/browse/MessageCursor.java
+++ b/src/com/android/mail/browse/MessageCursor.java
@@ -84,6 +84,15 @@ public class MessageCursor extends ObjectCursor<ConversationMessage> {
return false;
}
+ public boolean isConversationLoaded() {
+ int pos = -1;
+ while (moveToPosition(++pos)) {
+ if (!getMessage().loaded) {
+ return false;
+ }
+ }
+ return true;
+ }
public boolean isConversationRead() {
int pos = -1;
@@ -160,9 +169,9 @@ public class MessageCursor extends ObjectCursor<ConversationMessage> {
}
sb.append(String.format(
"[Message #%d hash=%s uri=%s id=%s serverId=%s from='%s' draftType=%d" +
- " isSending=%s read=%s starred=%s attUris=%s]\n",
+ " isSending=%s loaded=%s read=%s starred=%s attUris=%s]\n",
pos, m.getStateHashCode(), m.uri, m.id, m.serverId, m.getFrom(), m.draftType,
- m.isSending, m.read, m.starred, attUris));
+ m.isSending, m.loaded, m.read, m.starred, attUris));
}
return sb.toString();
}
diff --git a/src/com/android/mail/browse/MessageFooterView.java b/src/com/android/mail/browse/MessageFooterView.java
index a3f851641..50d27ea6f 100644
--- a/src/com/android/mail/browse/MessageFooterView.java
+++ b/src/com/android/mail/browse/MessageFooterView.java
@@ -24,12 +24,14 @@ import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.android.emailcommon.provider.EmailContent;
import com.android.mail.R;
import com.android.mail.browse.AttachmentLoader.AttachmentCursor;
import com.android.mail.browse.ConversationContainer.DetachListener;
@@ -54,6 +56,7 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
private LoaderManager mLoaderManager;
private FragmentManager mFragmentManager;
private AttachmentCursor mAttachmentsCursor;
+ private MessageLoadMoreBar mLoadMore;
private TextView mTitleText;
private AttachmentTileGrid mAttachmentGrid;
private LinearLayout mAttachmentBarList;
@@ -78,6 +81,7 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
protected void onFinishInflate() {
super.onFinishInflate();
+ mLoadMore = (MessageLoadMoreBar)findViewById(R.id.message_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);
@@ -86,6 +90,7 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
public void initialize(LoaderManager loaderManager, FragmentManager fragmentManager) {
mLoaderManager = loaderManager;
mFragmentManager = fragmentManager;
+ mLoadMore.initialize(fragmentManager);
}
public void bind(MessageHeaderItem headerItem, Uri accountUri, boolean measureOnly) {
@@ -102,17 +107,41 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
headerItem.getMessage().attachmentListUri)) {
mAttachmentGrid.removeAllViewsInLayout();
mAttachmentBarList.removeAllViewsInLayout();
+ mLoadMore.setVisibility(View.GONE);
mTitleText.setVisibility(View.GONE);
mAttachmentGrid.setVisibility(View.GONE);
mAttachmentBarList.setVisibility(View.GONE);
}
+ mMessageHeaderItem = headerItem;
+
+ Message msg = mMessageHeaderItem.getMessage();
+ if (!msg.loaded) {
+ mLoadMore.setVisibility(View.VISIBLE);
+
+ // We need to load the dummy attachment
+ requestLoader(measureOnly);
+
+ } else {
+ mLoadMore.setVisibility(View.GONE);
+
+ // Request load of attachment
+ requestLoader(measureOnly);
+
+ // Do an initial render if initLoader didn't already do one
+ if (mAttachmentGrid.getChildCount() == 0 &&
+ mAttachmentBarList.getChildCount() == 0) {
+ renderAttachments(false);
+ }
+ }
+ setVisibility(mMessageHeaderItem.isExpanded() ? VISIBLE : GONE);
+ }
+
+ private void requestLoader(boolean measureOnly) {
// If this MessageFooterView is being bound to a new attachment, we need to unbind with the
// old loader
final Integer oldAttachmentLoaderId = getAttachmentLoaderId();
- mMessageHeaderItem = headerItem;
-
final Integer attachmentLoaderId = getAttachmentLoaderId();
// Destroy the loader if we are attempting to load a different attachment
if (oldAttachmentLoaderId != null &&
@@ -127,13 +156,6 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
attachmentLoaderId);
mLoaderManager.initLoader(attachmentLoaderId, Bundle.EMPTY, this);
}
-
- // Do an initial render if initLoader didn't already do one
- if (mAttachmentGrid.getChildCount() == 0 &&
- mAttachmentBarList.getChildCount() == 0) {
- renderAttachments(false);
- }
- setVisibility(mMessageHeaderItem.isExpanded() ? VISIBLE : GONE);
}
private void renderAttachments(boolean loaderResult) {
@@ -157,24 +179,42 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
return;
}
+ final Message msg = mMessageHeaderItem.getMessage();
+
+
// filter the attachments into tiled and non-tiled
final int maxSize = attachments.size();
final List<Attachment> tiledAttachments = new ArrayList<Attachment>(maxSize);
final List<Attachment> barAttachments = new ArrayList<Attachment>(maxSize);
for (Attachment attachment : attachments) {
+ // We don't need to show dummy or incomplete attachments. We have a load more
+ // to load the rest of the message
+ if (TextUtils.isEmpty(attachment.getName()) ||
+ (attachment.flags & EmailContent.Attachment.FLAG_DUMMY_ATTACHMENT) ==
+ EmailContent.Attachment.FLAG_DUMMY_ATTACHMENT) {
+ continue;
+ }
if (AttachmentTile.isTiledAttachment(attachment)) {
tiledAttachments.add(attachment);
} else {
barAttachments.add(attachment);
}
}
- mMessageHeaderItem.getMessage().attachmentsJson = Attachment.toJSONArray(attachments);
+ msg.attachmentsJson = Attachment.toJSONArray(attachments);
- mTitleText.setVisibility(View.VISIBLE);
+ int tiledAttachmentsCount = tiledAttachments.size();
+ int barAttachmentsCount = barAttachments.size();
+ if (tiledAttachmentsCount + barAttachmentsCount > 0) {
+ mTitleText.setVisibility(View.VISIBLE);
+ }
- renderTiledAttachments(tiledAttachments, loaderResult);
- renderBarAttachments(barAttachments, loaderResult);
+ if (tiledAttachmentsCount > 0) {
+ renderTiledAttachments(tiledAttachments, loaderResult);
+ }
+ if (barAttachmentsCount > 0) {
+ renderBarAttachments(barAttachments, loaderResult);
+ }
}
private void renderTiledAttachments(List<Attachment> tiledAttachments, boolean loaderResult) {
@@ -228,10 +268,18 @@ public class MessageFooterView extends LinearLayout implements DetachListener,
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAttachmentsCursor = (AttachmentCursor) data;
- if (mAttachmentsCursor == null || mAttachmentsCursor.isClosed()) {
+ if (mMessageHeaderItem == null || mAttachmentsCursor == null
+ || mAttachmentsCursor.isClosed()) {
return;
}
+ final Message msg = mMessageHeaderItem.getMessage();
+ if (msg.loaded) {
+ mLoadMore.onMessageLoaded();
+ } else {
+ mAttachmentsCursor.moveToPosition(0);
+ mLoadMore.setAttachment(mAttachmentsCursor.get());
+ }
renderAttachments(true);
}
diff --git a/src/com/android/mail/browse/MessageLoadMoreBar.java b/src/com/android/mail/browse/MessageLoadMoreBar.java
new file mode 100644
index 000000000..6e11dad9e
--- /dev/null
+++ b/src/com/android/mail/browse/MessageLoadMoreBar.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to 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.mail.browse;
+
+import android.app.DialogFragment;
+import android.app.FragmentManager;
+import android.content.Context;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.FrameLayout;
+
+import com.android.mail.providers.Attachment;
+import com.android.mail.providers.UIProvider.AttachmentDestination;
+
+public class MessageLoadMoreBar extends FrameLayout implements OnClickListener,
+ AttachmentViewInterface {
+
+ private final AttachmentActionHandler mActionHandler;
+ private DialogFragment mDialog;
+ private Handler mHandler;
+
+ public MessageLoadMoreBar(Context context) {
+ this(context, null);
+ }
+
+ public MessageLoadMoreBar(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ mActionHandler = new AttachmentActionHandler(context, this);
+ mHandler = new Handler();
+ }
+
+ public void initialize(FragmentManager fragmentManager) {
+ mActionHandler.initialize(fragmentManager);
+ }
+
+ public void setAttachment(Attachment attachment) {
+ mActionHandler.setAttachment(attachment);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (mDialog != null) {
+ mDialog.dismiss();
+ }
+ mDialog = mActionHandler.showDownloadingDialog(true);
+ mActionHandler.setViewOnFinish(false);
+ mActionHandler.startDownloadingAttachment(AttachmentDestination.CACHE);
+ }
+
+ public void onMessageLoaded() {
+ // This method is invoked from the onLoadFinished method, so it's must be
+ // called in the uithread to dismiss the dialog
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mDialog != null) {
+ mDialog.dismiss();
+ }
+ mDialog = null;
+ }
+ });
+ }
+
+ @Override
+ public void viewAttachment() {
+ }
+
+ @Override
+ public void updateProgress(boolean showDeterminateProgress) {
+ }
+
+ @Override
+ public void onUpdateStatus() {
+ }
+
+}
diff --git a/src/com/android/mail/providers/Message.java b/src/com/android/mail/providers/Message.java
index 4b70d34fa..a3c80aec2 100644
--- a/src/com/android/mail/providers/Message.java
+++ b/src/com/android/mail/providers/Message.java
@@ -35,6 +35,7 @@ import com.android.emailcommon.internet.MimeMessage;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.mail.Part;
+import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.utility.ConversionUtilities;
import com.android.mail.providers.UIProvider.MessageColumns;
import com.android.mail.ui.HtmlMessage;
@@ -147,6 +148,10 @@ public class Message implements Parcelable, HtmlMessage {
*/
public boolean alwaysShowImages;
/**
+ * @see UIProvider.MessageColumns#LOADED
+ */
+ public boolean loaded;
+ /**
* @see UIProvider.MessageColumns#READ
*/
public boolean read;
@@ -254,6 +259,7 @@ public class Message implements Parcelable, HtmlMessage {
dest.writeInt(spamLinkType);
dest.writeString(viaDomain);
dest.writeInt(isSending ? 1 : 0);
+ dest.writeInt(loaded ? 1 : 0);
}
private Message(Parcel in) {
@@ -288,6 +294,7 @@ public class Message implements Parcelable, HtmlMessage {
spamLinkType = in.readInt();
viaDomain = in.readString();
isSending = in.readInt() != 0;
+ loaded = in.readInt() != 0;
}
public Message() {
@@ -362,6 +369,8 @@ public class Message implements Parcelable, HtmlMessage {
spamLinkType = cursor.getInt(UIProvider.MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN);
viaDomain = cursor.getString(UIProvider.MESSAGE_VIA_DOMAIN_COLUMN);
isSending = cursor.getInt(UIProvider.MESSAGE_IS_SENDING_COLUMN) != 0;
+ loaded = cursor.getInt(UIProvider.MESSAGE_LOADED_COLUMN) ==
+ EmailContent.Message.FLAG_LOADED_COMPLETE;
}
}
diff --git a/src/com/android/mail/providers/MessageInfo.java b/src/com/android/mail/providers/MessageInfo.java
index b197b7cd9..a0ebc34f8 100644
--- a/src/com/android/mail/providers/MessageInfo.java
+++ b/src/com/android/mail/providers/MessageInfo.java
@@ -24,6 +24,7 @@ import com.google.common.base.Objects;
public class MessageInfo implements Parcelable {
public static final String SENDER_LIST_TOKEN_ELIDED = " .. ";
+ public boolean loaded;
public boolean read;
public boolean starred;
public String sender;
@@ -34,8 +35,8 @@ public class MessageInfo implements Parcelable {
}
public MessageInfo(boolean isRead, boolean isStarred, String senderString, int p,
- String email) {
- set(isRead, isStarred, senderString, p, email);
+ String email, boolean loaded) {
+ set(isRead, isStarred, senderString, p, email, loaded);
}
private MessageInfo(Parcel in) {
@@ -44,6 +45,7 @@ public class MessageInfo implements Parcelable {
sender = in.readString();
priority = in.readInt();
senderEmail = in.readString();
+ loaded = (in.readInt() != 0);
}
@Override
@@ -58,14 +60,17 @@ public class MessageInfo implements Parcelable {
dest.writeString(sender);
dest.writeInt(priority);
dest.writeString(senderEmail);
+ dest.writeInt(loaded ? 1 : 0);
}
- public void set(boolean isRead, boolean isStarred, String senderString, int p, String email) {
+ public void set(boolean isRead, boolean isStarred, String senderString, int p,
+ String email, boolean isLoaded) {
read = isRead;
starred = isStarred;
sender = senderString;
priority = p;
senderEmail = email;
+ loaded = isLoaded;
}
public boolean markRead(boolean isRead) {
@@ -78,7 +83,7 @@ public class MessageInfo implements Parcelable {
@Override
public int hashCode() {
- return Objects.hashCode(read, starred, sender, senderEmail);
+ return Objects.hashCode(loaded, read, starred, sender, senderEmail, priority);
}
public static final Creator<MessageInfo> CREATOR = new Creator<MessageInfo>() {
@@ -106,6 +111,8 @@ public class MessageInfo implements Parcelable {
builder.append(senderEmail);
builder.append(", priority = ");
builder.append(priority);
+ builder.append(", loaded = ");
+ builder.append(loaded);
builder.append("]");
return builder.toString();
}
diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java
index e4bc961e5..50d1a028e 100644
--- a/src/com/android/mail/providers/UIProvider.java
+++ b/src/com/android/mail/providers/UIProvider.java
@@ -998,6 +998,7 @@ public class UIProvider {
ConversationColumns.ATTACHMENT_PREVIEW_URI1,
ConversationColumns.ATTACHMENT_PREVIEW_STATES,
ConversationColumns.ATTACHMENT_PREVIEWS_COUNT,
+ ConversationColumns.LOADED
};
/**
@@ -1145,6 +1146,11 @@ public class UIProvider {
public static final String PRIORITY = "priority";
/**
+ * This int column indicates whether the conversation has been loaded
+ */
+ public static final String LOADED = "loaded";
+
+ /**
* This int column indicates whether the conversation has been read
*/
public static final String READ = "read";
@@ -1538,7 +1544,8 @@ public class UIProvider {
MessageColumns.SPAM_WARNING_LEVEL,
MessageColumns.SPAM_WARNING_LINK_TYPE,
MessageColumns.VIA_DOMAIN,
- MessageColumns.IS_SENDING
+ MessageColumns.IS_SENDING,
+ MessageColumns.LOADED
};
/** Separates attachment info parts in strings in a message. */
@@ -1584,6 +1591,7 @@ public class UIProvider {
public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 32;
public static final int MESSAGE_VIA_DOMAIN_COLUMN = 33;
public static final int MESSAGE_IS_SENDING_COLUMN = 34;
+ public static final int MESSAGE_LOADED_COLUMN = 35;
public static final class CursorStatus {
// The cursor is actively loading more data
@@ -1733,6 +1741,11 @@ public class UIProvider {
public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
/**
+ * This boolean column indicates whether the message has been loaded
+ */
+ public static final String LOADED = "loaded";
+
+ /**
* This boolean column indicates whether the message has been read
*/
public static final String READ = "read";
diff --git a/src/com/android/mail/providers/protos/mock/MockUiProvider.java b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
index c908bb8c0..275dbc8d7 100644
--- a/src/com/android/mail/providers/protos/mock/MockUiProvider.java
+++ b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
@@ -193,6 +193,7 @@ public final class MockUiProvider extends ContentProvider {
conversationMap.put(ConversationColumns.NUM_MESSAGES, 1);
conversationMap.put(ConversationColumns.NUM_DRAFTS, 1);
conversationMap.put(ConversationColumns.SENDING_STATE, 1);
+ conversationMap.put(ConversationColumns.LOADED, 1);
conversationMap.put(ConversationColumns.READ, 0);
conversationMap.put(ConversationColumns.SEEN, 0);
conversationMap.put(ConversationColumns.STARRED, 0);
@@ -232,13 +233,13 @@ public final class MockUiProvider extends ContentProvider {
for (int i = 0; i < messageCount; i++) {
if (i % 2 == 0) {
info.addMessage(new MessageInfo(false, false,
- i + "Test <testsender@test.com>", -1, "testsender@test.com"));
+ i + "Test <testsender@test.com>", -1, "testsender@test.com", true));
} else if (i % 3 == 0) {
info.addMessage(new MessageInfo(true, false, i + "sender@test.com", -1,
- "sender@test.com"));
+ "sender@test.com", true));
} else {
info.addMessage(new MessageInfo(false, false, MessageInfo.SENDER_LIST_TOKEN_ELIDED,
- -1, null));
+ -1, null, true));
}
}
return info.toBlob();