updated to latest from Milos

This commit is contained in:
Roumen Georgiev 2018-05-09 15:06:34 +03:00
parent a7bbf93599
commit 41d736e176
4 changed files with 111 additions and 129 deletions

View file

@ -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());
}
});

View file

@ -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());

View file

@ -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);
}