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

Moved method into SettingsFragment.

This commit is contained in:
Felix Ableitner 2015-11-16 13:11:47 +01:00
parent 5239e57d5c
commit 4b7c299cd2
2 changed files with 20 additions and 27 deletions

View file

@ -2,6 +2,7 @@ package com.nutomic.syncthingandroid.fragments;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
@ -358,7 +359,25 @@ public class SettingsFragment extends PreferenceFragment
.show();
return true;
case SYNCTHING_RESET:
((SyncthingActivity) getActivity()).getApi().resetSyncthing(getActivity());
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, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getActivity().startService(intent);
Toast.makeText(getActivity(), R.string.streset_done, Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.show();
return true;
default:
return false;

View file

@ -359,32 +359,6 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
activity.startActivity(new Intent(mContext, RestartActivity.class));
}
/**
* Reset Syncthing's indexes when confirmed by a dialog.
*
* TODO: why is this here and not in fragment?
*/
public void resetSyncthing(final Activity activity) {
final Intent intent = new Intent(mContext, SyncthingService.class)
.setAction(SyncthingService.ACTION_RESET);
new AlertDialog.Builder(activity)
.setTitle(R.string.streset_title)
.setMessage(R.string.streset_question)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mContext.startService(intent);
Toast.makeText(activity, R.string.streset_done, Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) { }
})
.show();
}
/**
* Returns a list of all existing devices.
*