1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

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

View file

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

View file

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

View file

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

View file

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