diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java index c0537566b0..82070c44cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWDefinition.java @@ -18,6 +18,9 @@ import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; +import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; +import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; @@ -151,6 +154,22 @@ public class SWDefinition { .validator(() -> SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid("StartupWizard")) .visibility(() -> SimpleProfilePlugin.getPlugin().isEnabled(PluginType.PROFILE)) ) + .add(new SWScreen(R.string.profileswitch) + .skippable(false) + .add(new SWInfotext() + .label(R.string.profileswitch_ismissing)) + .add(new SWButton() + .text(R.string.profileswitch) + .action(() -> { + NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); + final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT; + profileswitch.executeProfileSwitch = true; + newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); + newDialog.show(getActivity().getSupportFragmentManager(), "NewNSTreatmentDialog"); + })) + .validator(() -> MainApp.getConfigBuilder().getProfile() != null) + .visibility(() -> MainApp.getConfigBuilder().getProfile() == null) + ) .add(new SWScreen(R.string.configbuilder_pump) .skippable(false) .add(new SWPlugin() diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWFragment.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWFragment.java index 97beb9fad1..d53559e539 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWFragment.java @@ -1,29 +1,25 @@ package info.nightscout.androidaps.startupwizard; -import android.content.Context; import android.support.v4.app.Fragment; import android.view.View; import android.widget.LinearLayout; -import android.widget.TextView; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.plugins.Common.SubscriberFragment; - public class SWFragment extends SWItem { private static Logger log = LoggerFactory.getLogger(SWFragment.class); SWDefinition definition; - SubscriberFragment fragment; + Fragment fragment; public SWFragment(SWDefinition definition) { super(Type.FRAGMENT); this.definition = definition; } - public SWFragment add(SubscriberFragment fragment) { + public SWFragment add(Fragment fragment) { this.fragment = fragment; return this; } diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java index df820953ea..67af63326b 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java @@ -22,6 +22,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.startupwizard.events.EventSWUpdate; import info.nightscout.utils.LocaleHelper; +import info.nightscout.utils.OKDialog; public class SetupWizardActivity extends AppCompatActivity { //logging @@ -54,6 +55,11 @@ public class SetupWizardActivity extends AppCompatActivity { } } + @Override + public void onBackPressed() { + OKDialog.showConfirmation(this, MainApp.gs(R.string.exitwizard), this::finish); + } + @Override public void onPause() { super.onPause(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 87b072dc9b..710e66e3be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1062,5 +1062,6 @@ Pump setup Read status Changes must be done in NS + Exit setup wizard?