updated to latest from Milos
This commit is contained in:
parent
a7bbf93599
commit
41d736e176
|
@ -9,6 +9,12 @@ import android.widget.CheckBox;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +53,18 @@ public class SWCheckbox extends SWItem {
|
||||||
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
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());
|
save(checkBox.isChecked());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,93 +51,93 @@ public class SWDefinition {
|
||||||
.add(new SWInfotext()
|
.add(new SWInfotext()
|
||||||
.label(R.string.welcometosetupwizard) )
|
.label(R.string.welcometosetupwizard) )
|
||||||
)
|
)
|
||||||
.add(new SWScreen(R.string.language)
|
.add(new SWScreen(R.string.language)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
.add(new SWRadioButton()
|
.add(new SWRadioButton()
|
||||||
.option(R.array.languagesArray, R.array.languagesValues)
|
.option(R.array.languagesArray, R.array.languagesValues)
|
||||||
.preferenceId(R.string.key_language).label(R.string.language)
|
.preferenceId(R.string.key_language).label(R.string.language)
|
||||||
.comment(R.string.setupwizard_language_prompt))
|
.comment(R.string.setupwizard_language_prompt))
|
||||||
.validator(() -> {
|
.validator(() -> {
|
||||||
String lang = SP.getString("language", "en");
|
String lang = SP.getString("language", "en");
|
||||||
LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang);
|
LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang);
|
||||||
return SP.contains(R.string.key_language);
|
return SP.contains(R.string.key_language);
|
||||||
})
|
|
||||||
)
|
|
||||||
.add(new SWScreen(R.string.nsclientinternal_title)
|
|
||||||
.skippable(true)
|
|
||||||
.add(new SWUrl()
|
|
||||||
.preferenceId(R.string.key_nsclientinternal_url)
|
|
||||||
.label(R.string.nsclientinternal_url_title)
|
|
||||||
.comment(R.string.nsclientinternal_url_dialogmessage))
|
|
||||||
.add(new SWString()
|
|
||||||
.preferenceId(R.string.key_nsclientinternal_api_secret)
|
|
||||||
.label(R.string.nsclientinternal_secret_dialogtitle)
|
|
||||||
.comment(R.string.nsclientinternal_secret_dialogmessage))
|
|
||||||
.add(new SWButton()
|
|
||||||
.text(R.string.enable_nsclient)
|
|
||||||
.action(() -> {
|
|
||||||
NSClientPlugin.getPlugin().setPluginEnabled(PluginType.GENERAL, true);
|
|
||||||
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
|
||||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
|
||||||
MainApp.bus().post(new EventSWUpdate(true));
|
|
||||||
})
|
})
|
||||||
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
)
|
||||||
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth)
|
.add(new SWScreen(R.string.nsclientinternal_title)
|
||||||
)
|
.skippable(true)
|
||||||
.add(new SWScreen(R.string.patientage)
|
.add(new SWUrl()
|
||||||
.skippable(false)
|
.preferenceId(R.string.key_nsclientinternal_url)
|
||||||
.add(new SWRadioButton()
|
.label(R.string.nsclientinternal_url_title)
|
||||||
.option(R.array.ageArray, R.array.ageValues)
|
.comment(R.string.nsclientinternal_url_dialogmessage))
|
||||||
.preferenceId(R.string.key_age)
|
.add(new SWString()
|
||||||
.label(R.string.patientage)
|
.preferenceId(R.string.key_nsclientinternal_api_secret)
|
||||||
.comment(R.string.patientage_summary))
|
.label(R.string.nsclientinternal_secret_dialogtitle)
|
||||||
.validator(() -> SP.contains(R.string.key_age))
|
.comment(R.string.nsclientinternal_secret_dialogmessage))
|
||||||
)
|
.add(new SWButton()
|
||||||
.add(new SWScreen(R.string.configbuilder_insulin)
|
.text(R.string.enable_nsclient)
|
||||||
.skippable(false)
|
.action(() -> {
|
||||||
.add(new SWPlugin()
|
NSClientPlugin.getPlugin().setPluginEnabled(PluginType.GENERAL, true);
|
||||||
.option(PluginType.INSULIN)
|
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
||||||
.label(R.string.configbuilder_insulin))
|
ConfigBuilderFragment.processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.INSULIN) != null)
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
)
|
MainApp.bus().post(new EventConfigBuilderChange());
|
||||||
.add(new SWScreen(R.string.configbuilder_bgsource)
|
MainApp.bus().post(new EventSWUpdate(true));
|
||||||
.skippable(false)
|
})
|
||||||
.add(new SWPlugin()
|
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
||||||
.option(PluginType.BGSOURCE)
|
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth)
|
||||||
.label(R.string.configbuilder_bgsource))
|
)
|
||||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.BGSOURCE) != null)
|
.add(new SWScreen(R.string.patientage)
|
||||||
)
|
.skippable(false)
|
||||||
.add(new SWScreen(R.string.configbuilder_pump)
|
.add(new SWRadioButton()
|
||||||
.skippable(false)
|
.option(R.array.ageArray, R.array.ageValues)
|
||||||
.add(new SWPlugin()
|
.preferenceId(R.string.key_age)
|
||||||
.option(PluginType.PUMP)
|
.label(R.string.patientage)
|
||||||
.label(R.string.configbuilder_pump))
|
.comment(R.string.patientage_summary))
|
||||||
.add(new SWButton()
|
.validator(() -> SP.contains(R.string.key_age))
|
||||||
.text(R.string.pumpsetup)
|
)
|
||||||
.action(() -> {
|
.add(new SWScreen(R.string.configbuilder_insulin)
|
||||||
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActivePump();
|
.skippable(false)
|
||||||
PasswordProtection.QueryPassword(context, R.string.settings_password, "settings_password", () -> {
|
.add(new SWPlugin()
|
||||||
Intent i = new Intent(context, PreferencesActivity.class);
|
.option(PluginType.INSULIN)
|
||||||
i.putExtra("id", plugin.getPreferencesId());
|
.label(R.string.configbuilder_insulin))
|
||||||
context.startActivity(i);
|
.validator(() -> MainApp.getSpecificPluginsList(PluginType.INSULIN) != null)
|
||||||
}, null);
|
)
|
||||||
})
|
.add(new SWScreen(R.string.configbuilder_bgsource)
|
||||||
.visibility(() -> ((PluginBase) MainApp.getConfigBuilder().getActivePump()).getPreferencesId() > 0))
|
.skippable(false)
|
||||||
.add(new SWButton()
|
.add(new SWPlugin()
|
||||||
.text(R.string.readstatus)
|
.option(PluginType.BGSOURCE)
|
||||||
.action(() -> ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null))
|
.label(R.string.configbuilder_bgsource))
|
||||||
.visibility(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null))
|
.validator(() -> MainApp.getSpecificPluginsList(PluginType.BGSOURCE) != null)
|
||||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null && MainApp.getConfigBuilder().getActivePump().isInitialized())
|
)
|
||||||
)
|
.add(new SWScreen(R.string.configbuilder_pump)
|
||||||
.add(new SWScreen(R.string.configbuilder_aps)
|
.skippable(false)
|
||||||
.skippable(false)
|
.add(new SWPlugin()
|
||||||
.add(new SWPlugin()
|
.option(PluginType.PUMP)
|
||||||
.option(PluginType.APS)
|
.label(R.string.configbuilder_pump))
|
||||||
.label(R.string.configbuilder_aps))
|
.add(new SWButton()
|
||||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null)
|
.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))
|
||||||
|
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null)
|
||||||
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,22 +5,11 @@ import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class SWRadioButton extends SWItem {
|
public class SWRadioButton extends SWItem {
|
||||||
|
@ -28,15 +17,13 @@ public class SWRadioButton extends SWItem {
|
||||||
|
|
||||||
int labelsArray;
|
int labelsArray;
|
||||||
int valuesArray;
|
int valuesArray;
|
||||||
String groupLabel = "";
|
|
||||||
private RadioGroup radioGroup;
|
private RadioGroup radioGroup;
|
||||||
|
|
||||||
public SWRadioButton() {
|
public SWRadioButton() {
|
||||||
super(Type.RADIOBUTTON);
|
super(Type.RADIOBUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWRadioButton option(String groupLabel, int labels, int values) {
|
public SWRadioButton option(int labels, int values) {
|
||||||
this.groupLabel = groupLabel;
|
|
||||||
this.labelsArray = labels;
|
this.labelsArray = labels;
|
||||||
this.valuesArray = values;
|
this.valuesArray = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -54,33 +41,12 @@ public class SWRadioButton extends SWItem {
|
||||||
public void generateDialog(View view, LinearLayout layout) {
|
public void generateDialog(View view, LinearLayout layout) {
|
||||||
Context context = view.getContext();
|
Context context = view.getContext();
|
||||||
// Get if there is already value in SP
|
// Get if there is already value in SP
|
||||||
String previousValue = "none";
|
String previousValue = SP.getString(preferenceId, "none");
|
||||||
if(preferenceId == R.string.key_virtualpump_uploadstatus) {
|
|
||||||
Boolean booleanValue = SP.getBoolean(preferenceId, false);
|
|
||||||
previousValue = booleanValue.toString();
|
|
||||||
} else {
|
|
||||||
previousValue = SP.getString(preferenceId, "none");
|
|
||||||
}
|
|
||||||
if(!groupLabel.equals("")) {
|
|
||||||
TextView groupName = new TextView(context);
|
|
||||||
groupName.setText(groupLabel);
|
|
||||||
layout.addView(groupName);
|
|
||||||
}
|
|
||||||
radioGroup = new RadioGroup(context);
|
radioGroup = new RadioGroup(context);
|
||||||
radioGroup.clearCheck();
|
radioGroup.clearCheck();
|
||||||
radioGroup.setOrientation(LinearLayout.VERTICAL);
|
radioGroup.setOrientation(LinearLayout.VERTICAL);
|
||||||
radioGroup.setVisibility(View.VISIBLE);
|
radioGroup.setVisibility(View.VISIBLE);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < labels().length; i++) {
|
for (int i = 0; i < labels().length; i++) {
|
||||||
RadioButton rdbtn = new RadioButton(context);
|
RadioButton rdbtn = new RadioButton(context);
|
||||||
rdbtn.setId(View.generateViewId());
|
rdbtn.setId(View.generateViewId());
|
||||||
|
|
|
@ -126,9 +126,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
this.finish();
|
this.finish();
|
||||||
Intent intent = new Intent(this, SetupWizardActivity.class);
|
Intent intent = new Intent(this, SetupWizardActivity.class);
|
||||||
intent.putExtra(INTENT_MESSAGE, currentWizardPage + 1);
|
intent.putExtra(INTENT_MESSAGE, currentWizardPage + 1);
|
||||||
|
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
// screens = SWDefinition.getInstance().getScreens();
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +137,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
intent.putExtra(INTENT_MESSAGE, currentWizardPage - 1);
|
intent.putExtra(INTENT_MESSAGE, currentWizardPage - 1);
|
||||||
else
|
else
|
||||||
intent.putExtra(INTENT_MESSAGE, 0);
|
intent.putExtra(INTENT_MESSAGE, 0);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue