mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
Time based attachment progress
This commit is contained in:
@@ -89,6 +89,7 @@ public class MessageHelper {
|
||||
|
||||
static final int SMALL_MESSAGE_SIZE = 32 * 1024; // bytes
|
||||
static final int DEFAULT_ATTACHMENT_DOWNLOAD_SIZE = 256 * 1024; // bytes
|
||||
static final long ATTACHMENT_PROGRESS_UPDATE = 1500L; // milliseconds
|
||||
|
||||
static void setSystemProperties(Context context) {
|
||||
System.setProperty("mail.mime.decodetext.strict", "false");
|
||||
@@ -1297,7 +1298,7 @@ public class MessageHelper {
|
||||
try (InputStream is = apart.part.getInputStream()) {
|
||||
long size = 0;
|
||||
long total = apart.part.getSize();
|
||||
int lastprogress = 0;
|
||||
long lastprogress = System.currentTimeMillis();
|
||||
|
||||
try (OutputStream os = new FileOutputStream(file)) {
|
||||
byte[] buffer = new byte[Helper.BUFFER_SIZE];
|
||||
@@ -1307,10 +1308,10 @@ public class MessageHelper {
|
||||
|
||||
// Update progress
|
||||
if (total > 0) {
|
||||
int progress = (int) (size * 100 / total / 20 * 20);
|
||||
if (progress != lastprogress) {
|
||||
lastprogress = progress;
|
||||
db.attachment().setProgress(local.id, progress);
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - lastprogress > ATTACHMENT_PROGRESS_UPDATE) {
|
||||
lastprogress = now;
|
||||
db.attachment().setProgress(local.id, (int) (size * 100 / total));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user