1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +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.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.support.v4.preference.PreferenceFragment;
@ -46,6 +47,8 @@ public class NodeSettingsFragment extends PreferenceFragment implements
private EditTextPreference mAddresses;
private CheckBoxPreference mCompression;
private Preference mVersion;
private Preference mCurrentAddress;
@ -73,6 +76,8 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mName.setOnPreferenceChangeListener(this);
mAddresses = (EditTextPreference) findPreference("addresses");
mAddresses.setOnPreferenceChangeListener(this);
mCompression = (CheckBoxPreference) findPreference("compression");
mCompression.setOnPreferenceChangeListener(this);
if (!mIsCreate) {
mVersion = findPreference("version");
mVersion.setSummary("?");
@ -102,6 +107,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mNode.Name = "";
mNode.NodeID = "";
mNode.Addresses = "dynamic";
mNode.Compression = true;
((EditTextPreference) mNodeId).setText(mNode.NodeID);
} else {
getActivity().setTitle(R.string.edit_node);
@ -122,6 +128,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mName.setSummary(mNode.Name);
mAddresses.setText(mNode.Addresses);
mAddresses.setSummary(mNode.Addresses);
mCompression.setChecked(mNode.Compression);
}
@Override
@ -196,6 +203,10 @@ public class NodeSettingsFragment extends PreferenceFragment implements
mNode.Addresses = (String) o;
nodeUpdated();
return true;
} else if (preference.equals(mCompression)) {
mNode.Compression = (Boolean) o;
nodeUpdated();
return true;
}
return false;
}

View file

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

View file

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

View file

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

View file

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