diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java index 65d095c75f..88e4f6eb13 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java @@ -2,6 +2,9 @@ package info.nightscout.androidaps.plugins.NSClientInternal; import android.app.Activity; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; import android.graphics.Paint; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -106,7 +109,19 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase, getPlugin().clearLog(); break; case R.id.nsclientinternal_clearqueue: - getPlugin().queue().clearQueue(); + final Context context = getContext(); + AlertDialog.Builder builder = new AlertDialog.Builder(context); + + builder.setTitle(this.getContext().getString(R.string.confirmation)); + builder.setMessage("Clear queue? All data in queue will be lost!"); + builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + getPlugin().queue().clearQueue(); + updateGUI(); + } + }); + builder.setNegativeButton(getString(R.string.cancel), null); + builder.show(); break; case R.id.nsclientinternal_showqueue: MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList())); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java index 46830deadc..1849bf7149 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java @@ -156,12 +156,6 @@ public class NSClientInternalPlugin implements PluginBase { log.debug(ev.action + " " + ev.logText); } - @Subscribe - public void onStatusEvent(final EventNSClientRestart ev) { - if (nsClientService != null) - nsClientService.restart(); - } - @Subscribe public void onStatusEvent(final EventNSClientStatus ev) { status = ev.status; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 7cdab59fca..c109873faa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog; +import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; @@ -173,6 +174,12 @@ public class NSClientService extends Service { } } + @Subscribe + public void onStatusEvent(final EventNSClientRestart ev) { + latestDateInReceivedData = 0; + restart(); + } + public static void setNsProfile(NSProfile profile) { nsProfile = profile; }