Added download size

pull/215/head
M66B 7 months ago
parent 8c6e5e08be
commit e5c35b958d

@ -40,6 +40,7 @@ public class FragmentDialogDownloadAttachments extends FragmentDialogBase {
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Bundle args = getArguments();
long id = args.getLong("id");
long size = args.getLong("size");
long[] download = args.getLongArray("download");
Intent intent = args.getParcelable("intent");
@ -59,6 +60,7 @@ public class FragmentDialogDownloadAttachments extends FragmentDialogBase {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_download_attachments, null);
TextView tvRemark = dview.findViewById(R.id.tvRemark);
Button btnDownload = dview.findViewById(R.id.btnDownload);
TextView tvSize = dview.findViewById(R.id.tvSize);
ProgressBar pbDownloaded = dview.findViewById(R.id.pbDownloaded);
TextView tvRemaining = dview.findViewById(R.id.tvRemaining);
CheckBox cbAutoConfirm = dview.findViewById(R.id.cbAutoConfirm);
@ -151,6 +153,9 @@ public class FragmentDialogDownloadAttachments extends FragmentDialogBase {
}
});
tvSize.setText("~ " + Helper.humanReadableByteCount(size));
tvSize.setVisibility(size > 0 ? View.VISIBLE : View.GONE);
cbAutoConfirm.setChecked(attachments_auto_confirm);
cbAutoConfirm.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override

@ -4072,14 +4072,21 @@ public class FragmentMessages extends FragmentBase
long id = args.getLong("id");
List<Long> download = new ArrayList<>();
long size = 0;
DB db = DB.getInstance(context);
List<EntityAttachment> attachments = db.attachment().getAttachments(id);
if (attachments != null)
for (EntityAttachment attachment : attachments)
if (!attachment.available &&
attachment.subsequence == null &&
!attachment.isEncryption())
!attachment.isEncryption()) {
if (attachment.size != null)
size += attachment.size;
download.add(attachment.id);
}
args.putLong("size", size);
return download;
}

@ -44,6 +44,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" />
<TextView
android:id="@+id/tvSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="~123 KB"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintBottom_toBottomOf="@id/btnDownload"
app:layout_constraintStart_toEndOf="@id/btnDownload"
app:layout_constraintTop_toTopOf="@id/btnDownload" />
<ProgressBar
android:id="@+id/pbDownloaded"
style="@android:style/Widget.ProgressBar.Horizontal"

Loading…
Cancel
Save