Initial implementation 2

This commit is contained in:
triplem 2018-11-04 18:51:24 +01:00
parent 43fcfaf5d6
commit c4bbb62d0b

View file

@ -446,7 +446,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
super.onCreateContextMenu(menu, v, menuInfo); super.onCreateContextMenu(menu, v, menuInfo);
if (v == apsModeView) { if (v == apsModeView) {
final LoopPlugin loopPlugin = LoopPlugin.getPlugin(); final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
final PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription(); final PumpDescription pumpDescription =
ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
if (!ProfileFunctions.getInstance().isProfileValid("ContexMenuCreation")) if (!ProfileFunctions.getInstance().isProfileValid("ContexMenuCreation"))
return; return;
menu.setHeaderTitle(MainApp.gs(R.string.loop)); menu.setHeaderTitle(MainApp.gs(R.string.loop));
@ -457,21 +458,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
menu.add(MainApp.gs(R.string.suspendloopfor2h)); menu.add(MainApp.gs(R.string.suspendloopfor2h));
menu.add(MainApp.gs(R.string.suspendloopfor3h)); menu.add(MainApp.gs(R.string.suspendloopfor3h));
menu.add(MainApp.gs(R.string.suspendloopfor10h)); menu.add(MainApp.gs(R.string.suspendloopfor10h));
if (pumpDescription.tempDurationStep15mAllowed) } else {
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
if (pumpDescription.tempDurationStep30mAllowed)
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
} else {
menu.add(MainApp.gs(R.string.resume)); menu.add(MainApp.gs(R.string.resume));
} }
} }
if (!loopPlugin.isEnabled(PluginType.LOOP)) if (!loopPlugin.isEnabled(PluginType.LOOP))
menu.add(MainApp.gs(R.string.enableloop)); menu.add(MainApp.gs(R.string.enableloop));
// menu-items visible even if loop is disabled (#1449) if (!ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended()) {
menu.add(MainApp.gs(R.string.disconnectpumpfor1h)); showSuspendtPump(menu, pumpDescription);
menu.add(MainApp.gs(R.string.disconnectpumpfor2h)); }
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
} else if (v == activeProfileView) { } else if (v == activeProfileView) {
menu.setHeaderTitle(MainApp.gs(R.string.profile)); menu.setHeaderTitle(MainApp.gs(R.string.profile));
@ -491,6 +487,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
} }
private void showSuspendtPump(ContextMenu menu,
PumpDescription pumpDescription) {
if (pumpDescription.tempDurationStep15mAllowed)
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
if (pumpDescription.tempDurationStep30mAllowed)
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
menu.add(MainApp.gs(R.string.disconnectpumpfor1h));
menu.add(MainApp.gs(R.string.disconnectpumpfor2h));
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
}
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
final Profile profile = ProfileFunctions.getInstance().getProfile(); final Profile profile = ProfileFunctions.getInstance().getProfile();