Merge "Fix IMAP attachments REDOWNLOADING." into jb-ub-mail-ur10
This commit is contained in:
commit
650f50023a
@ -3781,6 +3781,7 @@ public class EmailProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int uiUpdateAttachment(Uri uri, ContentValues uiValues) {
|
private int uiUpdateAttachment(Uri uri, ContentValues uiValues) {
|
||||||
|
int result = 0;
|
||||||
Integer stateValue = uiValues.getAsInteger(UIProvider.AttachmentColumns.STATE);
|
Integer stateValue = uiValues.getAsInteger(UIProvider.AttachmentColumns.STATE);
|
||||||
if (stateValue != null) {
|
if (stateValue != null) {
|
||||||
// This is a command from UIProvider
|
// This is a command from UIProvider
|
||||||
@ -3790,37 +3791,41 @@ public class EmailProvider extends ContentProvider {
|
|||||||
Attachment.restoreAttachmentWithId(context, attachmentId);
|
Attachment.restoreAttachmentWithId(context, attachmentId);
|
||||||
if (attachment == null) {
|
if (attachment == null) {
|
||||||
// Went away; ah, well...
|
// Went away; ah, well...
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
int state = stateValue.intValue();
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
switch (stateValue.intValue()) {
|
if (state == UIProvider.AttachmentState.NOT_SAVED
|
||||||
case UIProvider.AttachmentState.NOT_SAVED:
|
|| state == UIProvider.AttachmentState.REDOWNLOADING) {
|
||||||
// Set state, try to cancel request
|
// Set state, try to cancel request
|
||||||
values.put(AttachmentColumns.UI_STATE, stateValue);
|
values.put(AttachmentColumns.UI_STATE, UIProvider.AttachmentState.NOT_SAVED);
|
||||||
values.put(AttachmentColumns.FLAGS,
|
values.put(AttachmentColumns.FLAGS,
|
||||||
attachment.mFlags &= ~Attachment.FLAG_DOWNLOAD_USER_REQUEST);
|
attachment.mFlags &= ~Attachment.FLAG_DOWNLOAD_USER_REQUEST);
|
||||||
attachment.update(context, values);
|
attachment.update(context, values);
|
||||||
return 1;
|
result = 1;
|
||||||
case UIProvider.AttachmentState.DOWNLOADING:
|
}
|
||||||
// Set state and destination; request download
|
if (state == UIProvider.AttachmentState.DOWNLOADING
|
||||||
values.put(AttachmentColumns.UI_STATE, stateValue);
|
|| state == UIProvider.AttachmentState.REDOWNLOADING) {
|
||||||
Integer destinationValue =
|
// Set state and destination; request download
|
||||||
|
values.put(AttachmentColumns.UI_STATE, UIProvider.AttachmentState.DOWNLOADING);
|
||||||
|
Integer destinationValue =
|
||||||
uiValues.getAsInteger(UIProvider.AttachmentColumns.DESTINATION);
|
uiValues.getAsInteger(UIProvider.AttachmentColumns.DESTINATION);
|
||||||
values.put(AttachmentColumns.UI_DESTINATION,
|
values.put(AttachmentColumns.UI_DESTINATION,
|
||||||
destinationValue == null ? 0 : destinationValue);
|
destinationValue == null ? 0 : destinationValue);
|
||||||
values.put(AttachmentColumns.FLAGS,
|
values.put(AttachmentColumns.FLAGS,
|
||||||
attachment.mFlags | Attachment.FLAG_DOWNLOAD_USER_REQUEST);
|
attachment.mFlags | Attachment.FLAG_DOWNLOAD_USER_REQUEST);
|
||||||
attachment.update(context, values);
|
attachment.update(context, values);
|
||||||
return 1;
|
result = 1;
|
||||||
case UIProvider.AttachmentState.SAVED:
|
}
|
||||||
// If this is an inline attachment, notify message has changed
|
if (state == UIProvider.AttachmentState.SAVED) {
|
||||||
if (!TextUtils.isEmpty(attachment.mContentId)) {
|
// If this is an inline attachment, notify message has changed
|
||||||
notifyUI(UIPROVIDER_MESSAGE_NOTIFIER, attachment.mMessageKey);
|
if (!TextUtils.isEmpty(attachment.mContentId)) {
|
||||||
}
|
notifyUI(UIPROVIDER_MESSAGE_NOTIFIER, attachment.mMessageKey);
|
||||||
return 1;
|
}
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int uiUpdateFolder(final Context context, Uri uri, ContentValues uiValues) {
|
private int uiUpdateFolder(final Context context, Uri uri, ContentValues uiValues) {
|
||||||
|
@ -45,6 +45,7 @@ import com.android.emailcommon.service.EmailServiceStatus;
|
|||||||
import com.android.emailcommon.service.IEmailServiceCallback;
|
import com.android.emailcommon.service.IEmailServiceCallback;
|
||||||
import com.android.emailcommon.utility.AttachmentUtilities;
|
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||||
import com.android.emailcommon.utility.Utility;
|
import com.android.emailcommon.utility.Utility;
|
||||||
|
import com.android.mail.providers.UIProvider.AttachmentState;
|
||||||
import com.android.mail.utils.LogUtils;
|
import com.android.mail.utils.LogUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -621,6 +622,7 @@ public class AttachmentDownloadService extends Service implements Runnable {
|
|||||||
int flags =
|
int flags =
|
||||||
Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
|
Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
|
||||||
cv.put(Attachment.FLAGS, attachment.mFlags &= ~flags);
|
cv.put(Attachment.FLAGS, attachment.mFlags &= ~flags);
|
||||||
|
cv.put(Attachment.UI_STATE, AttachmentState.SAVED);
|
||||||
attachment.update(mContext, cv);
|
attachment.update(mContext, cv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user