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

Compression is now a string instead of a boolean (fixes #239)

This commit is contained in:
Lode Hoste 2015-03-16 07:59:12 +01:00
parent c128612e68
commit ca2ca8553a
6 changed files with 30 additions and 10 deletions

View file

@ -8,6 +8,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.support.v4.preference.PreferenceFragment;
import android.view.Menu;
@ -47,7 +48,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
private EditTextPreference mAddresses;
private CheckBoxPreference mCompression;
private ListPreference mCompression;
private CheckBoxPreference mIntroducer;
@ -78,7 +79,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
mName.setOnPreferenceChangeListener(this);
mAddresses = (EditTextPreference) findPreference("addresses");
mAddresses.setOnPreferenceChangeListener(this);
mCompression = (CheckBoxPreference) findPreference("compression");
mCompression = (ListPreference) findPreference("compression");
mCompression.setOnPreferenceChangeListener(this);
mIntroducer = (CheckBoxPreference) findPreference("introducer");
mIntroducer.setOnPreferenceChangeListener(this);
@ -97,7 +98,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
mDevice.Name = "";
mDevice.DeviceID = "";
mDevice.Addresses = "dynamic";
mDevice.Compression = true;
mDevice.Compression = "always";
((EditTextPreference) mDeviceId).setText(mDevice.DeviceID);
}
}
@ -148,7 +149,8 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
mName.setSummary(mDevice.Name);
mAddresses.setText(mDevice.Addresses);
mAddresses.setSummary(mDevice.Addresses);
mCompression.setChecked(mDevice.Compression);
mCompression.setValue(mDevice.Compression);
mCompression.setSummary(mDevice.Compression);
}
@Override
@ -209,7 +211,6 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
EditTextPreference pref = (EditTextPreference) preference;
pref.setSummary((String) o);
}
if (preference.equals(mDeviceId)) {
mDevice.DeviceID = (String) o;
deviceUpdated();
@ -223,7 +224,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
deviceUpdated();
return true;
} else if (preference.equals(mCompression)) {
mDevice.Compression = (Boolean) o;
mDevice.Compression = (String) o;
deviceUpdated();
return true;
} else if (preference.equals(mIntroducer)) {

View file

@ -66,7 +66,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String Addresses;
public String Name;
public String DeviceID;
public boolean Compression;
public String Compression;
public boolean Introducer;
}
@ -407,7 +407,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
n.Addresses = json.optJSONArray("Addresses").join(" ").replace("\"", "");
n.Name = json.getString("Name");
n.DeviceID = json.getString("DeviceID");
n.Compression = json.getBoolean("Compression");
n.Compression = json.getString("Compression");
n.Introducer = json.getBoolean("Introducer");
if (includeLocal || !mLocalDeviceId.equals(n.DeviceID)) {
ret.add(n);

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources translatable="false">
<string-array name="compress_values">
<item>never</item>
<item>metadata</item>
<item>always</item>
</string-array>
</resources>

View file

@ -146,6 +146,13 @@
<!-- Setting title -->
<string name="compression">Compression</string>
<!-- Strings representing compression options -->
<string-array name="compress_entries">
<item>Never</item>
<item>Metadata</item>
<item>Always</item>
</string-array>
<!-- Setting title -->
<string name="introducer">Introducer</string>

View file

@ -15,8 +15,10 @@
android:key="addresses"
android:title="@string/addresses" />
<CheckBoxPreference
<ListPreference
android:key="compression"
android:entries="@array/compress_entries"
android:entryValues="@array/compress_values"
android:title="@string/compression" />
<CheckBoxPreference

View file

@ -14,8 +14,10 @@
android:key="addresses"
android:title="@string/addresses" />
<CheckBoxPreference
<ListPreference
android:key="compression"
android:entries="@array/compress_entries"
android:entryValues="@array/compress_values"
android:title="@string/compression" />
<CheckBoxPreference