Merge pull request #1036 from PoweRGbg/dev
Added description for insulin plugins
This commit is contained in:
commit
0beccdea54
4 changed files with 120 additions and 2 deletions
|
@ -0,0 +1,77 @@
|
||||||
|
package info.nightscout.androidaps.startupwizard;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Rumen Georgiev on 5/9/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SWCheckbox extends SWItem {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(SWCheckbox.class);
|
||||||
|
|
||||||
|
int labelsArray;
|
||||||
|
int valuesArray;
|
||||||
|
String label = "";
|
||||||
|
int preferenceID;
|
||||||
|
private CheckBox checkBox;
|
||||||
|
|
||||||
|
public SWCheckbox() {
|
||||||
|
super(Type.CHECKBOX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SWCheckbox option(String label, int preferenceID) {
|
||||||
|
this.label = label;
|
||||||
|
this.preferenceID = preferenceID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateDialog(View view, LinearLayout layout) {
|
||||||
|
Context context = view.getContext();
|
||||||
|
// Get if there is already value in SP
|
||||||
|
Boolean previousValue;
|
||||||
|
previousValue = SP.getBoolean(preferenceId, false);
|
||||||
|
checkBox = new CheckBox(context);
|
||||||
|
checkBox.setText(label);
|
||||||
|
checkBox.setChecked(previousValue);
|
||||||
|
checkBox.setVisibility(View.VISIBLE);
|
||||||
|
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
ArrayList<PluginBase> pluginsInCategory;
|
||||||
|
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.PUMP);
|
||||||
|
PluginBase found = null;
|
||||||
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
if (p.isEnabled(PluginType.PUMP) && found == null) {
|
||||||
|
found = p;
|
||||||
|
} else if (p.isEnabled(PluginType.PUMP)) {
|
||||||
|
// set others disabled
|
||||||
|
p.setPluginEnabled(PluginType.PUMP, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.debug("Enabled pump plugin:"+found.getClass());
|
||||||
|
save(checkBox.isChecked());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
layout.addView(checkBox);
|
||||||
|
super.generateDialog(view, layout);
|
||||||
|
}
|
||||||
|
public void save(boolean value){
|
||||||
|
SP.putBoolean(preferenceID, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
||||||
|
@ -113,6 +114,12 @@ public class SWDefinition {
|
||||||
)
|
)
|
||||||
.add(new SWScreen(R.string.configbuilder_insulin)
|
.add(new SWScreen(R.string.configbuilder_insulin)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(MainApp.gs(R.string.fastactinginsulincomment)+" = "+MainApp.gs(R.string.rapid_acting_oref)))
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(MainApp.gs(R.string.ultrafastactinginsulincomment)+" = "+MainApp.gs(R.string.ultrarapid_oref)))
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(MainApp.gs(R.string.free_peak_oref_description)+" = "+MainApp.gs(R.string.free_peak_oref)))
|
||||||
.add(new SWPlugin()
|
.add(new SWPlugin()
|
||||||
.option(PluginType.INSULIN)
|
.option(PluginType.INSULIN)
|
||||||
.label(R.string.configbuilder_insulin))
|
.label(R.string.configbuilder_insulin))
|
||||||
|
@ -120,6 +127,8 @@ public class SWDefinition {
|
||||||
)
|
)
|
||||||
.add(new SWScreen(R.string.configbuilder_bgsource)
|
.add(new SWScreen(R.string.configbuilder_bgsource)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(R.string.setupwizard_bgsource_description))
|
||||||
.add(new SWPlugin()
|
.add(new SWPlugin()
|
||||||
.option(PluginType.BGSOURCE)
|
.option(PluginType.BGSOURCE)
|
||||||
.label(R.string.configbuilder_bgsource))
|
.label(R.string.configbuilder_bgsource))
|
||||||
|
@ -210,6 +219,8 @@ public class SWDefinition {
|
||||||
)
|
)
|
||||||
.add(new SWScreen(R.string.configbuilder_loop)
|
.add(new SWScreen(R.string.configbuilder_loop)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(R.string.setupwizard_loop_description))
|
||||||
.add(new SWButton()
|
.add(new SWButton()
|
||||||
.text(R.string.enableloop)
|
.text(R.string.enableloop)
|
||||||
.action(() -> {
|
.action(() -> {
|
||||||
|
@ -223,7 +234,24 @@ public class SWDefinition {
|
||||||
.validator(() -> LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
.validator(() -> LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||||
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||||
)
|
)
|
||||||
|
.add(new SWScreen(R.string.objectives)
|
||||||
|
.skippable(false)
|
||||||
|
.add(new SWInfotext()
|
||||||
|
.label(R.string.setupwizard_objectives_description))
|
||||||
|
.add(new SWButton()
|
||||||
|
.text(R.string.objectives_button_start)
|
||||||
|
.action(() -> {
|
||||||
|
ObjectivesPlugin.getPlugin().setPluginEnabled(PluginType.CONSTRAINTS, true);
|
||||||
|
ObjectivesPlugin.getPlugin().setFragmentVisible(PluginType.CONSTRAINTS, true);
|
||||||
|
ConfigBuilderFragment.processOnEnabledCategoryChanged(ObjectivesPlugin.getPlugin(), PluginType.CONSTRAINTS);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
|
MainApp.bus().post(new EventSWUpdate(true));
|
||||||
|
}))
|
||||||
|
.validator(() -> ObjectivesPlugin.getPlugin().isEnabled(PluginType.CONSTRAINTS))
|
||||||
|
.visibility(() -> !ObjectivesPlugin.getPlugin().isFragmentVisible())
|
||||||
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,18 +15,27 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class SWInfotext extends SWItem {
|
public class SWInfotext extends SWItem {
|
||||||
private static Logger log = LoggerFactory.getLogger(SWInfotext.class);
|
private static Logger log = LoggerFactory.getLogger(SWInfotext.class);
|
||||||
|
private String textLabel = null;
|
||||||
|
|
||||||
public SWInfotext() {
|
public SWInfotext() {
|
||||||
super(Type.TEXT);
|
super(Type.TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SWInfotext label(String newLabel){
|
||||||
|
this.textLabel = newLabel;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(View view, LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = view.getContext();
|
||||||
|
|
||||||
TextView l = new TextView(context);
|
TextView l = new TextView(context);
|
||||||
l.setId(view.generateViewId());
|
l.setId(view.generateViewId());
|
||||||
l.setText(label);
|
if(textLabel != null)
|
||||||
|
l.setText(textLabel);
|
||||||
|
else
|
||||||
|
l.setText(label);
|
||||||
layout.addView(l);
|
layout.addView(l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,6 +667,7 @@
|
||||||
<string name="free_peak_oref">Free-Peak Oref</string>
|
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||||
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
|
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
|
||||||
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
||||||
|
<string name="free_peak_oref_description">Custom insulin</string>
|
||||||
<string name="dia_too_short" formatted="false">DIA of %f too short - using %f instead!</string>
|
<string name="dia_too_short" formatted="false">DIA of %f too short - using %f instead!</string>
|
||||||
<string name="activate_profile">Activate profile</string>
|
<string name="activate_profile">Activate profile</string>
|
||||||
<string name="date">Date</string>
|
<string name="date">Date</string>
|
||||||
|
@ -1063,5 +1064,8 @@
|
||||||
<string name="readstatus">Read status</string>
|
<string name="readstatus">Read status</string>
|
||||||
<string name="adjustprofileinns">Changes must be done in NS</string>
|
<string name="adjustprofileinns">Changes must be done in NS</string>
|
||||||
<string name="exitwizard">Exit setup wizard?</string>
|
<string name="exitwizard">Exit setup wizard?</string>
|
||||||
|
<string name="setupwizard_bgsource_description">Where should blood glucose(BG) data be comming from ?</string>
|
||||||
|
<string name="setupwizard_loop_description">Press the button below to enable AndroidAPS to suggest/make basal changes</string>
|
||||||
|
<string name="setupwizard_objectives_description">Press the button below to enable Objectives. Look in the Objectives tab, after you finish this wizard, to make AndroidAPS completely functional.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue