mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
First pass at a "download the rest of this message" button
This commit is contained in:
parent
d0c24e23c7
commit
111e6f5109
@ -196,4 +196,8 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip" />
|
||||
<Button android:id="@+id/download_remainder"
|
||||
android:text="@string/message_view_download_remainder"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent" />
|
||||
</merge>
|
||||
|
@ -275,6 +275,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="message_view_fetching_attachment_toast">Fetching attachment.</string>
|
||||
<string name="message_view_no_viewer">Unable to find viewer for <xliff:g id="mimetype">%s</xliff:g>.</string>
|
||||
|
||||
|
||||
<string name="message_view_download_remainder">Download complete message</string>
|
||||
|
||||
<!-- NOTE: The following message refers to strings with id 'account_setup_incoming_save_all_headers_label' and 'account_setup_incoming_title' -->
|
||||
<string name="message_additional_headers_not_downloaded">Not all headers have been downloaded or saved. Select \"Save all headers locally\" in the account\'s incoming server settings to enable this for the future.</string>
|
||||
<string name="message_no_additional_headers_available">All headers have been downloaded, but there are no additional headers to show.</string>
|
||||
|
@ -103,6 +103,10 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
private View mAttachmentIcon;
|
||||
private View mDownloadingIcon;
|
||||
private View mShowPicturesSection;
|
||||
|
||||
private Button mDownloadRemainder;
|
||||
|
||||
|
||||
View next;
|
||||
View next_scrolling;
|
||||
View previous;
|
||||
@ -417,6 +421,13 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
null); // bottom
|
||||
}
|
||||
|
||||
if(mMessage.isSet(Flag.X_DOWNLOADED_FULL)) {
|
||||
mDownloadRemainder.setVisibility(View.GONE);
|
||||
} else {
|
||||
mDownloadRemainder.setEnabled(true);
|
||||
mDownloadRemainder.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@ -712,6 +723,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
mDownloadingIcon = findViewById(R.id.downloading);
|
||||
mShowPicturesSection = findViewById(R.id.show_pictures_section);
|
||||
|
||||
mDownloadRemainder = (Button)findViewById(R.id.download_remainder);
|
||||
|
||||
mFlagged = (CheckBox)findViewById(R.id.flagged);
|
||||
mFlagged.setOnClickListener(new OnClickListener()
|
||||
@ -774,6 +786,8 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
|
||||
setOnClickListener(R.id.show_pictures);
|
||||
|
||||
setOnClickListener(R.id.download_remainder);
|
||||
|
||||
setTitle("");
|
||||
|
||||
Intent intent = getIntent();
|
||||
@ -1494,6 +1508,25 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
return null;
|
||||
}
|
||||
|
||||
private void onDownloadRemainder()
|
||||
{
|
||||
if(mMessage.isSet(Flag.X_DOWNLOADED_FULL))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.v(K9.LOG_TAG, "downloading remainder");
|
||||
|
||||
|
||||
mDownloadRemainder.setEnabled(false);
|
||||
MessagingController.getInstance(getApplication()).loadMessageForViewRemote(
|
||||
mAccount,
|
||||
mMessageReference.folderName,
|
||||
mMessageReference.uid,
|
||||
mListener);
|
||||
|
||||
}
|
||||
|
||||
private void onDownloadAttachment(Attachment attachment)
|
||||
{
|
||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
|
||||
@ -1593,6 +1626,9 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
case R.id.header_container:
|
||||
onShowAdditionalHeaders();
|
||||
break;
|
||||
case R.id.download_remainder:
|
||||
onDownloadRemainder();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2995,7 +2995,7 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMessageForViewRemote(final Account account, final String folder,
|
||||
public void loadMessageForViewRemote(final Account account, final String folder,
|
||||
final String uid, final MessagingListener listener)
|
||||
{
|
||||
put("loadMessageForViewRemote", listener, new Runnable()
|
||||
@ -3042,6 +3042,7 @@ public class MessagingController implements Runnable
|
||||
|
||||
// Store the message locally and load the stored message into memory
|
||||
localFolder.appendMessages(new Message[] { remoteMessage });
|
||||
fp.add(FetchProfile.Item.ENVELOPE);
|
||||
message = localFolder.getMessage(uid);
|
||||
localFolder.fetch(new Message[] { message }, fp, null);
|
||||
|
||||
@ -3049,6 +3050,12 @@ public class MessagingController implements Runnable
|
||||
message.setFlag(Flag.X_DOWNLOADED_FULL, true);
|
||||
}
|
||||
|
||||
// now that we have the full message, refresh the headers
|
||||
for (MessagingListener l : getListeners(listener))
|
||||
{
|
||||
l.loadMessageForViewHeadersAvailable(account, folder, uid, message);
|
||||
}
|
||||
|
||||
for (MessagingListener l : getListeners(listener))
|
||||
{
|
||||
l.loadMessageForViewBodyAvailable(account, folder, uid, message);
|
||||
@ -3118,16 +3125,6 @@ public class MessagingController implements Runnable
|
||||
l.loadMessageForViewHeadersAvailable(account, folder, uid, message);
|
||||
}
|
||||
|
||||
if (!message.isSet(Flag.X_DOWNLOADED_FULL))
|
||||
{
|
||||
loadMessageForViewRemote(account, folder, uid, listener);
|
||||
if (!message.isSet(Flag.X_DOWNLOADED_PARTIAL))
|
||||
{
|
||||
localFolder.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FetchProfile fp = new FetchProfile();
|
||||
fp.add(FetchProfile.Item.ENVELOPE);
|
||||
fp.add(FetchProfile.Item.BODY);
|
||||
|
Loading…
Reference in New Issue
Block a user