SW pump screen
This commit is contained in:
parent
ed43eddc83
commit
bacb3fb337
|
@ -15,6 +15,8 @@ public class SWButton extends SWItem {
|
|||
int buttonText;
|
||||
SWValidator buttonValidator;
|
||||
|
||||
Button button;
|
||||
|
||||
public SWButton() {
|
||||
super(Type.BUTTON);
|
||||
}
|
||||
|
@ -38,15 +40,22 @@ public class SWButton extends SWItem {
|
|||
public void generateDialog(View view, LinearLayout layout) {
|
||||
Context context = view.getContext();
|
||||
|
||||
Button button = new Button(context);
|
||||
button = new Button(context);
|
||||
button.setText(buttonText);
|
||||
button.setOnClickListener((v) -> {
|
||||
if (buttonRunnable != null)
|
||||
buttonRunnable.run();
|
||||
});
|
||||
if (buttonValidator != null && !buttonValidator.isValid())
|
||||
return;
|
||||
processVisibility();
|
||||
layout.addView(button);
|
||||
super.generateDialog(view, layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVisibility() {
|
||||
if (buttonValidator != null && !buttonValidator.isValid())
|
||||
button.setVisibility(View.GONE);
|
||||
else
|
||||
button.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package info.nightscout.androidaps.startupwizard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -7,29 +10,31 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.PreferencesActivity;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.startupwizard.events.EventSWUpdate;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
import info.nightscout.utils.PasswordProtection;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class SWDefinition {
|
||||
private static Logger log = LoggerFactory.getLogger(SWDefinition.class);
|
||||
private static SWDefinition swDefinition = null;
|
||||
|
||||
public static SWDefinition getInstance() {
|
||||
if (swDefinition == null)
|
||||
swDefinition = new SWDefinition();
|
||||
return swDefinition;
|
||||
}
|
||||
|
||||
private Context context;
|
||||
static List<SWScreen> screens = new ArrayList<>();
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public static List<SWScreen> getScreens() {
|
||||
return screens;
|
||||
}
|
||||
|
@ -94,24 +99,43 @@ public class SWDefinition {
|
|||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.INSULIN)
|
||||
.label(R.string.configbuilder_insulin)
|
||||
.comment(R.string.configbuilder_insulin))
|
||||
.label(R.string.configbuilder_insulin))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.INSULIN) != null)
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_bgsource)
|
||||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.BGSOURCE)
|
||||
.label(R.string.configbuilder_bgsource)
|
||||
.comment(R.string.configbuilder_bgsource))
|
||||
.label(R.string.configbuilder_bgsource))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.BGSOURCE) != null)
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_pump)
|
||||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.PUMP)
|
||||
.label(R.string.configbuilder_pump))
|
||||
.add(new SWButton()
|
||||
.text(R.string.pumpsetup)
|
||||
.action(() -> {
|
||||
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActivePump();
|
||||
PasswordProtection.QueryPassword(context, R.string.settings_password, "settings_password", () -> {
|
||||
Intent i = new Intent(context, PreferencesActivity.class);
|
||||
i.putExtra("id", plugin.getPreferencesId());
|
||||
context.startActivity(i);
|
||||
}, null);
|
||||
})
|
||||
.visibility(() -> ((PluginBase) MainApp.getConfigBuilder().getActivePump()).getPreferencesId() > 0))
|
||||
.add(new SWButton()
|
||||
.text(R.string.readstatus)
|
||||
.action(() -> ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null))
|
||||
.visibility(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null && MainApp.getConfigBuilder().getActivePump().isInitialized())
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_aps)
|
||||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.APS)
|
||||
.label(R.string.configbuilder_aps)
|
||||
.comment(R.string.configbuilder_aps))
|
||||
.label(R.string.configbuilder_aps))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null)
|
||||
)
|
||||
;
|
||||
|
|
|
@ -82,4 +82,6 @@ public class SWItem {
|
|||
public void generateDialog(View view, LinearLayout layout) {
|
||||
}
|
||||
|
||||
public void processVisibility() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,4 +34,9 @@ public class SWScreen {
|
|||
this.validator = validator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void processVisibility() {
|
||||
for (SWItem i : items)
|
||||
i.processVisibility();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
||||
import info.nightscout.androidaps.startupwizard.events.EventSWUpdate;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
|
@ -27,7 +28,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
|
||||
private TextView screenName;
|
||||
|
||||
SWDefinition swDefinition = SWDefinition.getInstance();
|
||||
SWDefinition swDefinition = new SWDefinition();
|
||||
List<SWScreen> screens = swDefinition.getScreens();
|
||||
private int currentWizardPage = 0;
|
||||
public static final String INTENT_MESSAGE = "WIZZARDPAGE";
|
||||
|
@ -63,6 +64,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
swDefinition.setContext(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -73,7 +75,12 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onContentUpdate(EventNSClientStatus ev) {
|
||||
public void onEventNSClientStatus(EventNSClientStatus ignored) {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEventPumpStatusChanged(EventPumpStatusChanged ignored) {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
@ -104,6 +111,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
findViewById(R.id.previous_button).setVisibility(View.GONE);
|
||||
else
|
||||
findViewById(R.id.previous_button).setVisibility(View.VISIBLE);
|
||||
currentScreen.processVisibility();
|
||||
}
|
||||
|
||||
public void showNextPage(View view) {
|
||||
|
|
|
@ -1061,5 +1061,7 @@
|
|||
<string name="dummy_content">DUMMY\nCONTENT</string>
|
||||
<string name="enable_nsclient">Enable NSClient</string>
|
||||
<string name="welcometosetupwizard">Welcome to setup wizard. It will guide you through the setup process</string>
|
||||
<string name="pumpsetup">Pump setup</string>
|
||||
<string name="readstatus">Read status</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue