mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Compression is now a string instead of a boolean (fixes #239)
This commit is contained in:
parent
c128612e68
commit
ca2ca8553a
6 changed files with 30 additions and 10 deletions
|
@ -8,6 +8,7 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.support.v4.preference.PreferenceFragment;
|
import android.support.v4.preference.PreferenceFragment;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -47,7 +48,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
|
||||||
|
|
||||||
private EditTextPreference mAddresses;
|
private EditTextPreference mAddresses;
|
||||||
|
|
||||||
private CheckBoxPreference mCompression;
|
private ListPreference mCompression;
|
||||||
|
|
||||||
private CheckBoxPreference mIntroducer;
|
private CheckBoxPreference mIntroducer;
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ public class DeviceSettingsFragment 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 = (ListPreference) findPreference("compression");
|
||||||
mCompression.setOnPreferenceChangeListener(this);
|
mCompression.setOnPreferenceChangeListener(this);
|
||||||
mIntroducer = (CheckBoxPreference) findPreference("introducer");
|
mIntroducer = (CheckBoxPreference) findPreference("introducer");
|
||||||
mIntroducer.setOnPreferenceChangeListener(this);
|
mIntroducer.setOnPreferenceChangeListener(this);
|
||||||
|
@ -97,7 +98,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
|
||||||
mDevice.Name = "";
|
mDevice.Name = "";
|
||||||
mDevice.DeviceID = "";
|
mDevice.DeviceID = "";
|
||||||
mDevice.Addresses = "dynamic";
|
mDevice.Addresses = "dynamic";
|
||||||
mDevice.Compression = true;
|
mDevice.Compression = "always";
|
||||||
((EditTextPreference) mDeviceId).setText(mDevice.DeviceID);
|
((EditTextPreference) mDeviceId).setText(mDevice.DeviceID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,8 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
|
||||||
mName.setSummary(mDevice.Name);
|
mName.setSummary(mDevice.Name);
|
||||||
mAddresses.setText(mDevice.Addresses);
|
mAddresses.setText(mDevice.Addresses);
|
||||||
mAddresses.setSummary(mDevice.Addresses);
|
mAddresses.setSummary(mDevice.Addresses);
|
||||||
mCompression.setChecked(mDevice.Compression);
|
mCompression.setValue(mDevice.Compression);
|
||||||
|
mCompression.setSummary(mDevice.Compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,7 +211,6 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
|
||||||
EditTextPreference pref = (EditTextPreference) preference;
|
EditTextPreference pref = (EditTextPreference) preference;
|
||||||
pref.setSummary((String) o);
|
pref.setSummary((String) o);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preference.equals(mDeviceId)) {
|
if (preference.equals(mDeviceId)) {
|
||||||
mDevice.DeviceID = (String) o;
|
mDevice.DeviceID = (String) o;
|
||||||
deviceUpdated();
|
deviceUpdated();
|
||||||
|
@ -223,7 +224,7 @@ public class DeviceSettingsFragment extends PreferenceFragment implements
|
||||||
deviceUpdated();
|
deviceUpdated();
|
||||||
return true;
|
return true;
|
||||||
} else if (preference.equals(mCompression)) {
|
} else if (preference.equals(mCompression)) {
|
||||||
mDevice.Compression = (Boolean) o;
|
mDevice.Compression = (String) o;
|
||||||
deviceUpdated();
|
deviceUpdated();
|
||||||
return true;
|
return true;
|
||||||
} else if (preference.equals(mIntroducer)) {
|
} else if (preference.equals(mIntroducer)) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
public String Addresses;
|
public String Addresses;
|
||||||
public String Name;
|
public String Name;
|
||||||
public String DeviceID;
|
public String DeviceID;
|
||||||
public boolean Compression;
|
public String Compression;
|
||||||
public boolean Introducer;
|
public boolean Introducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
n.Addresses = json.optJSONArray("Addresses").join(" ").replace("\"", "");
|
n.Addresses = json.optJSONArray("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.getString("Compression");
|
||||||
n.Introducer = json.getBoolean("Introducer");
|
n.Introducer = json.getBoolean("Introducer");
|
||||||
if (includeLocal || !mLocalDeviceId.equals(n.DeviceID)) {
|
if (includeLocal || !mLocalDeviceId.equals(n.DeviceID)) {
|
||||||
ret.add(n);
|
ret.add(n);
|
||||||
|
|
8
src/main/res/values/arrays.xml
Normal file
8
src/main/res/values/arrays.xml
Normal 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>
|
|
@ -146,6 +146,13 @@
|
||||||
<!-- Setting title -->
|
<!-- Setting title -->
|
||||||
<string name="compression">Compression</string>
|
<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 -->
|
<!-- Setting title -->
|
||||||
<string name="introducer">Introducer</string>
|
<string name="introducer">Introducer</string>
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
android:key="addresses"
|
android:key="addresses"
|
||||||
android:title="@string/addresses" />
|
android:title="@string/addresses" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<ListPreference
|
||||||
android:key="compression"
|
android:key="compression"
|
||||||
|
android:entries="@array/compress_entries"
|
||||||
|
android:entryValues="@array/compress_values"
|
||||||
android:title="@string/compression" />
|
android:title="@string/compression" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
android:key="addresses"
|
android:key="addresses"
|
||||||
android:title="@string/addresses" />
|
android:title="@string/addresses" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<ListPreference
|
||||||
android:key="compression"
|
android:key="compression"
|
||||||
|
android:entries="@array/compress_entries"
|
||||||
|
android:entryValues="@array/compress_values"
|
||||||
android:title="@string/compression" />
|
android:title="@string/compression" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
Loading…
Reference in a new issue