updated to latest from Milos
This commit is contained in:
parent
a7bbf93599
commit
41d736e176
4 changed files with 111 additions and 129 deletions
|
@ -9,6 +9,12 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -47,6 +53,18 @@ public class SWCheckbox extends SWItem {
|
|||
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());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -51,94 +51,94 @@ public class SWDefinition {
|
|||
.add(new SWInfotext()
|
||||
.label(R.string.welcometosetupwizard) )
|
||||
)
|
||||
.add(new SWScreen(R.string.language)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.languagesArray, R.array.languagesValues)
|
||||
.preferenceId(R.string.key_language).label(R.string.language)
|
||||
.comment(R.string.setupwizard_language_prompt))
|
||||
.validator(() -> {
|
||||
String lang = SP.getString("language", "en");
|
||||
LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang);
|
||||
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));
|
||||
.add(new SWScreen(R.string.language)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.languagesArray, R.array.languagesValues)
|
||||
.preferenceId(R.string.key_language).label(R.string.language)
|
||||
.comment(R.string.setupwizard_language_prompt))
|
||||
.validator(() -> {
|
||||
String lang = SP.getString("language", "en");
|
||||
LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang);
|
||||
return SP.contains(R.string.key_language);
|
||||
})
|
||||
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
||||
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth)
|
||||
)
|
||||
.add(new SWScreen(R.string.patientage)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.ageArray, R.array.ageValues)
|
||||
.preferenceId(R.string.key_age)
|
||||
.label(R.string.patientage)
|
||||
.comment(R.string.patientage_summary))
|
||||
.validator(() -> SP.contains(R.string.key_age))
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_insulin)
|
||||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.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))
|
||||
.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))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null)
|
||||
)
|
||||
)
|
||||
.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.patientage)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.ageArray, R.array.ageValues)
|
||||
.preferenceId(R.string.key_age)
|
||||
.label(R.string.patientage)
|
||||
.comment(R.string.patientage_summary))
|
||||
.validator(() -> SP.contains(R.string.key_age))
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_insulin)
|
||||
.skippable(false)
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.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))
|
||||
.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))
|
||||
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,22 +5,11 @@ import android.view.View;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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;
|
||||
|
||||
public class SWRadioButton extends SWItem {
|
||||
|
@ -28,15 +17,13 @@ public class SWRadioButton extends SWItem {
|
|||
|
||||
int labelsArray;
|
||||
int valuesArray;
|
||||
String groupLabel = "";
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
public SWRadioButton() {
|
||||
super(Type.RADIOBUTTON);
|
||||
}
|
||||
|
||||
public SWRadioButton option(String groupLabel, int labels, int values) {
|
||||
this.groupLabel = groupLabel;
|
||||
public SWRadioButton option(int labels, int values) {
|
||||
this.labelsArray = labels;
|
||||
this.valuesArray = values;
|
||||
return this;
|
||||
|
@ -54,33 +41,12 @@ public class SWRadioButton extends SWItem {
|
|||
public void generateDialog(View view, LinearLayout layout) {
|
||||
Context context = view.getContext();
|
||||
// Get if there is already value in SP
|
||||
String previousValue = "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);
|
||||
}
|
||||
String previousValue = SP.getString(preferenceId, "none");
|
||||
radioGroup = new RadioGroup(context);
|
||||
radioGroup.clearCheck();
|
||||
radioGroup.setOrientation(LinearLayout.VERTICAL);
|
||||
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++) {
|
||||
RadioButton rdbtn = new RadioButton(context);
|
||||
rdbtn.setId(View.generateViewId());
|
||||
|
@ -98,4 +64,4 @@ public class SWRadioButton extends SWItem {
|
|||
layout.addView(radioGroup);
|
||||
super.generateDialog(view, layout);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -126,9 +126,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
this.finish();
|
||||
Intent intent = new Intent(this, SetupWizardActivity.class);
|
||||
intent.putExtra(INTENT_MESSAGE, currentWizardPage + 1);
|
||||
|
||||
// screens = SWDefinition.getInstance().getScreens();
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
@ -139,7 +137,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
|||
intent.putExtra(INTENT_MESSAGE, currentWizardPage - 1);
|
||||
else
|
||||
intent.putExtra(INTENT_MESSAGE, 0);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue