From 80d24c88434772ae0e4dc06dff03a136cecc16cf Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sun, 20 Jan 2019 22:34:51 +0000 Subject: [PATCH] Device overview: Show status "Syncing" in case of data throughput (fixes #240) (#260) * Device overview: Show status "Syncing" in case of data throughput (fixes #240) If (incoming_bits_per_second + outgoing_bits_per_second) top the threshold, we'll assume syncing state for the device reporting that data throughput. * Imported de translation --- .../views/DevicesAdapter.java | 22 +++++++++++++++++-- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/views/DevicesAdapter.java b/app/src/main/java/com/nutomic/syncthingandroid/views/DevicesAdapter.java index 2d61ee3b..5662d3b1 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/views/DevicesAdapter.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/views/DevicesAdapter.java @@ -26,6 +26,12 @@ public class DevicesAdapter extends ArrayAdapter { private static final String TAG = "DevicesAdapter"; + /** + * If (incoming_bits_per_second + outgoing_bits_per_second) top the threshold, + * we'll assume syncing state for the device reporting that data throughput. + */ + private static final long ACTIVE_SYNC_BITS_PER_SECOND_THRESHOLD = 50 * 1024 * 8; + private Connections mConnections; public DevicesAdapter(Context context) { @@ -80,8 +86,20 @@ public class DevicesAdapter extends ArrayAdapter { rateInOutView.setVisibility(VISIBLE); status.setVisibility(VISIBLE); if (conn.completion == 100) { - status.setText(r.getString(R.string.device_up_to_date)); - status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green)); + /** + * UI polish - We distinguish the following cases: + * a) conn.completion == 100 because of the model init assignment, data transmission ongoing. + * b) conn.completion == 100 because of a finished sync, no data transmission. + */ + if ((conn.inBits + conn.outBits) >= ACTIVE_SYNC_BITS_PER_SECOND_THRESHOLD) { + // case a) device_syncing + status.setText(r.getString(R.string.state_syncing_general)); + status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_blue)); + } else { + // case b) device_up_to_date + status.setText(r.getString(R.string.device_up_to_date)); + status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green)); + } } else { status.setText(r.getString(R.string.device_syncing, conn.completion)); status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_blue)); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0db5ce3c..ec058cb0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -778,6 +778,7 @@ Bitte melden Sie auftretende Probleme via GitHub. Untätig Scannen + Synchronisiere Synchronisiere (%1$d%%) Fehler Unbekannt diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e3bc8eb1..30138f01 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -794,6 +794,7 @@ Please report any problems you encounter via Github. Idle Scanning + Syncing Syncing (%1$d%%) Error Unknown