Skip to content

Commit

Permalink
show xfer speed + ETA
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Jan 23, 2022
1 parent 9da219a commit 2b81f26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/me/ocv/partyup/XferActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class XferActivity extends AppCompatActivity {
String base_url;
boolean upping;
String the_msg;
long bytes_done, bytes_total;
long bytes_done, bytes_total, t0;
F[] files;

@Override
Expand Down Expand Up @@ -263,6 +263,7 @@ private void do_up2() {
if (!base_url.endsWith("/"))
base_url += "/";

t0 = System.currentTimeMillis();
tshow_msg("Sending to " + base_url + " ...");

int nfiles = files == null ? 1 : files.length;
Expand Down Expand Up @@ -347,14 +348,19 @@ private boolean do_fileput(HttpURLConnection conn, int nfile) throws Exception {

tv.post(() -> {
double perc = ((double) bytes_done * 1000) / bytes_total;
tv.setText(format("Sending %d of %d to %s ...\n\n%s\n\nbytes done: %,d\nbytes left: %,d\nprogress: %.2f %%",
long td = 1 + System.currentTimeMillis() - t0;
double spd = bytes_done / (td / 1000.0);
long left = (long)((bytes_total - bytes_done) / spd);
tv.setText(format("Sending to %s ...\n\nFile %d of %d:\n%s\n\nbytes done: %,d\nbytes left: %,d\nspeed: %.2f MiB/s\nprogress: %.2f %%\nETA: %d sec",
base_url,
nfile + 1,
files.length,
base_url,
f.desc,
bytes_done,
bytes_total - bytes_done,
perc / 10
spd / 1024 / 1024,
perc / 10,
left
));
pb.setProgress((int) Math.round(perc));
});
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/10600.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
• new: upload multiple files
• new: show transfer speed and ETA
• new: choose what happens when upload succeeds
• new: add http:// to the server URL if missing
• bugfix: sharing from some apps on android 10+ could crash this app

0 comments on commit 2b81f26

Please sign in to comment.