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

Use Gson to (de-)serialize config, instead of working on raw JSON

This commit is contained in:
Felix Ableitner 2016-10-19 21:34:16 +09:00
parent fa2879c9f0
commit 87f36fcf13
44 changed files with 651 additions and 907 deletions

View file

@ -29,6 +29,7 @@ import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.fragments.DeviceListFragment;
import com.nutomic.syncthingandroid.fragments.DrawerFragment;
import com.nutomic.syncthingandroid.fragments.FolderListFragment;
import com.nutomic.syncthingandroid.model.Options;
import com.nutomic.syncthingandroid.syncthing.RestApi;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
@ -87,7 +88,7 @@ public class MainActivity extends SyncthingActivity
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mDrawerFragment.requestGuiUpdate();
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
getApi().getUsageReportAccepted() == RestApi.USAGE_REPORTING_UNDECIDED) {
getApi().getOptions().getUsageReportValue() == Options.USAGE_REPORTING_UNDECIDED) {
showUsageReportingDialog();
}
break;
@ -390,21 +391,20 @@ public class MainActivity extends SyncthingActivity
*/
private void showUsageReportingDialog() {
final DialogInterface.OnClickListener listener = (dialog, which) -> {
Options options = getApi().getOptions();
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_ACCEPTED,
MainActivity.this);
options.urAccepted = Options.USAGE_REPORTING_ACCEPTED;
break;
case DialogInterface.BUTTON_NEGATIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_DENIED,
MainActivity.this);
options.urAccepted = Options.USAGE_REPORTING_DENIED;
break;
case DialogInterface.BUTTON_NEUTRAL:
Uri uri = Uri.parse("https://data.syncthing.net");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
}
getApi().editOptions(options, this);
};
getApi().getUsageReport(report -> {

View file

@ -30,7 +30,7 @@ public class RestartActivity extends SyncthingActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.restart_title)
.setPositiveButton(R.string.restart_now, (dialogInterface, i) -> {
getService().getApi().updateConfig();
getService().getApi().restart();
finish();
})
.setNegativeButton(R.string.restart_later, (dialogInterface, i) -> {

View file

@ -19,6 +19,8 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.nutomic.syncthingandroid.R;
@ -159,7 +161,7 @@ public class DeviceFragment extends Fragment implements
if (mIsCreateMode) {
if (savedInstanceState != null) {
mDevice = (Device) savedInstanceState.getSerializable("device");
mDevice = new Gson().fromJson(savedInstanceState.getString("device"), Device.class);
}
if (mDevice == null) {
initDevice();
@ -192,7 +194,7 @@ public class DeviceFragment extends Fragment implements
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable("device", mDevice);
outState.putString("device", new Gson().toJson(mDevice));
}
@Nullable
@ -322,7 +324,7 @@ public class DeviceFragment extends Fragment implements
.show();
return true;
}
mSyncthingService.getApi().editDevice(mDevice, getActivity(), this);
mSyncthingService.getApi().addDevice(mDevice, this);
getActivity().finish();
return true;
case R.id.share_device_id:
@ -331,7 +333,8 @@ public class DeviceFragment extends Fragment implements
case R.id.remove:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.remove_device_confirm)
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> mSyncthingService.getApi().deleteDevice(mDevice, getActivity()))
.setPositiveButton(android.R.string.yes, (dialogInterface, i) ->
mSyncthingService.getApi().removeDevice(mDevice.deviceID))
.setNegativeButton(android.R.string.no, null)
.show();
return true;
@ -391,7 +394,7 @@ public class DeviceFragment extends Fragment implements
*/
private void updateDevice() {
if (!mIsCreateMode && mDeviceNeedsToUpdate && mDevice != null) {
mSyncthingService.getApi().editDevice(mDevice, getActivity(), this);
mSyncthingService.getApi().editDevice(mDevice);
}
}

View file

@ -66,18 +66,11 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setHasOptionsMenu(true);
setEmptyText(getString(R.string.devices_list_empty));
getListView().setOnItemClickListener(this);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
updateList();
setHasOptionsMenu(true);
}
/**
* Refreshes ListView by updating devices and info.
*

View file

@ -25,6 +25,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.FolderPickerActivity;
import com.nutomic.syncthingandroid.activities.SettingsActivity;
@ -156,7 +157,7 @@ public class FolderFragment extends Fragment
if (mIsCreateMode) {
if (savedInstanceState != null) {
mFolder = (Folder) savedInstanceState.getSerializable("folder");
mFolder = new Gson().fromJson(savedInstanceState.getString("folder"), Folder.class);
}
if (mFolder == null) {
initFolder();
@ -189,7 +190,7 @@ public class FolderFragment extends Fragment
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable("folder", mFolder);
outState.putString("folder", new Gson().toJson(mFolder));
}
@Override
@ -327,13 +328,14 @@ public class FolderFragment extends Fragment
.show();
return true;
}
mSyncthingService.getApi().editFolder(mFolder, true, getActivity());
mSyncthingService.getApi().addFolder(mFolder);
getActivity().finish();
return true;
case R.id.remove:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.remove_folder_confirm)
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> mSyncthingService.getApi().deleteFolder(mFolder, getActivity()))
.setPositiveButton(android.R.string.yes, (dialogInterface, i) ->
mSyncthingService.getApi().removeFolder(mFolder.id))
.setNegativeButton(android.R.string.no, null)
.show();
return true;
@ -403,7 +405,7 @@ public class FolderFragment extends Fragment
private void updateFolder() {
if (!mIsCreateMode) {
mSyncthingService.getApi().editFolder(mFolder, false, getActivity());
mSyncthingService.getApi().editFolder(mFolder);
}
}
}

View file

@ -74,19 +74,12 @@ public class FolderListFragment extends ListFragment implements SyncthingService
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setHasOptionsMenu(true);
setEmptyText(getString(R.string.folder_list_empty));
getListView().setOnItemClickListener(this);
getListView().setOnItemLongClickListener(this);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
updateList();
setHasOptionsMenu(true);
}
/**
* Refreshes ListView by updating folders and info.
*

View file

@ -8,22 +8,25 @@ import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.support.v4.app.NavUtils;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.SyncthingActivity;
import com.nutomic.syncthingandroid.model.Config;
import com.nutomic.syncthingandroid.model.Device;
import com.nutomic.syncthingandroid.model.Options;
import com.nutomic.syncthingandroid.views.WifiSsidPreference;
import com.nutomic.syncthingandroid.syncthing.RestApi;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import java.util.List;
import java.util.TreeSet;
import eu.chainfire.libsuperuser.Shell;
@ -33,89 +36,39 @@ public class SettingsFragment extends PreferenceFragment
Preference.OnPreferenceClickListener {
private static final String TAG = "SettingsFragment";
private static final String SYNCTHING_OPTIONS_KEY = "syncthing_options";
private static final String SYNCTHING_GUI_KEY = "syncthing_gui";
private static final String DEVICE_NAME_KEY = "deviceName";
private static final String USAGE_REPORT_ACCEPTED = "urAccepted";
private static final String ADDRESS = "address";
private static final String USER = "user";
// Note that this preference is seperate from the syncthing config value. While Syncthing
// stores a password hash, we store the plaintext password in the Android preferences.
private static final String PASSWORD = "web_gui_password";
private static final String EXPORT_CONFIG = "export_config";
private static final String IMPORT_CONFIG = "import_config";
private static final String STTRACE = "sttrace";
private static final String SYNCTHING_RESET = "streset";
private static final String SYNCTHING_VERSION_KEY = "syncthing_version";
private static final String APP_VERSION_KEY = "app_version";
private static final String KEY_STTRACE = "sttrace";
private static final String KEY_EXPORT_CONFIG = "export_config";
private static final String KEY_IMPORT_CONFIG = "import_config";
private static final String KEY_STRESET = "streset";
private CheckBoxPreference mAlwaysRunInBackground;
private CheckBoxPreference mSyncOnlyCharging;
private CheckBoxPreference mSyncOnlyWifi;
private WifiSsidPreference mSyncOnlyOnSSIDs;
private EditTextPreference mDeviceName;
private EditTextPreference mListenAddresses;
private EditTextPreference mMaxRecvKbps;
private EditTextPreference mMaxSendKbps;
private CheckBoxPreference mNatEnabled;
private CheckBoxPreference mLocalAnnounceEnabled;
private CheckBoxPreference mGlobalAnnounceEnabled;
private CheckBoxPreference mRelaysEnabled;
private EditTextPreference mGlobalAnnounceServers;
private EditTextPreference mAddress;
private EditTextPreference mUser;
private EditTextPreference mPassword;
private CheckBoxPreference mUrAccepted;
private CheckBoxPreference mUseRoot;
private CheckBoxPreference mKeepWakelock;
private PreferenceScreen mOptionsScreen;
private PreferenceScreen mGuiScreen;
private Preference mSyncthingVersion;
private SyncthingService mSyncthingService;
private RestApi mApi;
@Override
public void onApiChange(SyncthingService.State currentState) {
boolean enabled = currentState == SyncthingService.State.ACTIVE;
mOptionsScreen.setEnabled(enabled);
mGuiScreen.setEnabled(enabled);
mUseRoot.setEnabled(enabled);
mKeepWakelock.setEnabled(enabled);
if (currentState == SyncthingService.State.ACTIVE) {
Preference syncthingVersion = getPreferenceScreen().findPreference(SYNCTHING_VERSION_KEY);
syncthingVersion.setSummary(mSyncthingService.getApi().getVersion());
RestApi api = mSyncthingService.getApi();
for (int i = 0; i < mOptionsScreen.getPreferenceCount(); i++) {
final Preference pref = mOptionsScreen.getPreference(i);
pref.setOnPreferenceChangeListener(SettingsFragment.this);
String value;
switch (pref.getKey()) {
case DEVICE_NAME_KEY:
value = api.getLocalDevice().name;
break;
case USAGE_REPORT_ACCEPTED:
int setting = api.getUsageReportAccepted();
value = Boolean.toString(setting == RestApi.USAGE_REPORTING_ACCEPTED);
break;
default:
value = api.getValue(RestApi.TYPE_OPTIONS, pref.getKey());
}
applyPreference(pref, value);
}
Preference address = mGuiScreen.findPreference(ADDRESS);
address.setOnPreferenceChangeListener(this);
applyPreference(address, api.getValue(RestApi.TYPE_GUI, ADDRESS));
Preference user = mGuiScreen.findPreference(USER);
user.setOnPreferenceChangeListener(this);
applyPreference(user, api.getValue(RestApi.TYPE_GUI, USER));
Preference password = mGuiScreen.findPreference(PASSWORD);
password.setOnPreferenceChangeListener(this);
}
}
/**
* Applies the given value to the preference.
*
* If pref is an EditTextPreference, setText is used and the value shown as summary. If pref is
* a CheckBoxPreference, setChecked is used (by parsing value as Boolean).
*/
private void applyPreference(Preference pref, String value) {
if (pref instanceof EditTextPreference) {
((EditTextPreference) pref).setText(value);
} else if (pref instanceof CheckBoxPreference) {
((CheckBoxPreference) pref).setChecked(Boolean.parseBoolean(value));
}
}
private Options mOptions;
private Config.Gui mGui;
/**
* Loads layout, sets version from Rest API.
@ -129,20 +82,59 @@ public class SettingsFragment extends PreferenceFragment
((SyncthingActivity) getActivity()).registerOnServiceConnectedListener(this);
addPreferencesFromResource(R.xml.app_settings);
final PreferenceScreen screen = getPreferenceScreen();
mAlwaysRunInBackground = (CheckBoxPreference)
findPreference(SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND);
mSyncOnlyCharging = (CheckBoxPreference)
findPreference(SyncthingService.PREF_SYNC_ONLY_CHARGING);
mSyncOnlyWifi = (CheckBoxPreference) findPreference(SyncthingService.PREF_SYNC_ONLY_WIFI);
mSyncOnlyOnSSIDs = (WifiSsidPreference) findPreference(SyncthingService.PREF_SYNC_ONLY_WIFI_SSIDS);
mSyncOnlyOnSSIDs.setDefaultValue(new TreeSet<String>()); // default to empty list
mUseRoot = (CheckBoxPreference) findPreference(SyncthingService.PREF_USE_ROOT);
mKeepWakelock = (CheckBoxPreference) findPreference(SyncthingService.PREF_USE_WAKE_LOCK);
Preference appVersion = screen.findPreference(APP_VERSION_KEY);
mOptionsScreen = (PreferenceScreen) screen.findPreference(SYNCTHING_OPTIONS_KEY);
mGuiScreen = (PreferenceScreen) screen.findPreference(SYNCTHING_GUI_KEY);
Preference sttrace = findPreference(STTRACE);
PreferenceScreen screen = getPreferenceScreen();
mAlwaysRunInBackground =
(CheckBoxPreference) findPreference(SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND);
mSyncOnlyCharging =
(CheckBoxPreference) findPreference(SyncthingService.PREF_SYNC_ONLY_CHARGING);
mSyncOnlyWifi =
(CheckBoxPreference) findPreference(SyncthingService.PREF_SYNC_ONLY_WIFI);
mSyncOnlyOnSSIDs =
(WifiSsidPreference) findPreference(SyncthingService.PREF_SYNC_ONLY_WIFI_SSIDS);
mDeviceName = (EditTextPreference) findPreference("deviceName");
mListenAddresses = (EditTextPreference) findPreference("listenAddresses");
mMaxRecvKbps = (EditTextPreference) findPreference("maxRecvKbps");
mMaxSendKbps = (EditTextPreference) findPreference("maxSendKbps");
mNatEnabled = (CheckBoxPreference) findPreference("natEnabled");
mLocalAnnounceEnabled = (CheckBoxPreference) findPreference("localAnnounceEnabled");
mGlobalAnnounceEnabled = (CheckBoxPreference) findPreference("globalAnnounceEnabled");
mRelaysEnabled = (CheckBoxPreference) findPreference("relaysEnabled");
mGlobalAnnounceServers = (EditTextPreference) findPreference("globalAnnounceServers");
mAddress = (EditTextPreference) findPreference("address");
mUser = (EditTextPreference) findPreference("user");
mPassword = (EditTextPreference) findPreference("password");
mUrAccepted = (CheckBoxPreference) findPreference("urAccepted");
Preference exportConfig = findPreference("export_config");
Preference importConfig = findPreference("import_config");
Preference stTrace = findPreference("sttrace");
Preference stReset = findPreference("streset");
mUseRoot = (CheckBoxPreference) findPreference(SyncthingService.PREF_USE_ROOT);
Preference useWakelock = findPreference(SyncthingService.PREF_USE_WAKE_LOCK);
Preference foregroundService = findPreference("run_as_foreground_service");
Preference useTor = findPreference("use_tor");
mSyncthingVersion = findPreference("syncthing_version");
Preference appVersion = screen.findPreference("app_version");
setPreferenceCategoryChangeListener(findPreference("category_run_conditions"), this);
setPreferenceCategoryChangeListener(
findPreference("category_syncthing_options"), this::onSyncthingPreferenceChange);
exportConfig.setOnPreferenceClickListener(this);
importConfig.setOnPreferenceClickListener(this);
stTrace.setOnPreferenceChangeListener(this);
stReset.setOnPreferenceClickListener(this);
mUseRoot.setOnPreferenceChangeListener(this);
useWakelock.setOnPreferenceChangeListener(this::onRequireRestart);
foregroundService.setOnPreferenceChangeListener(this::onRequireRestart);
useTor.setOnPreferenceChangeListener(this::onRequireRestart);
try {
appVersion.setSummary(getActivity().getPackageManager()
@ -150,17 +142,193 @@ public class SettingsFragment extends PreferenceFragment
} catch (PackageManager.NameNotFoundException e) {
Log.d(TAG, "Failed to get app version name");
}
}
mAlwaysRunInBackground.setOnPreferenceChangeListener(this);
mSyncOnlyCharging.setOnPreferenceChangeListener(this);
mSyncOnlyWifi.setOnPreferenceChangeListener(this);
mSyncOnlyOnSSIDs.setOnPreferenceChangeListener(this);
mUseRoot.setOnPreferenceClickListener(this);
mKeepWakelock.setOnPreferenceClickListener(this);
screen.findPreference(EXPORT_CONFIG).setOnPreferenceClickListener(this);
screen.findPreference(IMPORT_CONFIG).setOnPreferenceClickListener(this);
screen.findPreference(SYNCTHING_RESET).setOnPreferenceClickListener(this);
sttrace.setOnPreferenceChangeListener(this);
@Override
public void onServiceConnected() {
mSyncthingService = ((SyncthingActivity) getActivity()).getService();
mSyncthingService.registerOnApiChangeListener(this);
mGui = mSyncthingService.getApi().getGui();
mOptions = mSyncthingService.getApi().getOptions();
}
@Override
public void onApiChange(SyncthingService.State currentState) {
boolean enabled = currentState == SyncthingService.State.ACTIVE;
getPreferenceScreen().setEnabled(enabled);
if (!enabled)
return;
mApi = mSyncthingService.getApi();
mSyncthingVersion.setSummary(mApi.getVersion());
mOptions = mApi.getOptions();
mGui = mApi.getGui();
Joiner joiner = Joiner.on(", ");
mDeviceName.setTitle(mApi.getLocalDevice().name);
mListenAddresses.setText(joiner.join(mOptions.listenAddresses));
mMaxRecvKbps.setText(Integer.toString(mOptions.maxRecvKbps));
mMaxSendKbps.setText(Integer.toString(mOptions.maxSendKbps));
mNatEnabled.setChecked(mOptions.natEnabled);
mLocalAnnounceEnabled.setChecked(mOptions.localAnnounceEnabled);
mGlobalAnnounceEnabled.setChecked(mOptions.globalAnnounceEnabled);
mRelaysEnabled.setChecked(mOptions.relaysEnabled);
mGlobalAnnounceServers.setText(joiner.join(mOptions.globalAnnounceServers));
mAddress.setText(mGui.address);
mUser.setText(mGui.user);
mPassword.setText(mGui.password);
mUrAccepted.setChecked(mOptions.getUsageReportValue() == Options.USAGE_REPORTING_ACCEPTED);
}
@Override
public void onDestroy() {
super.onDestroy();
mSyncthingService.unregisterOnApiChangeListener(this);
}
private void setPreferenceCategoryChangeListener(
Preference category, Preference.OnPreferenceChangeListener listener) {
PreferenceScreen ps = (PreferenceScreen) category;
for (int i = 0; i < ps.getPreferenceCount(); i++) {
Preference p = ps.getPreference(i);
p.setOnPreferenceChangeListener(listener);
}
}
public boolean onSyncthingPreferenceChange(Preference preference, Object o) {
Device localDevice = mApi.getLocalDevice();
localDevice.name = mDeviceName.getText();
mApi.editDevice(localDevice);
Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings();
mOptions.listenAddresses = Iterables.toArray(
splitter.split(mListenAddresses.getText()), String.class);
mOptions.maxRecvKbps = Integer.valueOf(mMaxRecvKbps.getText());
mOptions.maxRecvKbps = Integer.valueOf(mMaxSendKbps.getText());
mOptions.natEnabled = mNatEnabled.isChecked();
mOptions.localAnnounceEnabled = mLocalAnnounceEnabled.isChecked();
mOptions.globalAnnounceEnabled = mGlobalAnnounceEnabled.isChecked();
mOptions.relaysEnabled = mRelaysEnabled.isChecked();
mOptions.globalAnnounceServers = Iterables.toArray(
splitter.split(mGlobalAnnounceServers.getText()), String.class);
mGui.address = mAddress.getText();
mGui.user = mUser.getText();
mGui.password = mPassword.getText();
mOptions.urAccepted = (mUrAccepted.isChecked())
? Options.USAGE_REPORTING_ACCEPTED
: Options.USAGE_REPORTING_DENIED;
mApi.editOptions(mOptions, getActivity());
mApi.editGui(mGui, getActivity());
return true;
}
public boolean onRequireRestart(Preference preference, Object o) {
mSyncthingService.getApi().requireRestart(getActivity());
return true;
}
/**
* Sends the updated value to {@link }RestApi}, and sets it as the summary
* for EditTextPreference.
*/
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
switch (preference.getKey()) {
case SyncthingService.PREF_ALWAYS_RUN_IN_BACKGROUND:
boolean value = (Boolean) o;
mAlwaysRunInBackground.setSummary((value)
? R.string.always_run_in_background_enabled
: R.string.always_run_in_background_disabled);
mSyncOnlyCharging.setEnabled(value);
mSyncOnlyWifi.setEnabled(value);
mSyncOnlyOnSSIDs.setEnabled(mSyncOnlyWifi.isChecked());
// Uncheck items when disabled, so it is clear they have no effect.
if (!value) {
mSyncOnlyCharging.setChecked(false);
mSyncOnlyWifi.setChecked(false);
}
break;
case SyncthingService.PREF_SYNC_ONLY_WIFI:
mSyncOnlyOnSSIDs.setEnabled((Boolean) o);
break;
case KEY_STTRACE:
if (((String) o).matches("[0-9a-z, ]*"))
mSyncthingService.getApi().requireRestart(getActivity());
else {
Toast.makeText(getActivity(), R.string.toast_invalid_sttrace, Toast.LENGTH_SHORT)
.show();
return false;
}
break;
}
return true;
}
@Override
public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()) {
case SyncthingService.PREF_USE_ROOT:
if (mUseRoot.isChecked()) {
// Only check preference after root was granted.
mUseRoot.setChecked(false);
new TestRootTask().execute();
} else {
new Thread(new ChownFilesRunnable()).start();
mSyncthingService.getApi().requireRestart(getActivity());
}
return true;
case KEY_EXPORT_CONFIG:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_export)
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
mSyncthingService.exportConfig();
Toast.makeText(getActivity(),
getString(R.string.config_export_successful,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
case KEY_IMPORT_CONFIG:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_import)
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
if (mSyncthingService.importConfig()) {
Toast.makeText(getActivity(),
getString(R.string.config_imported_successful),
Toast.LENGTH_SHORT).show();
// No need to restart, as we shutdown to import the config, and
// then have to start Syncthing again.
} else {
Toast.makeText(getActivity(),
getString(R.string.config_import_failed,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
case KEY_STRESET:
final Intent intent = new Intent(getActivity(), SyncthingService.class)
.setAction(SyncthingService.ACTION_RESET);
new AlertDialog.Builder(getActivity())
.setTitle(R.string.streset_title)
.setMessage(R.string.streset_question)
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
getActivity().startService(intent);
Toast.makeText(getActivity(), R.string.streset_done, Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {
})
.show();
return true;
default:
return false;
}
}
/**
@ -184,101 +352,6 @@ public class SettingsFragment extends PreferenceFragment
}
}
@Override
public void onServiceConnected() {
mSyncthingService = ((SyncthingActivity) getActivity()).getService();
mSyncthingService.registerOnApiChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
mSyncthingService.unregisterOnApiChangeListener(this);
}
/**
* Handles ActionBar back selected.
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(getActivity());
return true;
default:
return super.onOptionsItemSelected(item);
}
}
/**
* Sends the updated value to {@link }RestApi}, and sets it as the summary
* for EditTextPreference.
*/
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
boolean requireRestart = false;
if (preference.equals(mAlwaysRunInBackground)) {
boolean value = (Boolean) o;
preference.setSummary((value)
? R.string.always_run_in_background_enabled
: R.string.always_run_in_background_disabled);
mSyncOnlyCharging.setEnabled(value);
mSyncOnlyWifi.setEnabled(value);
mSyncOnlyOnSSIDs.setEnabled(mSyncOnlyWifi.isChecked());
// Uncheck items when disabled, so it is clear they have no effect.
if (!value) {
mSyncOnlyCharging.setChecked(false);
mSyncOnlyWifi.setChecked(false);
}
} else if (preference.equals(mSyncOnlyWifi)) {
mSyncOnlyOnSSIDs.setEnabled((Boolean) o);
} else if (preference.getKey().equals(DEVICE_NAME_KEY)) {
Device old = mSyncthingService.getApi().getLocalDevice();
Device updated = new Device();
updated.addresses = old.addresses;
updated.compression = old.compression;
updated.deviceID = old.deviceID;
updated.introducer = old.introducer;
updated.name = (String) o;
mSyncthingService.getApi().editDevice(updated, getActivity(), null);
} else if (preference.getKey().equals(USAGE_REPORT_ACCEPTED)) {
int setting = ((Boolean) o)
? RestApi.USAGE_REPORTING_ACCEPTED
: RestApi.USAGE_REPORTING_DENIED;
mSyncthingService.getApi().setUsageReportAccepted(setting, getActivity());
} else if (mOptionsScreen.findPreference(preference.getKey()) != null) {
boolean isArray = preference.getKey().equals("listenAddress") ||
preference.getKey().equals("globalAnnounceServers");
mSyncthingService.getApi().setValue(RestApi.TYPE_OPTIONS, preference.getKey(), o,
isArray, getActivity());
} else if (preference.getKey().equals(ADDRESS)) {
mSyncthingService.getApi().setValue(
RestApi.TYPE_GUI, preference.getKey(), o, false, getActivity());
} else if (preference.getKey().equals(USER)) {
mSyncthingService.getApi().setValue(
RestApi.TYPE_GUI, preference.getKey(), o, false, getActivity());
} else if (preference.getKey().equals(PASSWORD)) {
mSyncthingService.getApi().setValue(
RestApi.TYPE_GUI, "password", o, false, getActivity());
}
// Avoid any code injection.
if (preference.getKey().equals(STTRACE)) {
if (((String) o).matches("[0-9a-z, ]*"))
requireRestart = true;
else {
Toast.makeText(getActivity(), R.string.toast_invalid_sttrace, Toast.LENGTH_SHORT).show();
return false;
}
}
if (requireRestart)
mSyncthingService.getApi().requireRestart(getActivity());
return true;
}
/**
* Changes the owner of syncthing files so they can be accessed without root.
*/
@ -291,73 +364,4 @@ public class SettingsFragment extends PreferenceFragment
}
}
@Override
public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()) {
case SyncthingService.PREF_USE_ROOT:
if (mUseRoot.isChecked()) {
// Only check preference after root was granted.
mUseRoot.setChecked(false);
new TestRootTask().execute();
} else {
new Thread(new ChownFilesRunnable()).start();
mSyncthingService.getApi().requireRestart(getActivity());
}
return true;
case SyncthingService.PREF_USE_WAKE_LOCK:
mSyncthingService.getApi().requireRestart(getActivity());
return true;
case EXPORT_CONFIG:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_export)
.setPositiveButton(android.R.string.yes,
(dialog, which) -> {
mSyncthingService.exportConfig();
Toast.makeText(getActivity(),
getString(R.string.config_export_successful,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
case IMPORT_CONFIG:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_import)
.setPositiveButton(android.R.string.yes,
(dialog, which) -> {
if (mSyncthingService.importConfig()) {
Toast.makeText(getActivity(),
getString(R.string.config_imported_successful),
Toast.LENGTH_SHORT).show();
// No need to restart, as we shutdown to import the config, and
// then have to start Syncthing again.
} else {
Toast.makeText(getActivity(),
getString(R.string.config_import_failed,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
case SYNCTHING_RESET:
final Intent intent = new Intent(getActivity(), SyncthingService.class)
.setAction(SyncthingService.ACTION_RESET);
new AlertDialog.Builder(getActivity())
.setTitle(R.string.streset_title)
.setMessage(R.string.streset_question)
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
getActivity().startService(intent);
Toast.makeText(getActivity(), R.string.streset_done, Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {
})
.show();
return true;
default:
return false;
}
}
}

View file

@ -38,6 +38,11 @@ public abstract class RestTask<Params, Progress> extends
private static final String TAG = "RestTask";
/**
* The name of the HTTP header used for the syncthing API key.
*/
private static final String HEADER_API_KEY = "X-API-Key";
public interface OnSuccessListener {
public void onSuccess(String result);
}
@ -67,7 +72,7 @@ public abstract class RestTask<Params, Progress> extends
URL url = new URL(uriBuilder.build().toString());
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty(RestApi.HEADER_API_KEY, mApiKey);
connection.setRequestProperty(HEADER_API_KEY, mApiKey);
connection.setHostnameVerifier((h, s) -> true);
connection.setSSLSocketFactory(getSslSocketFactory());
return connection;

View file

@ -0,0 +1,23 @@
package com.nutomic.syncthingandroid.model;
import java.util.List;
public class Config {
public int version;
public String[] ignoredDevices;
public List<Device> devices;
public List<Folder> folders;
public Gui gui;
public Options options;
public class Gui {
public boolean enabled;
public String address;
public String user;
public String password;
public boolean useTLS;
public String apiKey;
public boolean insecureAdminAccess;
public String theme;
}
}

View file

@ -5,7 +5,7 @@ import android.text.TextUtils;
import java.io.Serializable;
import java.util.List;
public class Device implements Serializable {
public class Device {
public String deviceID;
public String name;
public List<String> addresses;

View file

@ -6,7 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Folder implements Serializable {
public class Folder {
public String id;
public String label;

View file

@ -0,0 +1,50 @@
package com.nutomic.syncthingandroid.model;
public class Options {
public String[] listenAddresses;
public String[] globalAnnounceServers;
public boolean globalAnnounceEnabled;
public boolean localAnnounceEnabled;
public int localAnnouncePort;
public String localAnnounceMCAddr;
public int maxSendKbps;
public int maxRecvKbps;
public int reconnectionIntervalS;
public boolean relaysEnabled;
public int relayReconnectIntervalM;
public boolean startBrowser;
public boolean natEnabled;
public int natLeaseMinutes;
public int natRenewalMinutes;
public int natTimeoutSeconds;
public int urAccepted;
public String urUniqueId;
public String urURL;
public boolean urPostInsecurely;
public int urInitialDelayS;
public boolean restartOnWakeup;
public int autoUpgradeIntervalH;
public int keepTemporariesH;
public boolean cacheIgnoredFiles;
public int progressUpdateIntervalS;
public boolean symlinksEnabled;
public boolean limitBandwidthInLan;
public int minHomeDiskFreePct;
public String releasesURL;
public String[] alwaysLocalNets;
public boolean overwriteRemoteDeviceNamesOnConnect;
public int tempIndexMinBlocks;
public static final int USAGE_REPORTING_UNDECIDED = 0;
public static final int USAGE_REPORTING_ACCEPTED = 2;
public static final int USAGE_REPORTING_DENIED = -1;
public int getUsageReportValue() {
if (urAccepted > USAGE_REPORTING_ACCEPTED)
throw new RuntimeException("Inalid usage reporting value");
return (urAccepted == USAGE_REPORTING_ACCEPTED || urAccepted == USAGE_REPORTING_DENIED)
? urAccepted
: USAGE_REPORTING_UNDECIDED;
}
}

View file

@ -5,24 +5,26 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.util.Log;
import com.google.common.base.Objects;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.nutomic.syncthingandroid.BuildConfig;
import com.nutomic.syncthingandroid.activities.RestartActivity;
import com.nutomic.syncthingandroid.http.GetTask;
import com.nutomic.syncthingandroid.http.PostTask;
import com.nutomic.syncthingandroid.model.Config;
import com.nutomic.syncthingandroid.model.Connection;
import com.nutomic.syncthingandroid.model.Device;
import com.nutomic.syncthingandroid.model.Folder;
import com.nutomic.syncthingandroid.model.Model;
import com.nutomic.syncthingandroid.model.Options;
import com.nutomic.syncthingandroid.model.SystemInfo;
import com.nutomic.syncthingandroid.model.SystemVersion;
import com.nutomic.syncthingandroid.util.FolderObserver;
@ -31,10 +33,8 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Type;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -49,51 +49,24 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
private static final String TAG = "RestApi";
/**
* Parameter for {@link #getValue} or {@link #setValue} referring to "options" config item.
*/
public static final String TYPE_OPTIONS = "options";
/**
* Parameter for {@link #getValue} or {@link #setValue} referring to "gui" config item.
*/
public static final String TYPE_GUI = "gui";
/**
* The name of the HTTP header used for the syncthing API key.
*/
public static final String HEADER_API_KEY = "X-API-Key";
/**
* Key of the map element containing connection info for the local device, in the return
* value of {@link #getConnections}
*/
public static final String TOTAL_STATS = "total";
public static final int USAGE_REPORTING_UNDECIDED = 0;
public static final int USAGE_REPORTING_ACCEPTED = 2;
public static final int USAGE_REPORTING_DENIED = -1;
private static final List<Integer> USAGE_REPORTING_DECIDED =
Arrays.asList(USAGE_REPORTING_ACCEPTED, USAGE_REPORTING_DENIED);
public interface OnConfigChangedListener {
void onConfigChanged();
}
private final Context mContext;
private String mVersion;
private final URL mUrl;
private final String mApiKey;
private final String mHttpsCertPath;
private JSONObject mConfig;
private String mVersion;
private Config mConfig;
private String mLocalDeviceId;
private boolean mRestartPostponed = false;
/**
@ -113,11 +86,6 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
*/
private final HashMap<String, Model> mCachedModelInfo = new HashMap<>();
/**
* Stores a hash map to resolve folders to paths for events.
*/
private final Map<String, String> mCacheFolderPathLookup = new HashMap<>();
public RestApi(Context context, URL url, String apiKey, OnApiAvailableListener apiListener,
OnConfigChangedListener configListener) {
mContext = context;
@ -159,12 +127,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
tryIsAvailable();
}).execute();
new GetTask(mUrl, GetTask.URI_CONFIG, mHttpsCertPath, mApiKey, result -> {
try {
mConfig = new JSONObject(result);
tryIsAvailable();
} catch (JSONException e) {
Log.w(TAG, "Failed to parse config", e);
}
mConfig = new Gson().fromJson(result, Config.class);
tryIsAvailable();
}).execute();
getSystemInfo(info -> {
mLocalDeviceId = info.myID;
@ -197,71 +161,12 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* Stops syncthing and cancels notification. For use by {@link SyncthingService}.
*/
public void shutdown() {
// Happens in unit tests.
if (mContext == null)
return;
NotificationManager nm = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(RestartActivity.NOTIFICATION_RESTART);
mRestartPostponed = false;
}
/**
* Gets a value from config,
*
* Booleans are returned as {@link }Boolean#toString}, arrays as space seperated string.
*
* @param name {@link #TYPE_OPTIONS} or {@link #TYPE_GUI}
* @param key The key to read from.
* @return The value as a String, or null on failure.
*/
public String getValue(String name, String key) {
// Happens if this functions is called before class is fully initialized.
if (mConfig == null)
return "";
try {
Object value = mConfig.getJSONObject(name).get(key);
return (value instanceof JSONArray)
? ((JSONArray) value).join(", ").replace("\"", "").replace("\\", "")
: value.toString();
} catch (JSONException e) {
Log.w(TAG, "Failed to get value for " + key, e);
return "";
}
}
/**
* Sets a value to config and sends it via Rest API.
* <p/>
* Booleans must be passed as {@link Boolean}, arrays as space seperated string
* with isArray true.
*
* @param name {@link #TYPE_OPTIONS} or {@link #TYPE_GUI}
* @param key The key to write to.
* @param value The new value to set, either String, Boolean or Integer.
* @param isArray True if value is a space seperated String that should be converted to array.
*/
public <T> void setValue(String name, String key, T value, boolean isArray, Activity activity) {
try {
mConfig.getJSONObject(name).put(key, (isArray)
? new JSONArray(Arrays.asList(((String) value).split(",")))
: value);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to set value for " + key, e);
}
}
private List<String> jsonToList(JSONArray array) throws JSONException {
ArrayList<String> list = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {
list.add(array.getString(i));
}
return list;
}
/**
* Either shows a restart dialog, or only updates the config, depending on
* {@link #mRestartPostponed}.
@ -277,16 +182,14 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
}
/**
* Sends the current config to Syncthing and restarts it.
*
* This executes a restart immediately, and does not show a dialog.
* Immediately restarts Syncthing, without confirmation.
*/
public void updateConfig() {
public void restart() {
new PostTask(mUrl, PostTask.URI_CONFIG, mHttpsCertPath, mApiKey, result -> {
mContext.startService(new Intent(mContext, SyncthingService.class)
.setAction(SyncthingService.ACTION_RESTART));
Intent intent = new Intent(mContext, SyncthingService.class)
.setAction(SyncthingService.ACTION_RESTART);
mContext.startService(intent);
}).execute(mConfig.toString());
}
/**
@ -295,26 +198,89 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* @param includeLocal True if the local device should be included in the result.
*/
public List<Device> getDevices(boolean includeLocal) {
if (mConfig == null)
return new ArrayList<>();
List<Device> devices = deepCopy(mConfig.devices, new TypeToken<List<Device>>(){}.getType());
try {
String json = mConfig.getJSONArray("devices").toString();
List<Device> devices = new ArrayList<>();
Collections.addAll(devices, new Gson().fromJson(json, Device[].class));
Iterator<Device> it = devices.iterator();
while (it.hasNext()) {
Device device = it.next();
boolean isLocalDevice = Objects.equal(mLocalDeviceId, device.deviceID);
if (!includeLocal && isLocalDevice)
it.remove();
}
return devices;
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
return new ArrayList<>();
Iterator<Device> it = devices.iterator();
while (it.hasNext()) {
Device device = it.next();
boolean isLocalDevice = Objects.equal(mLocalDeviceId, device.deviceID);
if (!includeLocal && isLocalDevice)
it.remove();
}
return devices;
}
public Options getOptions() {
return deepCopy(mConfig.options, Options.class);
}
public Config.Gui getGui() {
return deepCopy(mConfig.gui, Config.Gui.class);
}
/**
* Returns a deep copy of object.
*
* This method uses Gson and only works with objects that can be converted with Gson.
*/
public <T> T deepCopy(T object, Type type) {
Gson gson = new Gson();
return gson.fromJson(gson.toJson(object, type), type);
}
public void removeDevice(String deviceId) {
Iterator<Device> it = mConfig.devices.iterator();
while (it.hasNext()) {
Device d = it.next();
if (d.deviceID.equals(deviceId)) {
it.remove();
}
}
}
public void removeFolder(String id) {
Iterator<Folder> it = mConfig.folders.iterator();
while (it.hasNext()) {
Folder f = it.next();
if (f.id.equals(id)) {
it.remove();
}
}
}
public void addDevice(Device device, OnDeviceIdNormalizedListener listener) {
normalizeDeviceId(device.deviceID, ((normalizedId, error) -> {
if (error == null) {
mConfig.devices.add(device);
}
else {
listener.onDeviceIdNormalized(normalizedId, error);
}
}));
}
public void addFolder(Folder folder) {
mConfig.folders.add(folder);
}
public void editDevice(Device newDevice) {
removeDevice(newDevice.deviceID);
addDevice(newDevice, null);
}
public void editFolder(Folder newFolder) {
removeFolder(newFolder.id);
addFolder(newFolder);
}
public void editGui(Config.Gui newGui, Activity activity) {
mConfig.gui = newGui;
requireRestart(activity);
}
public void editOptions(Options newOptions, Activity activity) {
mConfig.options = newOptions;
requireRestart(activity);
}
/**
@ -338,7 +304,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
*/
public void getSystemInfo(final OnReceiveSystemInfoListener listener) {
new GetTask(mUrl, GetTask.URI_SYSTEM, mHttpsCertPath, mApiKey, result -> {
listener.onReceiveSystemInfo(new Gson().fromJson(result, SystemInfo.class));
listener.onReceiveSystemInfo(new Gson().fromJson(result, SystemInfo.class));
}).execute();
}
@ -349,12 +315,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
*/
public void getSystemVersion(final OnReceiveSystemVersionListener listener) {
new GetTask(mUrl, GetTask.URI_VERSION, mHttpsCertPath, mApiKey, result -> {
try {
SystemVersion systemVersion = new Gson().fromJson(result, SystemVersion.class);
listener.onReceiveSystemVersion(systemVersion);
} catch (JsonSyntaxException e) {
Log.w(TAG, "Failed to read system info", e);
}
SystemVersion systemVersion = new Gson().fromJson(result, SystemVersion.class);
listener.onReceiveSystemVersion(systemVersion);
}).execute();
}
@ -362,16 +324,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* Returns a list of all existing folders.
*/
public List<Folder> getFolders() {
if (mConfig == null)
return new ArrayList<>();
try {
String foldersJson = mConfig.getJSONArray("folders").toString();
return Arrays.asList(new Gson().fromJson(foldersJson, Folder[].class));
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
return new ArrayList<>();
}
return deepCopy(mConfig.folders, new TypeToken<List<Folder>>(){}.getType());
}
/**
@ -520,28 +473,6 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
}).execute("folder", folderId);
}
/**
* Refreshes the lookup table to convert folder names to paths for events.
*/
private String getPathForFolder(String folderName) {
synchronized(mCacheFolderPathLookup) {
if (!mCacheFolderPathLookup.containsKey(folderName)) {
mCacheFolderPathLookup.clear();
for (Folder folder : getFolders()) {
mCacheFolderPathLookup.put(folder.id, folder.path);
}
}
return mCacheFolderPathLookup.get(folderName);
}
}
private void clearFolderCache() {
synchronized(mCacheFolderPathLookup) {
mCacheFolderPathLookup.clear();
}
}
/**
* Retrieves the events that have accumulated since the given event id.
*
@ -567,7 +498,12 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
// Add folder path to data.
if (data != null && data.has("folder")) {
String folder = data.get("folder").getAsString();
String folderPath = getPathForFolder(folder);
String folderPath = null;
for (Folder f : mConfig.folders) {
if (f.id.equals(folder)) {
folderPath = f.path;
}
}
data.addProperty("folderpath", folderPath);
}
@ -579,168 +515,6 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
"since", String.valueOf(sinceId), "limit", String.valueOf(limit));
}
/**
* Updates or creates the given device, depending on whether it already exists.
*
* @param device Settings of the device to edit. To create a device, pass a non-existant device ID.
* @param listener for the normalized device ID (may be null).
*/
public void editDevice(@NonNull final Device device, final Activity activity,
final OnDeviceIdNormalizedListener listener) {
normalizeDeviceId(device.deviceID,
(normalizedId, error) -> {
if (listener != null) listener.onDeviceIdNormalized(normalizedId, error);
if (normalizedId == null)
return;
device.deviceID = normalizedId;
// If the device already exists, just update it.
boolean create = true;
for (Device n : getDevices(true)) {
if (n.deviceID.equals(device.deviceID)) {
create = false;
}
}
try {
JSONArray devices = mConfig.getJSONArray("devices");
JSONObject n = null;
if (create) {
n = new JSONObject();
devices.put(n);
} else {
for (int i = 0; i < devices.length(); i++) {
JSONObject json = devices.getJSONObject(i);
if (device.deviceID.equals(json.getString("deviceID"))) {
n = devices.getJSONObject(i);
break;
}
}
}
n.put("deviceID", device.deviceID);
n.put("name", device.name);
n.put("addresses", new JSONArray(device.addresses));
n.put("compression", device.compression);
n.put("introducer", device.introducer);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
}
}
);
}
/**
* Deletes the given device from syncthing.
*/
public boolean deleteDevice(Device device, Activity activity) {
try {
JSONArray devices = mConfig.getJSONArray("devices");
for (int i = 0; i < devices.length(); i++) {
JSONObject json = devices.getJSONObject(i);
if (device.deviceID.equals(json.getString("deviceID"))) {
mConfig.remove("devices");
mConfig.put("devices", delete(devices, devices.getJSONObject(i)));
break;
}
}
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to edit folder", e);
return false;
}
return true;
}
/**
* Updates or creates the given device.
*/
public void editFolder(Folder folder, boolean create, Activity activity) {
try {
JSONArray folders = mConfig.getJSONArray("folders");
JSONObject r = null;
if (create) {
r = new JSONObject();
folders.put(r);
} else {
for (int i = 0; i < folders.length(); i++) {
JSONObject json = folders.getJSONObject(i);
if (folder.id.equals(json.getString("id"))) {
r = folders.getJSONObject(i);
break;
}
}
}
r.put("path", folder.path);
r.put("label", folder.label);
r.put("id", folder.id);
r.put("ignorePerms", true);
r.put("type", folder.type);
JSONArray devices = new JSONArray();
for (String n : folder.getDevices()) {
JSONObject element = new JSONObject();
element.put("deviceID", n);
devices.put(element);
}
r.put("devices", devices);
JSONObject versioning = new JSONObject();
versioning.put("type", folder.versioning.type);
JSONObject params = new JSONObject();
versioning.put("params", params);
for (String key : folder.versioning.params.keySet()) {
params.put(key, folder.versioning.params.get(key));
}
r.put("rescanIntervalS", folder.rescanIntervalS);
r.put("versioning", versioning);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to edit folder " + folder.id + " at " + folder.path, e);
return;
}
clearFolderCache();
}
/**
* Deletes the given folder from syncthing.
*/
public boolean deleteFolder(Folder folder, Activity activity) {
try {
JSONArray folders = mConfig.getJSONArray("folders");
for (int i = 0; i < folders.length(); i++) {
JSONObject json = folders.getJSONObject(i);
if (folder.id.equals(json.getString("id"))) {
mConfig.remove("folders");
mConfig.put("folders", delete(folders, folders.getJSONObject(i)));
break;
}
}
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to edit folder", e);
return false;
}
clearFolderCache();
return true;
}
/**
* Replacement for {@link org.json.JSONArray#remove(int)}, which is not available on older APIs.
*/
private JSONArray delete(JSONArray array, JSONObject delete) throws JSONException {
JSONArray newArray = new JSONArray();
for (int i = 0; i < array.length(); i++) {
if (!array.getJSONObject(i).equals(delete)) {
newArray.put(array.get(i));
}
}
return newArray;
}
/**
* Result listener for {@link #normalizeDeviceId(String, OnDeviceIdNormalizedListener)}.
*/
@ -784,43 +558,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public Device getLocalDevice() {
for (Device d : getDevices(true)) {
if (d.deviceID.equals(mLocalDeviceId)) {
return d;
return deepCopy(d, Device.class);
}
}
return new Device();
}
/**
* Returns value of usage reporting preference.
*/
public int getUsageReportAccepted() {
try {
int value = mConfig.getJSONObject(TYPE_OPTIONS).getInt("urAccepted");
if (value > USAGE_REPORTING_ACCEPTED)
throw new RuntimeException("Inalid usage reporting value");
if (!USAGE_REPORTING_DECIDED.contains(value))
value = USAGE_REPORTING_UNDECIDED;
return value;
} catch (JSONException e) {
Log.w(TAG, "Failed to read usage report value", e);
return USAGE_REPORTING_DENIED;
}
}
/**
* Sets new value for usage reporting preference.
*/
public void setUsageReportAccepted(int value, Activity activity) {
if (BuildConfig.DEBUG && !USAGE_REPORTING_DECIDED.contains(value))
throw new IllegalArgumentException("Invalid value for usage report");
try {
mConfig.getJSONObject(TYPE_OPTIONS).put("urAccepted", value);
} catch (JSONException e) {
Log.w(TAG, "Failed to set usage report value", e);
}
requireRestart(activity);
throw new RuntimeException();
}
/**
@ -835,11 +576,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
*/
public void getUsageReport(final OnReceiveUsageReportListener listener) {
new GetTask(mUrl, GetTask.URI_REPORT, mHttpsCertPath, mApiKey, result -> {
try {
listener.onReceiveUsageReport(new JSONObject(result).toString(4));
} catch (JSONException e) {
throw new RuntimeException("Failed to prettify usage report", e);
}
JsonElement json = new JsonParser().parse(result);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
listener.onReceiveUsageReport(gson.toJson(json));
}).execute();
}

View file

@ -343,8 +343,7 @@ public class SyncthingService extends Service implements
return;
}
mApi = new RestApi(SyncthingService.this, urlAndKey.first, urlAndKey.second,
() -> {
mApi = new RestApi(SyncthingService.this, urlAndKey.first, urlAndKey.second, () -> {
mCurrentState = State.ACTIVE;
onApiChange();
new Thread(() -> {

View file

@ -21,7 +21,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;

View file

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
/**
* MultiSelectListPreference which allows the user to select on which WiFi networks (based on SSID)
@ -34,10 +35,11 @@ public class WifiSsidPreference extends MultiSelectListPreference {
public WifiSsidPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDefaultValue(new TreeSet<String>());
}
public WifiSsidPreference(Context context) {
super(context);
this(context, null);
}
/**

View file

@ -125,7 +125,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Настройки</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Постоянна работа на заден план</string>
<!--Preference summary in case it is enabled-->
@ -146,8 +145,7 @@
<item>С нисък приоритет</item>
<item>Без известия</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Настройки на Syncthing</string>
<string name="category_syncthing_options">Настройки на Syncthing</string>
<string name="device_name">Име на устройството</string>
<string name="listen_address">Адрес за слушане на синхронизиращия протокол</string>
<string name="max_recv_kbps">Лимит на скоростта за сваляне (KiB/s)</string>
@ -156,12 +154,11 @@
<string name="local_announce_enabled">Локално откриване</string>
<string name="global_announce_server">Сървър за глобално откриване</string>
<string name="usage_reporting"> Анонимен доклад за ползване на програмата</string>
<string name="syncthing_gui">Потребителски интерфейс на Syncthing</string>
<string name="gui_address">Адрес за свързване с потребителския интерфейс</string>
<string name="gui_user">Потребител за потребителския интерфейс</string>
<string name="gui_password">Парола за потребителския интерфейс</string>
<string name="export_config">Изнасяне на настройките</string>
<string name="experimental_settings">Експериментално</string>
<string name="category_experimental">Експериментално</string>
<!--Dialog shown before config export-->
<string name="dialog_confirm_export">Наистина ли желаете настройките да бъдат изнесени? Съществуващите файлове ще бъдат презаписани.\n\nВНИМАНИЕ! Програми могат да извлекат частния ви ключ от генерирания файл, а чрез него да свалят и синхронизират файлове.</string>
<!--Dialog shown before config import-->

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Nastavení</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Vždy spuštěné na pozadí</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Nízká priorita</item>
<item>Źádné</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Nastavení Syncthing</string>
<string name="category_syncthing_options">Nastavení Syncthing</string>
<string name="device_name">Jméno přístroje</string>
<string name="listen_address">Adresy naslouchání protokolu synchronizace</string>
<string name="max_recv_kbps">Omezení příchozí rychlosti (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Server globálního oznamování</string>
<string name="enable_relaying">Povolit relaying</string>
<string name="usage_reporting">Anonymní hlášení o používání</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">Adresy naslouchání GUI</string>
<string name="gui_user">Přihlašovací jméno pro GUI</string>
<string name="gui_password">Přihlašovací heslo pro GUI</string>
<string name="export_config">Zálohovat nastavení</string>
<string name="experimental_settings">Experimentální</string>
<string name="category_experimental">Experimentální</string>
<string name="keep_wakelock_while_binary_running">Udržovat CPU aktivní pokud běží Syncthing</string>
<string name="keep_wakelock_while_binary_running_summary">Použijte toto nastavení pokud zaznamenáváte neočekávaná ukončení spojení při běhu na baterii. Toto bude mít za následek vyšší spotřebu energie.</string>
<string name="run_as_foreground_service">Spustit službu na popředí</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Einstellungen</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Immer im Hintergrund ausführen</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Geringe Priorität</item>
<item>Keine Priorität</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing-Optionen</string>
<string name="category_syncthing_options">Syncthing-Optionen</string>
<string name="device_name">Gerätename</string>
<string name="listen_address">Adresse(n) für das Synchronisierungsprotokoll</string>
<string name="max_recv_kbps">Eingehende Datenrate Limite (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Globaler Indexserver</string>
<string name="enable_relaying">Weiterleitung aktivieren</string>
<string name="usage_reporting">Anonymer Nutzungsbericht</string>
<string name="syncthing_gui">Syncthing-Weboberfläche</string>
<string name="gui_address">Adressen für Weboberfläche</string>
<string name="gui_user">Nutzername für Weboberfläche</string>
<string name="gui_password">Passwort für Weboberfläche</string>
<string name="export_config">Konfiguration exportieren</string>
<string name="experimental_settings">Experimentell</string>
<string name="category_experimental">Experimentell</string>
<string name="keep_wakelock_while_binary_running">Prozessor wach halten während Syncthing läuft.</string>
<string name="keep_wakelock_while_binary_running_summary">Nutze dieses Einstellung, wenn du unerwartete Verbindungsabbrüche hast, während du im Batteriebetrieb arbeitest. Das wird zu einem erhöhten Energieverbrauch führen.</string>
<string name="run_as_foreground_service">Führe Dienst mit Vordergrund-Priorität aus</string>

View file

@ -126,7 +126,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Configuración</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Siempre ejecutar en el fondo</string>
<!--Preference summary in case it is enabled-->
@ -147,8 +146,7 @@
<item>Baja Prioridad</item>
<item>Ninguna</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Opciones de Syncthing</string>
<string name="category_syncthing_options">Opciones de Syncthing</string>
<string name="device_name">Nombre del dispositivo</string>
<string name="listen_address">Direcciones de escucha del Protocolo de Sincronización</string>
<string name="max_recv_kbps">Límite de Tasa de Entrada (KiB/s)</string>
@ -157,12 +155,11 @@
<string name="local_announce_enabled">Descubrimiento Local</string>
<string name="global_announce_server">Servidor de Descubrimiento Global</string>
<string name="usage_reporting">Reporte de uso anónimo</string>
<string name="syncthing_gui">Interfaz gráfica de Syncthing</string>
<string name="gui_address">Direcciones de escucha de la interfaz gráfica</string>
<string name="gui_user">Autenticación del Usuario en la Interfaz Gráfica</string>
<string name="gui_password">Autenticación de la Contraseña en la Interfaz Gráfica</string>
<string name="export_config">Exportar Configuración</string>
<string name="experimental_settings">Experimental</string>
<string name="category_experimental">Experimental</string>
<string name="keep_wakelock_while_binary_running">Mantener el CPU encendido mientras Syncthing está en ejecución</string>
<string name="keep_wakelock_while_binary_running_summary">Use estos ajustes si experimenta desconexiones inesperadas mientras opera con la batería. Esto resultará en un consumo elevado de batería.</string>
<!--Dialog shown before config export-->

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Ajustes</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Ejecutar siempre en segundo plano</string>
<!--Preference summary in case it is enabled-->
@ -155,6 +154,7 @@
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Opciones de Syncthing</string>
<string name="device_name">Nombre del dispositivo</string>
<string name="category_syncthing_options">Opciones de Syncthing</string>
<string name="listen_address">Direcciones de escucha del protocolo de sincronización</string>
<string name="max_recv_kbps">Límite de tráfico de entrada (KiB/s)</string>
<string name="max_send_kbps">Límite de tráfico de salida (KiB/s)</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Paramètres</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Fonctionner en tâche de fond.</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Discrète</item>
<item>Aucune</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Options Syncthing</string>
<string name="category_syncthing_options">Options Syncthing</string>
<string name="device_name">Nom de l\'appareil</string>
<string name="listen_address">Adresse d\'écoute pour la synchro</string>
<string name="max_recv_kbps">Limite du débit de réception (Ko/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Serveur de découverte globale</string>
<string name="enable_relaying">Activer le relayage</string>
<string name="usage_reporting">Rapports anonymes d\'utilisation</string>
<string name="syncthing_gui">Interface WEB Syncthing</string>
<string name="gui_address">Adresse pour l\'interface WEB</string>
<string name="gui_user">Nom d\'authentification pour l\'interface WEB</string>
<string name="gui_password">Mot de passe d\'authentification pour l\'interface WEB</string>
<string name="export_config">Exporter la configuration</string>
<string name="experimental_settings">Expérimental</string>
<string name="category_experimental">Expérimental</string>
<string name="keep_wakelock_while_binary_running">Garder le CPU en éveil quand Syncthing fonctionne.</string>
<string name="keep_wakelock_while_binary_running_summary">Utilisez ce paramètre si vous rencontrez des déconnexions inattendues en fonctionnant sur batterie. Il en résultera une augmentation de la consommation de la batterie.</string>
<string name="run_as_foreground_service">Fonctionner avec prioriré de premier plan</string>

View file

@ -111,7 +111,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Beállítások</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Mindig fusson a háttérben</string>
<!--Preference summary in case it is enabled-->
@ -123,13 +122,11 @@
<string name="use_root_title">Syncthing futtatása Superuser-ként</string>
<string name="notification_type_title">Értesítés</string>
<string name="notification_type_summary">Értesítés típusának kiválasztása</string>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing beállításai</string>
<string name="category_syncthing_options">Syncthing beállításai</string>
<string name="device_name">Eszköz név</string>
<string name="global_announce_enabled">Globális felfedezés</string>
<string name="local_announce_enabled">Helyi felfedezés</string>
<string name="global_announce_server">Globális felfedező szerver</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="export_config">Beállítások mentése</string>
<!--Dialog shown before config export-->
<!--Dialog shown before config import-->

View file

@ -90,7 +90,6 @@
<!--Preference title-->
<!--Preference summary in case it is enabled-->
<!--Preference summary in case it is disabled-->
<string name="category_syncthing">Syncthing</string>
<!--Dialog shown before config export-->
<!--Dialog shown before config import-->
<!--Toast shown after config was successfully exported-->

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Impostazioni</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Sempre in background</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Bassa priorità</item>
<item>Nessuno</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Opzioni di Syncthing</string>
<string name="category_syncthing_options">Opzioni di Syncthing</string>
<string name="device_name">Nome Dispositivo</string>
<string name="listen_address">Indirizzi Protocollo Sincronizzazione</string>
<string name="max_recv_kbps">Limite Velocità in Ingresso (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Server Individuazione Globale</string>
<string name="enable_relaying">Abilita Reindirizzamento</string>
<string name="usage_reporting">Statistiche Anonime Utilizzo</string>
<string name="syncthing_gui">Interfaccia Grafica di Syncthing</string>
<string name="gui_address">Indirizzi Interfaccia Grafica</string>
<string name="gui_user">Utente Interfaccia Grafica</string>
<string name="gui_password">Password Autenticazione Utente</string>
<string name="export_config">Esporta Configurazione</string>
<string name="experimental_settings">Sperimentale</string>
<string name="category_experimental">Sperimentale</string>
<string name="keep_wakelock_while_binary_running">Mantieni attiva la CPU quando syncthing è in esecuzione</string>
<string name="keep_wakelock_while_binary_running_summary">Usa questa impostazione se rilevi disconnessioni inaspettate durante il funzionamento a batteria. Questo aumenterà il consumo della batteria.</string>
<string name="run_as_foreground_service">Esegui il servizio con la priorità di primo piano</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">設定</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">常にバックグラウンドで実行</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>優先度低</item>
<item>なし</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">同期オプション</string>
<string name="category_syncthing_options">同期オプション</string>
<string name="device_name">デバイス名</string>
<string name="listen_address">同期プロトコル リスンアドレス</string>
<string name="max_recv_kbps">着信レート制限 (KiB/秒)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">グローバル探索サーバー</string>
<string name="enable_relaying">リレーを有効にする</string>
<string name="usage_reporting">匿名使用状況レポート</string>
<string name="syncthing_gui">同期中 GUI</string>
<string name="gui_address">GUI リスンアドレス</string>
<string name="gui_user">GUI 認証ユーザー</string>
<string name="gui_password">GUI 認証パスワード</string>
<string name="export_config">設定をエクスポート</string>
<string name="experimental_settings">実験的</string>
<string name="category_experimental">実験的</string>
<string name="keep_wakelock_while_binary_running">Syncthing の実行中、CPU をオンのままにする</string>
<string name="keep_wakelock_while_binary_running_summary">バッテリーで動作しているときに予期しない接続の切断が発生した場合、この設定を使用します。これは、バッテリー消費を増やします。</string>
<string name="run_as_foreground_service">フォアグラウンドの優先度でサービスを実行する</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">설정</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">백그라운드에서 항상 실행</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>우선 순위 낮음</item>
<item>사용 안 함</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing 옵션 </string>
<string name="category_syncthing_options">Syncthing 옵션 </string>
<string name="device_name">기기명</string>
<string name="listen_address">동기화 프로토콜 수신 주소</string>
<string name="max_recv_kbps">다운로드 속도 제한 (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">글로벌 탐색 서버</string>
<string name="enable_relaying">Relaying 활성화</string>
<string name="usage_reporting">익명 사용 기록 </string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">접속 대기 주소</string>
<string name="gui_user">GUI 인증 사용자</string>
<string name="gui_password">GUI 인증 비밀번호</string>
<string name="export_config">설정 내보내기</string>
<string name="experimental_settings">실험적인 기능</string>
<string name="category_experimental">실험적인 기능</string>
<string name="keep_wakelock_while_binary_running">Syncthing이 실행 중일 때 CPU를 깨어 있는 상태로 두기</string>
<string name="keep_wakelock_while_binary_running_summary">만약 배터리로 사용중 예상하지 못한 접속 끊김이 발생 했다면 이 설정을 사용합니다. 이 기능은 배터리 소비를 늘립니다.</string>
<string name="run_as_foreground_service">서비스를 포그라운드로 실행</string>

View file

@ -128,7 +128,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Innstillinger</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Kjør alltid i bakgrunnen</string>
<!--Preference summary in case it is enabled-->
@ -150,8 +149,7 @@
<item>Lav prioritet</item>
<item>Ingen</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Valg for Syncthing</string>
<string name="category_syncthing_options">Valg for Syncthing</string>
<string name="device_name">Enhetsnavn</string>
<string name="listen_address">Lytteadresser for synkeprotokoll</string>
<string name="max_recv_kbps">Grense for innkommende trafikk (KiB/s)</string>
@ -162,12 +160,11 @@
<string name="global_announce_server">Global søketjener</string>
<string name="enable_relaying">Aktiver relésending</string>
<string name="usage_reporting">Anonym bruksrapportering</string>
<string name="syncthing_gui">Syncthing-GUI</string>
<string name="gui_address">GUI Lytteadresser</string>
<string name="gui_user">GUI Autentiseringsbruker</string>
<string name="gui_password">GUI Autentiseringspassord</string>
<string name="export_config">Eksporter innstillinger</string>
<string name="experimental_settings">Eksperimentelt</string>
<string name="category_experimental">Eksperimentelt</string>
<string name="keep_wakelock_while_binary_running">Hold prosessoren våken mens Syncthing kjører</string>
<string name="keep_wakelock_while_binary_running_summary">Bruk denne innstillingen dersom du opplever uventede frakoblinger mens enheten går på batteri. Dette vil medføre økt batteriforbruk.</string>
<string name="run_as_foreground_service">Kjør tjenesten med forgrunnsprioritet</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Instellingen</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Altijd draaien in achtergrond</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Lage prioriteit</item>
<item>Geen</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing-opties</string>
<string name="category_syncthing_options">Syncthing-opties</string>
<string name="device_name">Apparaatnaam</string>
<string name="listen_address">Synchronisatieprotocol luister-adressen</string>
<string name="max_recv_kbps">Inkomende snelheidslimiet (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Globale ontdekkingsserver</string>
<string name="enable_relaying">Relayen inschakelen</string>
<string name="usage_reporting">Anoniem gebruiksrapportage</string>
<string name="syncthing_gui">Syncthing-GUI</string>
<string name="gui_address">GUI luister-adressen</string>
<string name="gui_user">GUI-authenticatie gebruiker</string>
<string name="gui_password">GUI-authenticatie wachtwoord</string>
<string name="export_config">Configuratie exporteren</string>
<string name="experimental_settings">Experimenteel</string>
<string name="category_experimental">Experimenteel</string>
<string name="keep_wakelock_while_binary_running">Laat de CPU niet slapen wanneer Syncthing wordt uitgevoerd</string>
<string name="keep_wakelock_while_binary_running_summary">Gebruik deze instelling als je onverwacht losgekoppeld wordt wanneer je op batterij werkt. Dit zal leiden tot verhoogd batterijverbruik.</string>
<string name="run_as_foreground_service">Dienst uitvoeren met voorgrondprioriteit</string>

View file

@ -128,7 +128,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Innstillingar</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Køyr alltid i bakgrunnen</string>
<!--Preference summary in case it is enabled-->
@ -150,8 +149,7 @@
<item>Låg prioritet</item>
<item>Ingen</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing-innstillingar</string>
<string name="category_syncthing_options">Syncthing-innstillingar</string>
<string name="device_name">Einingsnamn</string>
<string name="listen_address">Lytteadresse for synkroniseringsprotokoll</string>
<string name="max_recv_kbps">Nedlastingsgrense (KiB/s)</string>
@ -162,12 +160,11 @@
<string name="global_announce_server">Tener for global søketeneste</string>
<string name="enable_relaying">Aktiver Reléer</string>
<string name="usage_reporting">Anonym rapportering av bruk</string>
<string name="syncthing_gui">Grafisk grensesnitt for Syncthing</string>
<string name="gui_address">Grensesnitt: lytteadresser</string>
<string name="gui_user">Grensesnitt: Brukarnamn</string>
<string name="gui_password">Grensesnitt: Passord</string>
<string name="export_config">Eksporter innstillingar</string>
<string name="experimental_settings">Eksperiment</string>
<string name="category_experimental">Eksperiment</string>
<string name="keep_wakelock_while_binary_running">Hald prosessoren vaken medan Syncthing køyrer</string>
<string name="keep_wakelock_while_binary_running_summary">Bruk denne innstillinga om du opplever uventa avkoplingar medan du køyrer på batteri. Dette vil føre til auka batteriforbruk.</string>
<string name="run_as_foreground_service">Køyr tenesten med forgrunnsprioritet</string>

View file

@ -66,7 +66,6 @@
<!--Preference title-->
<!--Preference summary in case it is enabled-->
<!--Preference summary in case it is disabled-->
<string name="category_syncthing">Syncthing</string>
<!--Toast shown after config was successfully exported-->
<!--Toast shown after config was successfully imported-->
<!--Toast shown after config was successfully imported-->

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Ustawienia</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Działanie w tle</string>
<!--Preference summary in case it is enabled-->
@ -146,8 +145,7 @@
<string name="use_root_title">Synchronizuje zawartość z uprawnieniami użytkownika Superuser</string>
<string name="notification_type_title">Powiadomienie</string>
<string name="notification_type_summary">Wybiera rodzaj powiadomienia</string>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Ustawienia Syncthing</string>
<string name="category_syncthing_options">Ustawienia Syncthing</string>
<string name="device_name">Nazwa urządzenia</string>
<string name="listen_address">Adres nasłuchiwania protokołu</string>
<string name="max_recv_kbps">Limit pobierania (KiB/s)</string>
@ -165,6 +163,7 @@
<string name="export_config">Eksportuj ustawienia</string>
<string name="experimental_settings">Eksperymentalne</string>
<string name="keep_wakelock_while_binary_running">Utrzymywanie wybudzonego CPU podczas działania</string>
<string name="category_experimental">Eksperymelne!</string>
<string name="keep_wakelock_while_binary_running_summary">Używaj, jeśli doświadczasz nieoczekiwanych rozłączeń w trakcie działania na baterii. Spowoduje to zwiększone jej zużycie.</string>
<string name="run_as_foreground_service">Pierwszoplanowy priorytet usługi</string>
<string name="use_tor_title">Korzystanie z Tor</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Configurações</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Sempre rodar em segundo plano</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Baixa prioridade</item>
<item>Nenhuma</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Opções do Syncthing</string>
<string name="category_syncthing_options">Opções do Syncthing</string>
<string name="device_name">Nome do dispositivo</string>
<string name="listen_address">Endereços de escuta do protocolo de sincronização</string>
<string name="max_recv_kbps">Limite de velocidade de recepção (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Descoberta global</string>
<string name="enable_relaying">Habilitar retransmissão</string>
<string name="usage_reporting">Relatório anônimo de uso</string>
<string name="syncthing_gui">Interface do Syncthing</string>
<string name="gui_address">Endereços de escuta da interface</string>
<string name="gui_user">Nome de usuário da interface</string>
<string name="gui_password">Senha da interface</string>
<string name="export_config">Exportar configuração</string>
<string name="experimental_settings">Configurações experimentais</string>
<string name="category_experimental">Configurações experimentais</string>
<string name="keep_wakelock_while_binary_running">Manter a CPU acordada</string>
<string name="keep_wakelock_while_binary_running_summary">Marque esta opção se você observar desconexões inesperadas enquanto a bateria do dispositivo não está sendo carregada. Isto resultará em maior uso da bateria.</string>
<string name="run_as_foreground_service">Rodar serviço com prioridade de primeiro plano</string>

View file

@ -121,7 +121,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Configurações</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Correr sempre em segundo plano</string>
<!--Preference summary in case it is enabled-->
@ -140,8 +139,7 @@
<item>Baixa prioridade</item>
<item>Nenhuma</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Opções do Syncthing</string>
<string name="category_syncthing_options">Opções do Syncthing</string>
<string name="device_name">Nome do dispositivo</string>
<string name="listen_address">Endereços de escuta do protocolo de sincronização</string>
<string name="max_recv_kbps">Limite de velocidade de recepção (KiB/s)</string>
@ -150,7 +148,6 @@
<string name="local_announce_enabled">Busca local</string>
<string name="global_announce_server">Servidor da busca global</string>
<string name="usage_reporting">Enviar relatórios anónimos de utilização</string>
<string name="syncthing_gui">Interface gráfica do Syncthing</string>
<string name="gui_address">Endereço de escuta da interface gráfica</string>
<string name="gui_user">Utilizador da autenticação na interface gráfica</string>
<string name="gui_password">Senha da autenticação na interface gráfica</string>

View file

@ -127,7 +127,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Настройки</string>
<string name="category_syncthing_android">Настройки приложения</string>
<!--Preference title-->
<string name="always_run_in_background">Фоновый режим</string>
<!--Preference summary in case it is enabled-->
@ -149,8 +148,7 @@
<item>Низкий</item>
<item>Никогда</item>
</string-array>
<string name="category_syncthing">Общие настройки Syncthing</string>
<string name="syncthing_options">Настройки устройства</string>
<string name="category_syncthing_options">Настройки устройства</string>
<string name="device_name">Имя устройства</string>
<string name="listen_address">Адрес Ожидания Протокола Синхронизации</string>
<string name="max_recv_kbps">Лимит Скачивания (КБ/с)</string>
@ -161,7 +159,6 @@
<string name="global_announce_server">Глобальный сервер обнаружения</string>
<string name="enable_relaying">Включить релеи</string>
<string name="usage_reporting">Анонимные Отчёты Использования</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">Адрес Ожидания GUI</string>
<string name="gui_user">Пользователь Идентификации GUI</string>
<string name="gui_password">Пароль Идентификации GUI</string>

View file

@ -120,7 +120,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Nastavenia</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Vždy bežať na pozadí</string>
<!--Preference summary in case it is enabled-->
@ -139,8 +138,7 @@
<item>S nízkou prioritou</item>
<item>Žiadne</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Nastavenia Syncthing</string>
<string name="category_syncthing_options">Nastavenia Syncthing</string>
<string name="device_name">Názov Zariadenia</string>
<string name="listen_address">Adresa pre Sync Protokol</string>
<string name="max_recv_kbps">Limit Rýchlosti Sťahovania (KiB/s)</string>
@ -149,7 +147,6 @@
<string name="local_announce_enabled">Lokálne Vyhľadávanie</string>
<string name="global_announce_server">Adresa Serveru pre Globálne Vyhľadávanie</string>
<string name="usage_reporting">Povoliť Anonymné Hlásenia o Používaní</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">Adresa pre GUI</string>
<string name="gui_user">Užívateľské Meno pre GUI</string>
<string name="gui_password">Užívateľské Heslo pre GUI</string>

View file

@ -134,7 +134,6 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Inställningar</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Körs alltid i bakgrunden</string>
<!--Preference summary in case it is enabled-->
@ -156,8 +155,7 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
<item>Låg prioritet</item>
<item>Ingen</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing alternativ</string>
<string name="category_syncthing_options">Syncthing alternativ</string>
<string name="device_name">Enhets namn</string>
<string name="listen_address">Lyssnaradresser för synkroniseringsprotokoll</string>
<string name="max_recv_kbps">Inkommande hastighetsbegränsning (KiB/s)</string>
@ -168,12 +166,11 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
<string name="global_announce_server">Global upptäktsserver</string>
<string name="enable_relaying">Aktivera reläa</string>
<string name="usage_reporting">Anonym användningsrapportering</string>
<string name="syncthing_gui">Syncting-GUI</string>
<string name="gui_address">Lyssnaradresser för GUI</string>
<string name="gui_user">GUI autentiseringsanvändare</string>
<string name="gui_password">GUI autentiseringslösenord</string>
<string name="export_config">Exportera konfiguration</string>
<string name="experimental_settings">Experimentell</string>
<string name="category_experimental">Experimentell</string>
<string name="keep_wakelock_while_binary_running">Håll CPU vaken medan Syncthing körs</string>
<string name="keep_wakelock_while_binary_running_summary">Använd den här inställningen om du får oväntade frånkopplingar under batteridrift. Detta kommer att resultera i ökad batteriförbrukning .</string>
<string name="run_as_foreground_service">Kör tjänst med förgrundsprioritet</string>

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Inställningar</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Körs alltid i bakgrunden</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>Låg prioritet</item>
<item>Ingen</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing alternativ</string>
<string name="category_syncthing_options">Syncthing alternativ</string>
<string name="device_name">Enhets namn</string>
<string name="listen_address">Synkroniseringsprotokollets lyssnaradresser</string>
<string name="max_recv_kbps">Inkommande hastighetsgräns (KiB/s)</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">Global upptäktsserver</string>
<string name="enable_relaying">Aktivera reläa</string>
<string name="usage_reporting">Anonym användningsrapportering</string>
<string name="syncthing_gui">Syncthing-GUI</string>
<string name="gui_address">GUI lyssnaradresser</string>
<string name="gui_user">GUI autentiseringsanvändare</string>
<string name="gui_password">GUI autentiseringslösenord</string>
<string name="export_config">Exportera konfiguration</string>
<string name="experimental_settings">Experimentell</string>
<string name="category_experimental">Experimentell</string>
<string name="keep_wakelock_while_binary_running">Håll CPU:n vaken medan Syncthing körs</string>
<string name="keep_wakelock_while_binary_running_summary">Använd den här inställningen om du får oväntade frånkopplingar under batteridrift. Detta kommer att resultera i ökad batteriförbrukning.</string>
<string name="run_as_foreground_service">Kör tjänst med förgrundsprioritet</string>

View file

@ -121,7 +121,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Ayarlar</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Arkaplanda herzaman çalış</string>
<!--Preference summary in case it is enabled-->
@ -142,8 +141,7 @@
<item>Düşük Öncelikli</item>
<item>Hiçbiri</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing Seçenekler</string>
<string name="category_syncthing_options">Syncthing Seçenekler</string>
<string name="device_name">Cihaz Adı</string>
<string name="listen_address">Eşzamanlama Protokolü Dinleme/Bağlanma Adresleri</string>
<string name="max_recv_kbps">Gelen Hız Sınırı (KiB/s)</string>
@ -152,7 +150,6 @@
<string name="local_announce_enabled">Yerel Bulunabilirlik</string>
<string name="global_announce_server">Küresel Bulunabilirlik Sunucusu</string>
<string name="usage_reporting">Anonim olarak Kullanım Raporlama</string>
<string name="syncthing_gui">Syncthing Arayüzü</string>
<string name="gui_address">Arayüz Dinleme Adresleri</string>
<string name="gui_user">Arayüz Kullanıcı Doğrulaması için Kullanıcı Adı</string>
<string name="gui_password">Arayüz Kullanıcı Doğrulaması için Kullanıcı Parolası</string>

View file

@ -126,7 +126,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">Cài đặt</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<!--Preference title-->
<string name="always_run_in_background">Luôn chạy nền</string>
<!--Preference summary in case it is enabled-->
@ -147,8 +146,7 @@
<item>Ưu tiên thấp</item>
<item>Không thông báo</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Tuỳ chọn Syncthing</string>
<string name="category_syncthing_options">Tuỳ chọn Syncthing</string>
<string name="device_name">Tên thiết bị</string>
<string name="listen_address">Đồng bộ các đ.chỉ lắng nghe giao thức</string>
<string name="max_recv_kbps">Giới hạn t.độ đầu vào (KiB/s)</string>
@ -157,12 +155,11 @@
<string name="local_announce_enabled">Dò tìm cục bộ</string>
<string name="global_announce_server">Máy chủ dò tìm toàn cầu</string>
<string name="usage_reporting">Báo cáo sử dụng ẩn danh</string>
<string name="syncthing_gui">GUI Syncthing</string>
<string name="gui_address">Các đ.chỉ lắng nghe GUI</string>
<string name="gui_user">Người dùng xác thực GUI</string>
<string name="gui_password">Mật khẩu xác thực GUI</string>
<string name="export_config">Xuất cấu hình</string>
<string name="experimental_settings">Thực nghiệm</string>
<string name="category_experimental">Thực nghiệm</string>
<string name="keep_wakelock_while_binary_running">Giữ CPU thức khi Syncthing đang chạy</string>
<string name="keep_wakelock_while_binary_running_summary">Dùng tuỳ chỉnh này nếu bạn bị mất kết nối bất ngờ khi đang dùng pin. Nó sẽ tiêu thụ nhiều pin hơn.</string>
<!--Dialog shown before config export-->

View file

@ -130,7 +130,6 @@
<!--SettingsFragment-->
<!--Activity title-->
<string name="settings_title">设置</string>
<string name="category_syncthing_android">Android 版 Syncthing 功能</string>
<!--Preference title-->
<string name="always_run_in_background">总是在后台运行</string>
<!--Preference summary in case it is enabled-->
@ -152,8 +151,7 @@
<item>低优先级</item>
<item>隐藏</item>
</string-array>
<string name="category_syncthing">Syncthing 通用功能</string>
<string name="syncthing_options">同步设置</string>
<string name="category_syncthing_options">同步设置</string>
<string name="device_name">设备名称</string>
<string name="listen_address">同步协议监听地址</string>
<string name="max_recv_kbps">下载限速KiB/s</string>
@ -164,12 +162,11 @@
<string name="global_announce_server">用以在互联网上寻找节点的发布服务器地址</string>
<string name="enable_relaying">启用中继</string>
<string name="usage_reporting">匿名使用报告</string>
<string name="syncthing_gui">Syncthing 管理页</string>
<string name="gui_address">管理页监听地址</string>
<string name="gui_user">管理页认证用户</string>
<string name="gui_password">管理页认证密码</string>
<string name="export_config">导出设置</string>
<string name="experimental_settings">实验性</string>
<string name="category_experimental">实验性</string>
<string name="keep_wakelock_while_binary_running">当 Syncthing 正在运行时保持 CPU 唤醒</string>
<string name="keep_wakelock_while_binary_running_summary">使用此设置如果您在电池上运行时遇到意外的断开连接。这将会导致电量消耗的增加。</string>
<string name="run_as_foreground_service">以前台优先级运行服务</string>

View file

@ -113,14 +113,12 @@
<string name="sync_only_charging">只在充電時同步</string>
<string name="sync_only_wifi">只透過 Wi-Fi 網路同步</string>
<string name="advanced_folder_picker">使用進階的資料夾選擇器</string>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing 選項</string>
<string name="category_syncthing_options">Syncthing 選項</string>
<string name="listen_address">同步通訊協定監聽位址</string>
<string name="max_recv_kbps">下載速率限制(KiB/s)</string>
<string name="max_send_kbps">上傳速率限制(KiB/s)</string>
<string name="global_announce_enabled">全域探索</string>
<string name="local_announce_enabled">本地探索</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">GUI 監聽位址</string>
<string name="gui_user">GUI 認證使用者名稱</string>
<string name="gui_password">GUI 認證密碼</string>

View file

@ -217,12 +217,15 @@ Please report any problems you encounter via Github.</string>
<!-- SettingsFragment -->
<!-- Activity title -->
<string name="settings_title">Settings</string>
<string name="category_syncthing_android">Syncthing-Android</string>
<string name="category_run_conditions">Run Conditions</string>
<string name="category_behaviour">Behaviour</string>
<string name="category_syncthing_options">Syncthing Options</string>
<string name="category_backup">Backup</string>
<string name="category_debug">Debug</string>
<string name="category_experimental">Experimental</string>
<!-- Preference title -->
<string name="always_run_in_background">Always run in background</string>
<!-- Preference summary in case it is enabled -->
@ -257,10 +260,6 @@ Please report any problems you encounter via Github.</string>
<item>None</item>
</string-array>
<string name="category_syncthing">Syncthing</string>
<string name="syncthing_options">Syncthing Options</string>
<string name="device_name">Device Name</string>
<string name="listen_address">Sync Protocol Listen Addresses</string>
@ -275,14 +274,12 @@ Please report any problems you encounter via Github.</string>
<string name="enable_nat_traversal">Enable NAT Traversal</string>
<string name="global_announce_server">Global Discovery Server</string>
<string name="global_announce_server">Global Discovery Servers</string>
<string name="enable_relaying">Enable Relaying</string>
<string name="usage_reporting">Anonymous Usage Reporting</string>
<string name="syncthing_gui">Syncthing GUI</string>
<string name="gui_address">GUI Listen Addresses</string>
<string name="gui_user">GUI Authentication User</string>
@ -291,8 +288,6 @@ Please report any problems you encounter via Github.</string>
<string name="export_config">Export Configuration</string>
<string name="experimental_settings">Experimental</string>
<string name="keep_wakelock_while_binary_running">Keep the CPU awake while Syncthing is running</string>
<string name="keep_wakelock_while_binary_running_summary">Use this setting if you experience unexpected disconnects while operating on battery. This will result in increased battery consumption.</string>

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/category_syncthing_android">
<PreferenceScreen
android:title="@string/category_run_conditions"
android:key="category_run_conditions">
<CheckBoxPreference
android:key="always_run_in_background"
@ -23,6 +24,11 @@
android:key="sync_only_wifi_ssids_set"
android:title="@string/sync_only_wifi_ssids" />
</PreferenceScreen>
<PreferenceScreen
android:title="@string/category_behaviour">
<CheckBoxPreference
android:key="advanced_folder_picker"
android:title="@string/advanced_folder_picker"
@ -37,96 +43,90 @@
android:summary="@string/notification_type_summary"
android:defaultValue="low_priority" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceCategory
android:title="@string/category_syncthing">
<PreferenceScreen
android:key="category_syncthing_options"
android:title="@string/category_syncthing_options">
<PreferenceScreen
android:key="syncthing_options"
android:title="@string/syncthing_options">
<EditTextPreference
android:key="deviceName"
android:title="@string/device_name"
android:persistent="false"
android:inputType="textCapWords" />
<EditTextPreference
android:key="deviceName"
android:title="@string/device_name"
android:persistent="false"
android:inputType="textCapWords" />
<EditTextPreference
android:key="listenAddresses"
android:title="@string/listen_address"
android:persistent="false"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="listenAddresses"
android:title="@string/listen_address"
android:persistent="false"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="maxRecvKbps"
android:title="@string/max_recv_kbps"
android:numeric="integer"
android:persistent="false"
android:inputType="number" />
<EditTextPreference
android:key="maxRecvKbps"
android:title="@string/max_recv_kbps"
android:numeric="integer"
android:persistent="false"
android:inputType="number" />
<EditTextPreference
android:key="maxSendKbps"
android:title="@string/max_send_kbps"
android:numeric="integer"
android:persistent="false"
android:inputType="number" />
<EditTextPreference
android:key="maxSendKbps"
android:title="@string/max_send_kbps"
android:numeric="integer"
android:persistent="false"
android:inputType="number" />
<CheckBoxPreference
android:key="natEnabled"
android:title="@string/enable_nat_traversal"
android:persistent="false"/>
<CheckBoxPreference
android:key="globalAnnounceEnabled"
android:title="@string/global_announce_enabled"
android:persistent="false" />
<CheckBoxPreference
android:key="localAnnounceEnabled"
android:title="@string/local_announce_enabled"
android:persistent="false" />
<CheckBoxPreference
android:key="localAnnounceEnabled"
android:title="@string/local_announce_enabled"
android:persistent="false" />
<CheckBoxPreference
android:key="globalAnnounceEnabled"
android:title="@string/global_announce_enabled"
android:persistent="false" />
<CheckBoxPreference
android:key="natEnabled"
android:title="@string/enable_nat_traversal"
android:persistent="false"/>
<CheckBoxPreference
android:key="relaysEnabled"
android:title="@string/enable_relaying"
android:persistent="false" />
<EditTextPreference
android:key="globalAnnounceServers"
android:title="@string/global_announce_server"
android:persistent="false"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="globalAnnounceServers"
android:title="@string/global_announce_server"
android:persistent="false"
android:inputType="textNoSuggestions" />
<CheckBoxPreference
android:key="relaysEnabled"
android:title="@string/enable_relaying"
android:persistent="false" />
<EditTextPreference
android:key="address"
android:title="@string/gui_address"
android:persistent="false"
android:inputType="textNoSuggestions" />
<CheckBoxPreference
android:key="urAccepted"
android:title="@string/usage_reporting"
android:persistent="false" />
<EditTextPreference
android:key="user"
android:title="@string/gui_user"
android:inputType="textCapWords"
android:persistent="false" />
</PreferenceScreen>
<EditTextPreference
android:key="password"
android:title="@string/gui_password"
android:inputType="textVisiblePassword" />
<PreferenceScreen
android:key="syncthing_gui"
android:title="@string/syncthing_gui">
<CheckBoxPreference
android:key="urAccepted"
android:title="@string/usage_reporting"
android:persistent="false" />
<EditTextPreference
android:key="address"
android:title="@string/gui_address"
android:persistent="false"
android:inputType="textNoSuggestions" />
</PreferenceScreen>
<EditTextPreference
android:key="user"
android:title="@string/gui_user"
android:inputType="textCapWords"
android:persistent="false" />
<EditTextPreference
android:key="web_gui_password"
android:title="@string/gui_password"
android:inputType="textVisiblePassword" />
</PreferenceScreen>
<PreferenceScreen
android:title="@string/category_backup">
<Preference
android:key="export_config"
@ -136,6 +136,18 @@
android:key="import_config"
android:title="@string/import_config" />
</PreferenceScreen>
<PreferenceScreen
android:title="@string/category_debug">
<Preference
android:title="@string/open_log"
android:summary="@string/open_log_summary">
<intent
android:action=".activities.LogActivity" />
</Preference>
<EditTextPreference
android:key="sttrace"
android:title="@string/sttrace_title"
@ -147,47 +159,40 @@
android:title="@string/streset_title"
android:singleLine="true" />
<PreferenceScreen
android:key="syncthing_experimental"
android:title="@string/experimental_settings">
</PreferenceScreen>
<CheckBoxPreference
android:key="use_root"
android:title="@string/use_root_title"
android:summary="@string/use_root_summary"
android:defaultValue="false" />
<PreferenceScreen
android:title="@string/category_experimental"
android:key="category_experimental">
<CheckBoxPreference
android:key="wakelock_while_binary_running"
android:title="@string/keep_wakelock_while_binary_running"
android:summary="@string/keep_wakelock_while_binary_running_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="use_root"
android:title="@string/use_root_title"
android:summary="@string/use_root_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="run_as_foreground_service"
android:title="@string/run_as_foreground_service"
android:summary="@string/run_as_foreground_service_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="wakelock_while_binary_running"
android:title="@string/keep_wakelock_while_binary_running"
android:summary="@string/keep_wakelock_while_binary_running_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="use_tor"
android:title="@string/use_tor_title"
android:summary="@string/use_tor_summary" />
<CheckBoxPreference
android:key="run_as_foreground_service"
android:title="@string/run_as_foreground_service"
android:summary="@string/run_as_foreground_service_summary"
android:defaultValue="false" />
</PreferenceScreen>
<CheckBoxPreference
android:key="use_tor"
android:title="@string/use_tor_title"
android:summary="@string/use_tor_summary" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceCategory
<PreferenceScreen
android:title="@string/category_about">
<Preference
android:title="@string/open_log"
android:summary="@string/open_log_summary">
<intent
android:action=".activities.LogActivity" />
</Preference>
<Preference
android:title="@string/report_issue_title"
android:summary="@string/report_issue_summary">
@ -214,6 +219,6 @@
android:title="@string/app_version_title"
style="?android:preferenceInformationStyle" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>