mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Show confirm dialog before config import/export (fixes #456).
This commit is contained in:
parent
82ccd340bf
commit
3986198fa4
2 changed files with 42 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
|||
package com.nutomic.syncthingandroid.fragments;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -308,19 +310,42 @@ public class SettingsFragment extends PreferenceFragment
|
|||
public boolean onPreferenceClick(Preference preference) {
|
||||
switch (preference.getKey()) {
|
||||
case EXPORT_CONFIG:
|
||||
mSyncthingService.exportConfig();
|
||||
Toast.makeText(getActivity(), getString(R.string.config_export_successful,
|
||||
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.dialog_confirm_export)
|
||||
.setPositiveButton(android.R.string.yes,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int 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:
|
||||
if (mSyncthingService.importConfig()) {
|
||||
Toast.makeText(getActivity(), getString(R.string.config_imported_successful),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mSyncthingService.getApi().requireRestart(getActivity(), false);
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.config_import_failed,
|
||||
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.dialog_confirm_import)
|
||||
.setPositiveButton(android.R.string.yes,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (mSyncthingService.importConfig()) {
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.config_imported_successful),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mSyncthingService.getApi().requireRestart(getActivity(), false);
|
||||
} 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:
|
||||
((SyncthingActivity) getActivity()).getApi().resetSyncthing(getActivity());
|
||||
|
|
|
@ -136,6 +136,12 @@
|
|||
<!-- Toast shown when selecting 'devices' if no devices have been added -->
|
||||
<string name="no_devices">Please connect a device first.</string>
|
||||
|
||||
<!-- Dialog shown before config export -->
|
||||
<string name="dialog_confirm_export">Do you really want to export your configuration? Existing files will be overwritten.</string>
|
||||
|
||||
<!-- Dialog shown before config import -->
|
||||
<string name="dialog_confirm_import">Do you really want to import a new configuration? Existing files will be overwritten.</string>
|
||||
|
||||
<!-- DeviceSettingsFragment -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue