Added introducer option.

This commit is contained in:
Felix Ableitner 2014-10-10 13:42:53 +03:00
parent 1b34bd9d48
commit 48188b845c
5 changed files with 23 additions and 5 deletions

View File

@ -49,6 +49,8 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
private CheckBoxPreference mCompression;
private CheckBoxPreference mIntroducer;
private Preference mVersion;
private Preference mCurrentAddress;
@ -78,6 +80,8 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
mAddresses.setOnPreferenceChangeListener(this);
mCompression = (CheckBoxPreference) findPreference("compression");
mCompression.setOnPreferenceChangeListener(this);
mIntroducer = (CheckBoxPreference) findPreference("introducer");
mIntroducer.setOnPreferenceChangeListener(this);
if (!mIsCreate) {
mVersion = findPreference("version");
mVersion.setSummary("?");
@ -206,6 +210,10 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
mDevice.Compression = (Boolean) o;
deviceUpdated();
return true;
} else if (preference.equals(mIntroducer)) {
mDevice.Introducer = (Boolean) o;
deviceUpdated();
return true;
}
return false;
}

View File

@ -65,6 +65,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String Name;
public String DeviceID;
public boolean Compression;
public boolean Introducer;
}
public static class SystemInfo {
@ -440,14 +441,11 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
for (int i = 0; i < devices.length(); i++) {
JSONObject json = devices.getJSONObject(i);
Device n = new Device();
// TODO
//n.Addresses = json.optJSONArray("Addresses").join(" ").replace("\"", "");
if (!json.isNull("Addresses")) {
n.Addresses = json.getJSONArray("Addresses").join(" ").replace("\"", "");
}
n.Addresses = json.optJSONArray("Addresses").join(" ").replace("\"", "");
n.Name = json.getString("Name");
n.DeviceID = json.getString("DeviceID");
n.Compression = json.getBoolean("Compression");
n.Introducer = json.getBoolean("Introducer");
if (!n.DeviceID.equals(mLocalDeviceId)) {
ret.add(n);
}
@ -712,6 +710,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
n.put("Name", device.Name);
n.put("Addresses", listToJson(device.Addresses.split(" ")));
n.put("Compression", device.Compression);
n.put("Introducer", device.Introducer);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);

View File

@ -145,6 +145,9 @@
<!-- Setting title -->
<string name="compression">Compression</string>
<!-- Setting title -->
<string name="introducer">Introducer</string>
<!-- ActionBar item -->
<string name="delete_device">Delete Device</string>

View File

@ -19,4 +19,8 @@
android:key="compression"
android:title="@string/compression" />
<CheckBoxPreference
android:key="introducer"
android:title="@string/introducer" />
</PreferenceScreen>

View File

@ -18,6 +18,10 @@
android:key="compression"
android:title="@string/compression" />
<CheckBoxPreference
android:key="introducer"
android:title="@string/introducer" />
<Preference
android:key="version"
android:title="@string/syncthing_version_title"