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

Show confirm dialog before config import/export (fixes #456).

This commit is contained in:
Felix Ableitner 2015-09-11 17:24:56 +02:00
parent 82ccd340bf
commit 3986198fa4
2 changed files with 42 additions and 11 deletions

View file

@ -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:
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,
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,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mSyncthingService.importConfig()) {
Toast.makeText(getActivity(), getString(R.string.config_imported_successful),
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,
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());

View file

@ -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 -->