mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
This commit is contained in:
parent
765bc4a984
commit
6ead66b359
4 changed files with 58 additions and 16 deletions
|
@ -81,6 +81,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
private static final String TAG = "SettingsFragment";
|
||||
private static final String KEY_EXPORT_CONFIG = "export_config";
|
||||
private static final String KEY_IMPORT_CONFIG = "import_config";
|
||||
private static final String KEY_UNDO_IGNORED_DEVICES_FOLDERS = "undo_ignored_devices_folders";
|
||||
private static final String KEY_ST_RESET_DATABASE = "st_reset_database";
|
||||
private static final String KEY_ST_RESET_DELTAS = "st_reset_deltas";
|
||||
|
||||
|
@ -123,7 +124,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
private Options mOptions;
|
||||
private Config.Gui mGui;
|
||||
|
||||
private Boolean mRequireRestart = false;
|
||||
private Boolean mPendingConfig = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -193,6 +194,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
Preference exportConfig = findPreference("export_config");
|
||||
Preference importConfig = findPreference("import_config");
|
||||
|
||||
Preference undoIgnoredDevicesFolders = findPreference(KEY_UNDO_IGNORED_DEVICES_FOLDERS);
|
||||
Preference debugFacilitiesEnabled = findPreference(Constants.PREF_DEBUG_FACILITIES_ENABLED);
|
||||
Preference environmentVariables = findPreference("environment_variables");
|
||||
Preference stResetDatabase = findPreference("st_reset_database");
|
||||
|
@ -216,6 +218,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
exportConfig.setOnPreferenceClickListener(this);
|
||||
importConfig.setOnPreferenceClickListener(this);
|
||||
|
||||
undoIgnoredDevicesFolders.setOnPreferenceClickListener(this);
|
||||
debugFacilitiesEnabled.setOnPreferenceChangeListener(this);
|
||||
environmentVariables.setOnPreferenceChangeListener(this);
|
||||
stResetDatabase.setOnPreferenceClickListener(this);
|
||||
|
@ -369,17 +372,17 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
}
|
||||
|
||||
mApi.editSettings(mGui, mOptions);
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
if (mRequireRestart) {
|
||||
if (mPendingConfig) {
|
||||
if (mSyncthingService != null && mApi != null &&
|
||||
mSyncthingService.getCurrentState() != SyncthingService.State.DISABLED) {
|
||||
mApi.saveConfigAndRestart();
|
||||
mRequireRestart = false;
|
||||
mPendingConfig = false;
|
||||
}
|
||||
}
|
||||
super.onStop();
|
||||
|
@ -410,11 +413,11 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
mSyncOnlyOnSSIDs.setEnabled((Boolean) o);
|
||||
break;
|
||||
case Constants.PREF_DEBUG_FACILITIES_ENABLED:
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
break;
|
||||
case Constants.PREF_ENVIRONMENT_VARIABLES:
|
||||
if (((String) o).matches("^(\\w+=[\\w:/\\.]+)?( \\w+=[\\w:/\\.]+)*$")) {
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
}
|
||||
else {
|
||||
Toast.makeText(getActivity(), R.string.toast_invalid_environment_variables, Toast.LENGTH_SHORT)
|
||||
|
@ -423,18 +426,18 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
}
|
||||
break;
|
||||
case Constants.PREF_USE_WAKE_LOCK:
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
break;
|
||||
case Constants.PREF_USE_TOR:
|
||||
mSocksProxyAddress.setEnabled(!(Boolean) o);
|
||||
mHttpProxyAddress.setEnabled(!(Boolean) o);
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
break;
|
||||
case Constants.PREF_SOCKS_PROXY_ADDRESS:
|
||||
if (o.toString().trim().equals(mPreferences.getString(Constants.PREF_SOCKS_PROXY_ADDRESS, "")))
|
||||
return false;
|
||||
if (handleSocksProxyPreferenceChange(preference, o.toString().trim())) {
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -443,7 +446,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
if (o.toString().trim().equals(mPreferences.getString(Constants.PREF_HTTP_PROXY_ADDRESS, "")))
|
||||
return false;
|
||||
if (handleHttpProxyPreferenceChange(preference, o.toString().trim())) {
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -464,7 +467,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
new TestRootTask(this).execute();
|
||||
} else {
|
||||
new Thread(() -> Util.fixAppDataPermissions(getActivity())).start();
|
||||
mRequireRestart = true;
|
||||
mPendingConfig = true;
|
||||
}
|
||||
return true;
|
||||
case KEY_EXPORT_CONFIG:
|
||||
|
@ -498,6 +501,25 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
case KEY_UNDO_IGNORED_DEVICES_FOLDERS:
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.undo_ignored_devices_folders_question)
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
if (mApi == null) {
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.generic_error) + getString(R.string.syncthing_disabled_title),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
mApi.undoIgnoredDevicesAndFolders();
|
||||
mPendingConfig = true;
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.undo_ignored_devices_folders_done),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
case KEY_ST_RESET_DATABASE:
|
||||
intent = new Intent(getActivity(), SyncthingService.class)
|
||||
.setAction(SyncthingService.ACTION_RESET_DATABASE);
|
||||
|
@ -571,7 +593,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
return;
|
||||
}
|
||||
if (haveRoot) {
|
||||
settingsFragment.mRequireRestart = true;
|
||||
settingsFragment.mPendingConfig = true;
|
||||
settingsFragment.mUseRoot.setChecked(true);
|
||||
} else {
|
||||
Toast.makeText(settingsFragment.getActivity(), R.string.toast_root_denied, Toast.LENGTH_SHORT)
|
||||
|
|
|
@ -269,6 +269,15 @@ public class RestApi {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo ignoring devices and folders.
|
||||
*/
|
||||
public void undoIgnoredDevicesAndFolders() {
|
||||
Log.d(TAG, "Undo ignoring devices and folders ...");
|
||||
mConfig.ignoredDevices.clear();
|
||||
mConfig.ignoredFolders.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override folder changes. This is the same as hitting
|
||||
* the "override changes" button from the web UI.
|
||||
|
|
|
@ -20,6 +20,7 @@ Please report any problems you encounter via Github.</string>
|
|||
|
||||
<!-- Generic texts used everywhere -->
|
||||
<string name="generic_example">Example</string>
|
||||
<string name="generic_error">Error</string>
|
||||
|
||||
<string name="accept">Accept</string>
|
||||
|
||||
|
@ -375,6 +376,11 @@ Please report any problems you encounter via Github.</string>
|
|||
|
||||
<string name="gui_address">GUI Listen Addresses</string>
|
||||
|
||||
<!-- Titles for the preference to undo ignored devices and folders -->
|
||||
<string name="undo_ignored_devices_folders_title">Undo ignoring devices and folders</string>
|
||||
<string name="undo_ignored_devices_folders_question">This will undo previous decisions to ignore devices and folders. Continue?</string>
|
||||
<string name="undo_ignored_devices_folders_done">Successfully undone decisions.</string>
|
||||
|
||||
<string name="export_config">Export Configuration</string>
|
||||
|
||||
<!-- Toast after entering invalid integer value -->
|
||||
|
|
|
@ -136,6 +136,11 @@
|
|||
android:title="@string/usage_reporting"
|
||||
android:persistent="false" />
|
||||
|
||||
<Preference
|
||||
android:key="undo_ignored_devices_folders"
|
||||
android:title="@string/undo_ignored_devices_folders_title"
|
||||
android:singleLine="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
|
Loading…
Reference in a new issue