1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-29 15:51:17 +00:00

Added compression preference to node settings.

This commit is contained in:
Felix Ableitner 2014-09-24 18:51:14 +03:00
parent 875b6b8c8d
commit ccfd28abbc
5 changed files with 25 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import android.content.ActivityNotFoundException;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.v4.preference.PreferenceFragment; import android.support.v4.preference.PreferenceFragment;
@ -46,6 +47,8 @@ public class NodeSettingsFragment extends PreferenceFragment implements
private EditTextPreference mAddresses; private EditTextPreference mAddresses;
private CheckBoxPreference mCompression;
private Preference mVersion; private Preference mVersion;
private Preference mCurrentAddress; private Preference mCurrentAddress;
@ -73,6 +76,8 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mName.setOnPreferenceChangeListener(this); mName.setOnPreferenceChangeListener(this);
mAddresses = (EditTextPreference) findPreference("addresses"); mAddresses = (EditTextPreference) findPreference("addresses");
mAddresses.setOnPreferenceChangeListener(this); mAddresses.setOnPreferenceChangeListener(this);
mCompression = (CheckBoxPreference) findPreference("compression");
mCompression.setOnPreferenceChangeListener(this);
if (!mIsCreate) { if (!mIsCreate) {
mVersion = findPreference("version"); mVersion = findPreference("version");
mVersion.setSummary("?"); mVersion.setSummary("?");
@ -102,6 +107,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mNode.Name = ""; mNode.Name = "";
mNode.NodeID = ""; mNode.NodeID = "";
mNode.Addresses = "dynamic"; mNode.Addresses = "dynamic";
mNode.Compression = true;
((EditTextPreference) mNodeId).setText(mNode.NodeID); ((EditTextPreference) mNodeId).setText(mNode.NodeID);
} else { } else {
getActivity().setTitle(R.string.edit_node); getActivity().setTitle(R.string.edit_node);
@ -122,6 +128,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mName.setSummary(mNode.Name); mName.setSummary(mNode.Name);
mAddresses.setText(mNode.Addresses); mAddresses.setText(mNode.Addresses);
mAddresses.setSummary(mNode.Addresses); mAddresses.setSummary(mNode.Addresses);
mCompression.setChecked(mNode.Compression);
} }
@Override @Override
@ -196,6 +203,10 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mNode.Addresses = (String) o; mNode.Addresses = (String) o;
nodeUpdated(); nodeUpdated();
return true; return true;
} else if (preference.equals(mCompression)) {
mNode.Compression = (Boolean) o;
nodeUpdated();
return true;
} }
return false; return false;
} }

View file

@ -65,6 +65,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String Addresses; public String Addresses;
public String Name; public String Name;
public String NodeID; public String NodeID;
public boolean Compression;
} }
public static class SystemInfo { public static class SystemInfo {
@ -446,6 +447,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
} }
n.Name = json.getString("Name"); n.Name = json.getString("Name");
n.NodeID = json.getString("NodeID"); n.NodeID = json.getString("NodeID");
n.Compression = json.getBoolean("Compression");
if (!n.NodeID.equals(mLocalNodeId)) { if (!n.NodeID.equals(mLocalNodeId)) {
ret.add(n); ret.add(n);
} }
@ -709,6 +711,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
n.put("NodeID", node.NodeID); n.put("NodeID", node.NodeID);
n.put("Name", node.Name); n.put("Name", node.Name);
n.put("Addresses", listToJson(node.Addresses.split(" "))); n.put("Addresses", listToJson(node.Addresses.split(" ")));
n.put("Compression", node.Compression);
requireRestart(activity); requireRestart(activity);
} catch (JSONException e) { } catch (JSONException e) {
Log.w(TAG, "Failed to read nodes", e); Log.w(TAG, "Failed to read nodes", e);

View file

@ -141,6 +141,9 @@
<string name="current_address">Current Address</string> <string name="current_address">Current Address</string>
<!-- Setting title --> <!-- Setting title -->
<string name="compression">Compression</string>
<!-- ActionBar item -->
<string name="delete_node">Delete Node</string> <string name="delete_node">Delete Node</string>
<!-- Title for NodeSettingsFragment in create mode --> <!-- Title for NodeSettingsFragment in create mode -->

View file

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

View file

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