Skip to content

Commit

Permalink
Device overview: Show status "Syncing" in case of data throughput (fixes
Browse files Browse the repository at this point in the history
 #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
  • Loading branch information
Catfriend1 authored Jan 20, 2019
1 parent e479bf6 commit 80d24c8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class DevicesAdapter extends ArrayAdapter<Device> {

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) {
Expand Down Expand Up @@ -80,8 +86,20 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
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));
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
<!-- Possible folder states -->
<string name="state_idle">Untätig</string>
<string name="state_scanning">Scannen</string>
<string name="state_syncing_general">Synchronisiere</string>
<string name="state_syncing">Synchronisiere (%1$d%%)</string>
<string name="state_error">Fehler</string>
<string name="state_unknown">Unbekannt</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ Please report any problems you encounter via Github.</string>
<!-- Possible folder states -->
<string name="state_idle">Idle</string>
<string name="state_scanning">Scanning</string>
<string name="state_syncing_general">Syncing</string>
<string name="state_syncing">Syncing (%1$d%%)</string>
<string name="state_error">Error</string>
<string name="state_unknown">Unknown</string>
Expand Down

0 comments on commit 80d24c8

Please sign in to comment.