Fix re-enabling the loop plugin from overview. Fixes #861.
Note that enabling a loop plugin is hardcoded against the only impl currently available LoopPlugin. Support for multiple loop plugins is incomplete (and not needed at this point), since there's no LoopInterface, but immediately LoopPlugin (as compared to APSInterface with OpenAPS* impls). When adding support, the last activated loop plugin must be remembered so the correct one is re-enabled.
This commit is contained in:
parent
e9ac979a1b
commit
80be7fb586
2 changed files with 12 additions and 9 deletions
|
@ -264,6 +264,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
return activeAPS;
|
return activeAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static LoopPlugin getActiveLoop() {
|
public static LoopPlugin getActiveLoop() {
|
||||||
return activeLoop;
|
return activeLoop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,10 +459,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (v == apsModeView) {
|
if (v == apsModeView) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
if (!MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||||
return;
|
return;
|
||||||
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||||
if (activeloop.isEnabled(PluginType.LOOP)) {
|
if (activeloop == null) {
|
||||||
|
menu.add(MainApp.gs(R.string.enableloop));
|
||||||
|
} else {
|
||||||
menu.add(MainApp.gs(R.string.disableloop));
|
menu.add(MainApp.gs(R.string.disableloop));
|
||||||
if (!activeloop.isSuspended()) {
|
if (!activeloop.isSuspended()) {
|
||||||
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
||||||
|
@ -480,8 +482,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
menu.add(MainApp.gs(R.string.resume));
|
menu.add(MainApp.gs(R.string.resume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!activeloop.isEnabled(PluginType.LOOP))
|
|
||||||
menu.add(MainApp.gs(R.string.enableloop));
|
|
||||||
} else if (v == activeProfileView) {
|
} else if (v == activeProfileView) {
|
||||||
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
||||||
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
||||||
|
@ -496,13 +496,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return true;
|
return true;
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
|
||||||
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||||
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
||||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -513,16 +513,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||||
|
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
||||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
||||||
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
activeloop.suspendTo(0L);
|
activeloop.suspendTo(0L);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
Loading…
Reference in a new issue