save() before showing next
This commit is contained in:
parent
59f654f918
commit
67ed699ca5
|
@ -10,6 +10,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class SWRadioButton extends SWItem {
|
public class SWRadioButton extends SWItem {
|
||||||
|
|
||||||
|
@ -72,11 +74,6 @@ public class SWRadioButton extends SWItem {
|
||||||
return this.radioGroup;
|
return this.radioGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the id of the group
|
|
||||||
public int getGroupId(){
|
|
||||||
return radioGroup.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCheckedValue(){
|
public String getCheckedValue(){
|
||||||
if(radioGroup != null && radioGroup.getCheckedRadioButtonId() > -1){
|
if(radioGroup != null && radioGroup.getCheckedRadioButtonId() > -1){
|
||||||
Context context = radioGroup.getRootView().getContext();
|
Context context = radioGroup.getRootView().getContext();
|
||||||
|
@ -91,6 +88,12 @@ public class SWRadioButton extends SWItem {
|
||||||
return this.somethingChecked;
|
return this.somethingChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(){
|
||||||
|
if(getCheckedValue().equals("none")) {
|
||||||
|
SP.putString(preferenceId, getCheckedValue());
|
||||||
|
MainApp.bus().post(new EventPreferenceChange(preferenceId));
|
||||||
|
}
|
||||||
|
}
|
||||||
// return true if we have something checked
|
// return true if we have something checked
|
||||||
public boolean isValid(){
|
public boolean isValid(){
|
||||||
if(getCheckedValue().equals("none"))
|
if(getCheckedValue().equals("none"))
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.startupwizard.SWItem.Type.RADIOBUTTON;
|
import static info.nightscout.androidaps.startupwizard.SWItem.Type.RADIOBUTTON;
|
||||||
import static info.nightscout.androidaps.startupwizard.SWItem.Type.STRING;
|
import static info.nightscout.androidaps.startupwizard.SWItem.Type.STRING;
|
||||||
|
@ -179,7 +180,10 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
nextAllowed = radioGroupItems.isValid();
|
log.debug("Validate radio input:" +currentScreen.validator.isValid());
|
||||||
|
radioGroupItems.save();
|
||||||
|
log.debug("Preference value after save is:"+ SP.getString(radioGroupItems.preferenceId, "unset"));
|
||||||
|
nextAllowed = currentScreen.validator.isValid();
|
||||||
if(showPage == screens.size() - 1 && nextAllowed) {
|
if(showPage == screens.size() - 1 && nextAllowed) {
|
||||||
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.GONE);
|
((Button) findViewById(R.id.next_button)).setVisibility(View.GONE);
|
||||||
|
@ -196,6 +200,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
SWUrl swUrl = new SWUrl();
|
SWUrl swUrl = new SWUrl();
|
||||||
swUrl.setOptions(labels, comments);
|
swUrl.setOptions(labels, comments);
|
||||||
swUrl.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
swUrl.generateDialog(this.findViewById(R.id.fullscreen_content_fields));
|
||||||
|
log.debug("Valid input:" +currentScreen.validator.isValid());
|
||||||
nextAllowed = swUrl.isValid();
|
nextAllowed = swUrl.isValid();
|
||||||
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
((Button) findViewById(R.id.next_button)).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue