SW sensitivity plugin
This commit is contained in:
parent
5b9594bdbb
commit
de8557a115
|
@ -33,8 +33,10 @@ import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
|
|||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
|
||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWBreak;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWButton;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWFragment;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWHtmlLink;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWInfotext;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWPlugin;
|
||||
import info.nightscout.androidaps.startupwizard.elements.SWRadioButton;
|
||||
|
@ -261,6 +263,30 @@ public class SWDefinition {
|
|||
.validator(() -> LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_sensitivity)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.setupwizard_sensitivity_description))
|
||||
.add(new SWHtmlLink()
|
||||
.label(R.string.setupwizard_sensitivity_url))
|
||||
.add(new SWBreak())
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.SENSITIVITY)
|
||||
.label(R.string.configbuilder_sensitivity))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.sensitivitysetup)
|
||||
.action(() -> {
|
||||
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveSensitivity();
|
||||
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
|
||||
Intent i = new Intent(activity, PreferencesActivity.class);
|
||||
i.putExtra("id", plugin.getPreferencesId());
|
||||
activity.startActivity(i);
|
||||
}, null);
|
||||
})
|
||||
.visibility(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null && ((PluginBase) MainApp.getConfigBuilder().getActiveSensitivity()).getPreferencesId() > 0))
|
||||
.validator(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null)
|
||||
)
|
||||
.add(new SWScreen(R.string.objectives)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package info.nightscout.androidaps.startupwizard.elements;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.startupwizard.SWValidator;
|
||||
|
||||
|
||||
public class SWBreak extends SWItem {
|
||||
private static Logger log = LoggerFactory.getLogger(SWBreak.class);
|
||||
|
||||
private TextView l;
|
||||
private SWValidator visibilityValidator;
|
||||
|
||||
public SWBreak() {
|
||||
super(Type.TEXT);
|
||||
}
|
||||
|
||||
public SWBreak visibility(SWValidator visibilityValidator) {
|
||||
this.visibilityValidator = visibilityValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDialog(View view, LinearLayout layout) {
|
||||
Context context = view.getContext();
|
||||
|
||||
l = new TextView(context);
|
||||
l.setId(View.generateViewId());
|
||||
l.setText("\n");
|
||||
layout.addView(l);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVisibility() {
|
||||
if (visibilityValidator != null && !visibilityValidator.isValid())
|
||||
l.setVisibility(View.GONE);
|
||||
else
|
||||
l.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package info.nightscout.androidaps.startupwizard.elements;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.startupwizard.SWValidator;
|
||||
|
||||
|
||||
public class SWHtmlLink extends SWItem {
|
||||
private static Logger log = LoggerFactory.getLogger(SWHtmlLink.class);
|
||||
private String textLabel = null;
|
||||
|
||||
private TextView l;
|
||||
private SWValidator visibilityValidator;
|
||||
|
||||
public SWHtmlLink() {
|
||||
super(Type.HTMLLINK);
|
||||
}
|
||||
|
||||
public SWHtmlLink label(int label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SWHtmlLink label(String newLabel){
|
||||
this.textLabel = newLabel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SWHtmlLink visibility(SWValidator visibilityValidator) {
|
||||
this.visibilityValidator = visibilityValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDialog(View view, LinearLayout layout) {
|
||||
Context context = view.getContext();
|
||||
|
||||
l = new TextView(context);
|
||||
l.setId(View.generateViewId());
|
||||
l.setAutoLinkMask(Linkify.ALL);
|
||||
if(textLabel != null)
|
||||
l.setText(textLabel);
|
||||
else
|
||||
l.setText(label);
|
||||
layout.addView(l);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVisibility() {
|
||||
if (visibilityValidator != null && !visibilityValidator.isValid())
|
||||
l.setVisibility(View.GONE);
|
||||
else
|
||||
l.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ public class SWItem {
|
|||
public enum Type {
|
||||
NONE,
|
||||
TEXT,
|
||||
HTMLLINK,
|
||||
BREAK,
|
||||
LISTENER,
|
||||
URL,
|
||||
STRING,
|
||||
|
|
|
@ -1071,4 +1071,7 @@
|
|||
<string name="apssetup">Configure APS plugin</string>
|
||||
<string name="backupismissing">Exported configuration is missing thus import configuration is not possible.\n</string>
|
||||
<string name="key_setupwizard_processed" translatable="false">startupwizard_processed</string>
|
||||
<string name="sensitivitysetup">Configure Sensitivity plugin</string>
|
||||
<string name="setupwizard_sensitivity_description">Sensitivity plugin is used for sensitivity detection and COB calculation. For more info visit:</string>
|
||||
<string name="setupwizard_sensitivity_url">https://github.com/MilosKozak/AndroidAPS/wiki/Sensitivity-detection-and-COB</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue