1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 04:41:16 +00:00

Fixed changing Syncthing settings

This commit is contained in:
Felix Ableitner 2016-10-31 03:36:51 +09:00
parent a263b0c8e2
commit dcd800dc9e

View file

@ -26,6 +26,7 @@ import com.nutomic.syncthingandroid.views.WifiSsidPreference;
import com.nutomic.syncthingandroid.syncthing.RestApi; import com.nutomic.syncthingandroid.syncthing.RestApi;
import com.nutomic.syncthingandroid.syncthing.SyncthingService; import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import java.security.InvalidParameterException;
import java.util.List; import java.util.List;
import eu.chainfire.libsuperuser.Shell; import eu.chainfire.libsuperuser.Shell;
@ -196,28 +197,35 @@ public class SettingsFragment extends PreferenceFragment
} }
public boolean onSyncthingPreferenceChange(Preference preference, Object o) { public boolean onSyncthingPreferenceChange(Preference preference, Object o) {
Device localDevice = mApi.getLocalDevice();
localDevice.name = mDeviceName.getText();
mApi.editDevice(localDevice);
Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings(); Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings();
switch (preference.getKey()) {
mOptions.listenAddresses = Iterables.toArray( case "deviceName":
splitter.split(mListenAddresses.getText()), String.class); Device localDevice = mApi.getLocalDevice();
mOptions.maxRecvKbps = Integer.valueOf(mMaxRecvKbps.getText()); localDevice.name = (String) o;
mOptions.maxRecvKbps = Integer.valueOf(mMaxSendKbps.getText()); mApi.editDevice(localDevice);
mOptions.natEnabled = mNatEnabled.isChecked(); break;
mOptions.localAnnounceEnabled = mLocalAnnounceEnabled.isChecked(); case "listenAddresses":
mOptions.globalAnnounceEnabled = mGlobalAnnounceEnabled.isChecked(); mOptions.listenAddresses = Iterables.toArray(splitter.split((String) o), String.class);
mOptions.relaysEnabled = mRelaysEnabled.isChecked(); break;
mOptions.globalAnnounceServers = Iterables.toArray( case "maxRecvKbps": mOptions.maxRecvKbps = (int) o; break;
splitter.split(mGlobalAnnounceServers.getText()), String.class); case "maxSendKbps": mOptions.maxRecvKbps = (int) o; break;
mGui.address = mAddress.getText(); case "natEnabled": mOptions.natEnabled = (boolean) o; break;
mGui.user = mUser.getText(); case "localAnnounceEnabled": mOptions.localAnnounceEnabled = (boolean) o; break;
mGui.password = mPassword.getText(); case "globalAnnounceEnabled": mOptions.globalAnnounceEnabled = (boolean) o; break;
mOptions.urAccepted = (mUrAccepted.isChecked()) case "relaysEnabled": mOptions.relaysEnabled = (boolean) o; break;
case "globalAnnounceServers":
mOptions.globalAnnounceServers = Iterables.toArray(splitter.split((String) o), String.class);
break;
case "address": mGui.address = (String) o; break;
case "user": mGui.user = (String) o; break;
case "password": mGui.password = (String) o; break;
case "urAccepted":
mOptions.urAccepted = ((boolean) o)
? Options.USAGE_REPORTING_ACCEPTED ? Options.USAGE_REPORTING_ACCEPTED
: Options.USAGE_REPORTING_DENIED; : Options.USAGE_REPORTING_DENIED;
break;
default: throw new InvalidParameterException();
}
mApi.editSettings(mGui, mOptions, getActivity()); mApi.editSettings(mGui, mOptions, getActivity());
return true; return true;