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:
parent
82ccd340bf
commit
3986198fa4
2 changed files with 42 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
||||||
package com.nutomic.syncthingandroid.fragments;
|
package com.nutomic.syncthingandroid.fragments;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -308,19 +310,42 @@ public class SettingsFragment extends PreferenceFragment
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
switch (preference.getKey()) {
|
switch (preference.getKey()) {
|
||||||
case EXPORT_CONFIG:
|
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();
|
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();
|
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.show();
|
||||||
return true;
|
return true;
|
||||||
case IMPORT_CONFIG:
|
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()) {
|
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();
|
Toast.LENGTH_SHORT).show();
|
||||||
mSyncthingService.getApi().requireRestart(getActivity(), false);
|
mSyncthingService.getApi().requireRestart(getActivity(), false);
|
||||||
} else {
|
} 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();
|
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.show();
|
||||||
return true;
|
return true;
|
||||||
case SYNCTHING_RESET:
|
case SYNCTHING_RESET:
|
||||||
((SyncthingActivity) getActivity()).getApi().resetSyncthing(getActivity());
|
((SyncthingActivity) getActivity()).getApi().resetSyncthing(getActivity());
|
||||||
|
|
|
@ -136,6 +136,12 @@
|
||||||
<!-- Toast shown when selecting 'devices' if no devices have been added -->
|
<!-- Toast shown when selecting 'devices' if no devices have been added -->
|
||||||
<string name="no_devices">Please connect a device first.</string>
|
<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 -->
|
<!-- DeviceSettingsFragment -->
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue