1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 04:41:16 +00:00

Use inSyncBytes instead of localBytes to calculate sync progress (fixes #93).

Also rename variable to clarify.
This commit is contained in:
Felix Ableitner 2014-10-12 13:46:26 +03:00
parent 77eaffa4b7
commit 8d781844a2
2 changed files with 12 additions and 14 deletions

View file

@ -548,8 +548,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
return; return;
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
Long difference = (now - mPreviousConnectionTime) / 1000; Long timeElapsed = (now - mPreviousConnectionTime) / 1000;
if (difference < 1) { if (timeElapsed < 1) {
listener.onReceiveConnections(mPreviousConnections); listener.onReceiveConnections(mPreviousConnections);
return; return;
} }
@ -573,12 +573,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
? mPreviousConnections.get(deviceId) ? mPreviousConnections.get(deviceId)
: new Connection(); : new Connection();
mPreviousConnectionTime = now; mPreviousConnectionTime = now;
if (difference != 0) { c.InBits = Math.max(0, 8 *
c.InBits = Math.max(0, 8 * (conn.getLong("InBytesTotal") - prev.InBytesTotal) / timeElapsed);
(conn.getLong("InBytesTotal") - prev.InBytesTotal) / difference); c.OutBits = Math.max(0, 8 *
c.OutBits = Math.max(0, 8 * (conn.getLong("OutBytesTotal") - prev.OutBytesTotal) / timeElapsed);
(conn.getLong("OutBytesTotal") - prev.OutBytesTotal) / difference);
}
connections.put(deviceId, c); connections.put(deviceId, c);

View file

@ -47,14 +47,14 @@ public class FoldersAdapter extends ArrayAdapter<RestApi.Folder>
state.setTextColor(getContext().getResources().getColor(R.color.text_green)); state.setTextColor(getContext().getResources().getColor(R.color.text_green));
directory.setText((folder.Path)); directory.setText((folder.Path));
if (model != null) { if (model != null) {
int percentage = (model.globalBytes != 0)
? (int) Math.floor(100 * model.inSyncBytes / model.globalBytes)
: 100;
state.setText(getContext().getString(R.string.folder_progress_format, model.state, state.setText(getContext().getString(R.string.folder_progress_format, model.state,
(model.globalBytes <= 0) percentage));
? 100
: (int) ((model.localBytes / (float) model.globalBytes) * 100)
));
items.setText(getContext() items.setText(getContext()
.getString(R.string.files, model.localFiles, model.globalFiles)); .getString(R.string.files, model.inSyncFiles, model.globalFiles));
size.setText(RestApi.readableFileSize(getContext(), model.localBytes) + " / " + size.setText(RestApi.readableFileSize(getContext(), model.inSyncBytes) + " / " +
RestApi.readableFileSize(getContext(), model.globalBytes)); RestApi.readableFileSize(getContext(), model.globalBytes));
if (folder.Invalid.equals("")) { if (folder.Invalid.equals("")) {
invalid.setText(model.invalid); invalid.setText(model.invalid);