mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 00:01:19 +00:00
Moved method into SettingsFragment.
This commit is contained in:
parent
5239e57d5c
commit
4b7c299cd2
2 changed files with 20 additions and 27 deletions
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue