mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
Fixed announce server status display (fixes #189).
This commit is contained in:
parent
1506541796
commit
535b1f6108
2 changed files with 16 additions and 5 deletions
|
@ -141,11 +141,12 @@ public class LocalDeviceInfoFragment extends Fragment
|
|||
});
|
||||
mCpuUsage.setText(new DecimalFormat("0.00").format(info.cpuPercent) + "%");
|
||||
mRamUsage.setText(RestApi.readableFileSize(mActivity, info.sys));
|
||||
if (info.extAnnounceOK) {
|
||||
mAnnounceServer.setText("Online");
|
||||
if (info.extAnnounceConnected == info.extAnnounceTotal) {
|
||||
mAnnounceServer.setText(android.R.string.ok);
|
||||
mAnnounceServer.setTextColor(getResources().getColor(R.color.text_green));
|
||||
} else {
|
||||
mAnnounceServer.setText("Offline");
|
||||
mAnnounceServer.setText(Integer.toString(info.extAnnounceConnected) + "/" +
|
||||
Integer.toString(info.extAnnounceTotal));
|
||||
mAnnounceServer.setTextColor(getResources().getColor(R.color.text_red));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.security.InvalidParameterException;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -73,7 +74,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
public static class SystemInfo {
|
||||
public long alloc;
|
||||
public double cpuPercent;
|
||||
public boolean extAnnounceOK;
|
||||
public int extAnnounceConnected; // Number of connected announce servers.
|
||||
public int extAnnounceTotal; // Total number of configured announce servers.
|
||||
public int goroutines;
|
||||
public String myID;
|
||||
public long sys;
|
||||
|
@ -427,7 +429,15 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
SystemInfo si = new SystemInfo();
|
||||
si.alloc = system.getLong("alloc");
|
||||
si.cpuPercent = system.getDouble("cpuPercent");
|
||||
si.extAnnounceOK = system.optBoolean("extAnnounceOK", false);
|
||||
JSONObject announce = system.getJSONObject("extAnnounceOK");
|
||||
si.extAnnounceConnected = 0;
|
||||
si.extAnnounceTotal = announce.length();
|
||||
for (Iterator<String> it = announce.keys(); it.hasNext(); ) {
|
||||
String key = it.next();
|
||||
if (announce.getBoolean(key)) {
|
||||
si.extAnnounceConnected++;
|
||||
}
|
||||
}
|
||||
si.goroutines = system.getInt("goroutines");
|
||||
si.myID = system.getString("myID");
|
||||
si.sys = system.getLong("sys");
|
||||
|
|
Loading…
Reference in a new issue