From 8443ba179af159faa1647bbc7e139dd1db4334f2 Mon Sep 17 00:00:00 2001 From: Lode Hoste Date: Mon, 9 Nov 2015 12:01:51 +0100 Subject: [PATCH] Correct handling of disconnected devices (fixes #473) --- .../java/com/nutomic/syncthingandroid/syncthing/RestApi.java | 2 ++ .../java/com/nutomic/syncthingandroid/util/DevicesAdapter.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index bdaed1f9..358aa544 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -119,6 +119,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, public String address; public String clientVersion; public int completion; + public boolean connected; } public static class Model { @@ -583,6 +584,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, c.address = conn.getString("address"); c.clientVersion = conn.getString("clientVersion"); c.completion = getDeviceCompletion(deviceId); + c.connected = conn.getBoolean("connected"); Connection prev = (mPreviousConnections.containsKey(deviceId)) ? mPreviousConnections.get(deviceId) diff --git a/src/main/java/com/nutomic/syncthingandroid/util/DevicesAdapter.java b/src/main/java/com/nutomic/syncthingandroid/util/DevicesAdapter.java index bb226896..4488f918 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/DevicesAdapter.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/DevicesAdapter.java @@ -55,7 +55,7 @@ public class DevicesAdapter extends ArrayAdapter name.setText(getItem(position).name); Resources r = getContext().getResources(); - if (conn != null) { + if (conn != null && conn.connected) { if (conn.completion == 100) { status.setText(r.getString(R.string.device_up_to_date)); status.setTextColor(r.getColor(R.color.text_green));