SWFragment

This commit is contained in:
Milos Kozak 2018-05-09 18:49:42 +02:00
parent 0060a2ba7f
commit 1ba828d20a
26 changed files with 251 additions and 167 deletions

View file

@ -0,0 +1,4 @@
package info.nightscout.androidaps.events;
public class EventProfileStoreChanged extends Event {
}

View file

@ -4,7 +4,6 @@ package info.nightscout.androidaps.plugins.ProfileLocal;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.FragmentTransaction;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -23,7 +22,6 @@ import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
@ -109,34 +107,25 @@ public class LocalProfileFragment extends SubscriberFragment {
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl); mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol); mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
mgdlView.setOnClickListener(new View.OnClickListener() { mgdlView.setOnClickListener(v -> {
@Override
public void onClick(View v) {
LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked(); LocalProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl; LocalProfilePlugin.getPlugin().mmol = !LocalProfilePlugin.getPlugin().mgdl;
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol); mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
doEdit(); doEdit();
}
}); });
mmolView.setOnClickListener(new View.OnClickListener() { mmolView.setOnClickListener(v -> {
@Override
public void onClick(View v) {
LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked(); LocalProfilePlugin.getPlugin().mmol = mmolView.isChecked();
LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol; LocalProfilePlugin.getPlugin().mgdl = !LocalProfilePlugin.getPlugin().mmol;
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl); mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
doEdit(); doEdit();
}
}); });
profileswitchButton.setOnClickListener(new View.OnClickListener() { profileswitchButton.setOnClickListener(view -> {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT; final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
}); });
resetButton.setOnClickListener(view -> { resetButton.setOnClickListener(view -> {

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventProfileStoreChanged;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -81,6 +82,7 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
edited = false; edited = false;
if (Config.logPrefsChange) if (Config.logPrefsChange)
log.debug("Storing settings: " + getRawProfile().getData().toString()); log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged());
} }
public synchronized void loadSettings() { public synchronized void loadSettings() {

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventProfileStoreChanged;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -43,7 +44,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.PROFILE) .mainType(PluginType.PROFILE)
.fragmentClass(NSProfileFragment.class.getName()) .fragmentClass(NSProfileFragment.class.getName())
.pluginName(R.string.profileviewer) .pluginName(R.string.nsprofile)
.shortName(R.string.profileviewer_shortname) .shortName(R.string.profileviewer_shortname)
.alwaysEnabled(Config.NSCLIENT) .alwaysEnabled(Config.NSCLIENT)
.alwayVisible(Config.NSCLIENT) .alwayVisible(Config.NSCLIENT)
@ -68,6 +69,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
profile = new ProfileStore(newProfile.getData()); profile = new ProfileStore(newProfile.getData());
storeNSProfile(); storeNSProfile();
MainApp.bus().post(new EventNSProfileUpdateGUI()); MainApp.bus().post(new EventNSProfileUpdateGUI());
MainApp.bus().post(new EventProfileStoreChanged());
} }
private void storeNSProfile() { private void storeNSProfile() {

View file

@ -73,34 +73,25 @@ public class SimpleProfileFragment extends SubscriberFragment {
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString()); targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString()); targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
mgdlView.setOnClickListener(new View.OnClickListener() { mgdlView.setOnClickListener(v -> {
@Override
public void onClick(View v) {
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked(); SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl; SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol); mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
SimpleProfilePlugin.getPlugin().storeSettings(); SimpleProfilePlugin.getPlugin().storeSettings();
}
}); });
mmolView.setOnClickListener(new View.OnClickListener() { mmolView.setOnClickListener(v -> {
@Override
public void onClick(View v) {
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked(); SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol; SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl); mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
SimpleProfilePlugin.getPlugin().storeSettings(); SimpleProfilePlugin.getPlugin().storeSettings();
}
}); });
profileswitchButton.setOnClickListener(new View.OnClickListener() { profileswitchButton.setOnClickListener(view -> {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH; final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
}); });
TextWatcher textWatch = new TextWatcher() { TextWatcher textWatch = new TextWatcher() {
@ -152,9 +143,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
protected void updateGUI() { protected void updateGUI() {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(() -> {
@Override
public void run() {
boolean isValid = SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid(MainApp.gs(R.string.simpleprofile)); boolean isValid = SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid(MainApp.gs(R.string.simpleprofile));
if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended() || !isValid) { if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended() || !isValid) {
profileswitchButton.setVisibility(View.GONE); profileswitchButton.setVisibility(View.GONE);
@ -165,7 +154,6 @@ public class SimpleProfileFragment extends SubscriberFragment {
invalidProfile.setVisibility(View.GONE); invalidProfile.setVisibility(View.GONE);
else else
invalidProfile.setVisibility(View.VISIBLE); invalidProfile.setVisibility(View.VISIBLE);
}
}); });
} }

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventProfileStoreChanged;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -73,6 +74,7 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
createConvertedProfile(); createConvertedProfile();
if (Config.logPrefsChange) if (Config.logPrefsChange)
log.debug("Storing settings: " + getRawProfile().getData().toString()); log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged());
} }
private void loadSettings() { private void loadSettings() {

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.startupwizard; package info.nightscout.androidaps.startupwizard;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
@ -21,6 +21,12 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
import info.nightscout.androidaps.startupwizard.events.EventSWLabel; import info.nightscout.androidaps.startupwizard.events.EventSWLabel;
import info.nightscout.androidaps.startupwizard.events.EventSWUpdate; import info.nightscout.androidaps.startupwizard.events.EventSWUpdate;
import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.LocaleHelper;
@ -30,14 +36,14 @@ import info.nightscout.utils.SP;
public class SWDefinition { public class SWDefinition {
private static Logger log = LoggerFactory.getLogger(SWDefinition.class); private static Logger log = LoggerFactory.getLogger(SWDefinition.class);
private Activity activity; private AppCompatActivity activity;
private List<SWScreen> screens = new ArrayList<>(); private List<SWScreen> screens = new ArrayList<>();
public void setActivity(Activity activity) { public void setActivity(AppCompatActivity activity) {
this.activity = activity; this.activity = activity;
} }
public Activity getActivity() { public AppCompatActivity getActivity() {
return activity; return activity;
} }
@ -106,14 +112,44 @@ public class SWDefinition {
.add(new SWPlugin() .add(new SWPlugin()
.option(PluginType.INSULIN) .option(PluginType.INSULIN)
.label(R.string.configbuilder_insulin)) .label(R.string.configbuilder_insulin))
.validator(() -> MainApp.getSpecificPluginsList(PluginType.INSULIN) != null) .validator(() -> MainApp.getConfigBuilder().getActiveInsulin() != null)
) )
.add(new SWScreen(R.string.configbuilder_bgsource) .add(new SWScreen(R.string.configbuilder_bgsource)
.skippable(false) .skippable(false)
.add(new SWPlugin() .add(new SWPlugin()
.option(PluginType.BGSOURCE) .option(PluginType.BGSOURCE)
.label(R.string.configbuilder_bgsource)) .label(R.string.configbuilder_bgsource))
.validator(() -> MainApp.getSpecificPluginsList(PluginType.BGSOURCE) != null) .validator(() -> MainApp.getConfigBuilder().getActiveBgSource() != null)
)
.add(new SWScreen(R.string.configbuilder_profile)
.skippable(false)
.add(new SWPlugin()
.option(PluginType.PROFILE)
.label(R.string.configbuilder_profile))
.validator(() -> MainApp.getConfigBuilder().getActiveProfileInterface() != null)
)
.add(new SWScreen(R.string.nsprofile)
.skippable(false)
.add(new SWInfotext()
.label(R.string.adjustprofileinns))
.add(new SWFragment(this)
.add(new NSProfileFragment()))
.validator(() -> NSProfilePlugin.getPlugin().getProfile() != null && NSProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid("StartupWizard"))
.visibility(() -> NSProfilePlugin.getPlugin().isEnabled(PluginType.PROFILE))
)
.add(new SWScreen(R.string.localprofile)
.skippable(false)
.add(new SWFragment(this)
.add(new LocalProfileFragment()))
.validator(() -> LocalProfilePlugin.getPlugin().getProfile() != null && LocalProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid("StartupWizard"))
.visibility(() -> LocalProfilePlugin.getPlugin().isEnabled(PluginType.PROFILE))
)
.add(new SWScreen(R.string.simpleprofile)
.skippable(false)
.add(new SWFragment(this)
.add(new SimpleProfileFragment()))
.validator(() -> SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid("StartupWizard"))
.visibility(() -> SimpleProfilePlugin.getPlugin().isEnabled(PluginType.PROFILE))
) )
.add(new SWScreen(R.string.configbuilder_pump) .add(new SWScreen(R.string.configbuilder_pump)
.skippable(false) .skippable(false)
@ -134,7 +170,7 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.readstatus) .text(R.string.readstatus)
.action(() -> ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null)) .action(() -> ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null))
.visibility(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null)) .visibility(() -> MainApp.getConfigBuilder().getActivePump() != null))
.add(new SWEventListener(this) .add(new SWEventListener(this)
.listener(new Object() { .listener(new Object() {
@Subscribe @Subscribe
@ -143,14 +179,14 @@ public class SWDefinition {
} }
}) })
) )
.validator(() -> MainApp.getSpecificPluginsList(PluginType.PUMP) != null && MainApp.getConfigBuilder().getActivePump().isInitialized()) .validator(() -> MainApp.getConfigBuilder().getActivePump() != null && MainApp.getConfigBuilder().getActivePump().isInitialized())
) )
.add(new SWScreen(R.string.configbuilder_aps) .add(new SWScreen(R.string.configbuilder_aps)
.skippable(false) .skippable(false)
.add(new SWPlugin() .add(new SWPlugin()
.option(PluginType.APS) .option(PluginType.APS)
.label(R.string.configbuilder_aps)) .label(R.string.configbuilder_aps))
.validator(() -> MainApp.getSpecificPluginsList(PluginType.APS) != null) .validator(() ->MainApp.getConfigBuilder().getActiveAPS() != null)
) )
; ;
} }

View file

@ -0,0 +1,36 @@
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;
public SWFragment(SWDefinition definition) {
super(Type.FRAGMENT);
this.definition = definition;
}
public SWFragment add(SubscriberFragment fragment) {
this.fragment = fragment;
return this;
}
@Override
public void generateDialog(View view, LinearLayout layout) {
definition.getActivity().getSupportFragmentManager().beginTransaction().add(layout.getId(), fragment, fragment.getTag()).commit();
}
}

View file

@ -25,7 +25,8 @@ public class SWItem {
CHECKBOX, CHECKBOX,
RADIOBUTTON, RADIOBUTTON,
PLUGIN, PLUGIN,
BUTTON BUTTON,
FRAGMENT
} }
Type type; Type type;

View file

@ -10,6 +10,7 @@ public class SWScreen {
int header; int header;
List<SWItem> items = new ArrayList<>(); List<SWItem> items = new ArrayList<>();
SWValidator validator; SWValidator validator;
SWValidator visibility;
boolean skippable = false; boolean skippable = false;
public SWScreen(int header) { public SWScreen(int header) {
@ -35,6 +36,11 @@ public class SWScreen {
return this; return this;
} }
public SWScreen visibility(SWValidator visibility) {
this.visibility = visibility;
return this;
}
public void processVisibility() { public void processVisibility() {
for (SWItem i : items) for (SWItem i : items)
i.processVisibility(); i.processVisibility();

View file

@ -17,6 +17,7 @@ import java.util.List;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventProfileStoreChanged;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.startupwizard.events.EventSWUpdate; import info.nightscout.androidaps.startupwizard.events.EventSWUpdate;
@ -46,6 +47,7 @@ public class SetupWizardActivity extends AppCompatActivity {
TextView screenName = (TextView) findViewById(R.id.sw_content); TextView screenName = (TextView) findViewById(R.id.sw_content);
screenName.setText(currentScreen.getHeader()); screenName.setText(currentScreen.getHeader());
swDefinition.setActivity(this);
//Generate layout first //Generate layout first
generateLayout(); generateLayout();
updateButtons(); updateButtons();
@ -82,6 +84,11 @@ public class SetupWizardActivity extends AppCompatActivity {
updateButtons(); updateButtons();
} }
@Subscribe
public void onEventProfileStoreChanged(EventProfileStoreChanged ignored) {
updateButtons();
}
private void generateLayout() { private void generateLayout() {
SWScreen currentScreen = screens.get(currentWizardPage); SWScreen currentScreen = screens.get(currentWizardPage);
LinearLayout layout = SWItem.generateLayout(this.findViewById(R.id.sw_content_fields)); LinearLayout layout = SWItem.generateLayout(this.findViewById(R.id.sw_content_fields));
@ -92,9 +99,10 @@ public class SetupWizardActivity extends AppCompatActivity {
} }
private void updateButtons() { private void updateButtons() {
runOnUiThread(() -> {
SWScreen currentScreen = screens.get(currentWizardPage); SWScreen currentScreen = screens.get(currentWizardPage);
if (currentScreen.validator == null || currentScreen.validator.isValid() || currentScreen.skippable) { if (currentScreen.validator == null || currentScreen.validator.isValid() || currentScreen.skippable) {
if (currentWizardPage == screens.size() - 1) { if (currentWizardPage == nextPage()) {
findViewById(R.id.finish_button).setVisibility(View.VISIBLE); findViewById(R.id.finish_button).setVisibility(View.VISIBLE);
findViewById(R.id.next_button).setVisibility(View.GONE); findViewById(R.id.next_button).setVisibility(View.GONE);
} else { } else {
@ -110,22 +118,20 @@ public class SetupWizardActivity extends AppCompatActivity {
else else
findViewById(R.id.previous_button).setVisibility(View.VISIBLE); findViewById(R.id.previous_button).setVisibility(View.VISIBLE);
currentScreen.processVisibility(); currentScreen.processVisibility();
});
} }
public void showNextPage(View view) { public void showNextPage(View view) {
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, nextPage());
startActivity(intent); startActivity(intent);
} }
public void showPreviousPage(View view) { public void showPreviousPage(View view) {
this.finish(); this.finish();
Intent intent = new Intent(this, SetupWizardActivity.class); Intent intent = new Intent(this, SetupWizardActivity.class);
if (currentWizardPage > 0) intent.putExtra(INTENT_MESSAGE, previousPage());
intent.putExtra(INTENT_MESSAGE, currentWizardPage - 1);
else
intent.putExtra(INTENT_MESSAGE, 0);
startActivity(intent); startActivity(intent);
} }
@ -135,4 +141,23 @@ public class SetupWizardActivity extends AppCompatActivity {
startActivity(intent); startActivity(intent);
} }
private int nextPage() {
int page = currentWizardPage + 1;
while (page < screens.size()) {
if (screens.get(page).visibility == null || screens.get(page).visibility.isValid())
return page;
page++;
}
return currentWizardPage;
}
private int previousPage() {
int page = currentWizardPage - 1;
while (page > 0) {
if (screens.get(page).visibility == null || screens.get(page).visibility.isValid())
return page;
page--;
}
return currentWizardPage;
}
} }

View file

@ -1,29 +1,25 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#0099cc" android:orientation="vertical"
tools:context=".startupwizard.SetupWizardActivity"> tools:context=".startupwizard.SetupWizardActivity">
<TextView <TextView
android:id="@+id/sw_content" android:id="@+id/sw_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:keepScreenOn="true" android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textColor="#33b5e5" android:textColor="#33b5e5"
android:textSize="20dp" android:textSize="20dp"
android:textStyle="bold" /> android:textStyle="bold" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:id="@+id/sw_content_fields" android:id="@+id/sw_content_fields"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
@ -72,8 +68,6 @@
android:text="@string/setupwizard_finish" android:text="@string/setupwizard_finish"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout>
</FrameLayout>

View file

@ -71,7 +71,7 @@
<string name="objectives">Цели</string> <string name="objectives">Цели</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Общ</string> <string name="overview">Общ</string>
<string name="profileviewer">NS Профил</string> <string name="nsprofile">NS Профил</string>
<string name="simpleprofile">Обикновен профил</string> <string name="simpleprofile">Обикновен профил</string>
<string name="tempbasal">TempBasal</string> <string name="tempbasal">TempBasal</string>
<string name="treatments">Лечения</string> <string name="treatments">Лечения</string>

View file

@ -110,7 +110,7 @@
<string name="overview_newtempbasal_basalpercent">Hodnota bazálu [%]</string> <string name="overview_newtempbasal_basalpercent">Hodnota bazálu [%]</string>
<string name="overview_newtempbasal_percent_label">% (100% = současný)</string> <string name="overview_newtempbasal_percent_label">% (100% = současný)</string>
<string name="overview_treatment_label">Bolus</string> <string name="overview_treatment_label">Bolus</string>
<string name="profileviewer">NS profil</string> <string name="nsprofile">NS profil</string>
<string name="objectives_pumpstatusavailableinns">Stav pumpy dostupný v NS</string> <string name="objectives_pumpstatusavailableinns">Stav pumpy dostupný v NS</string>
<string name="rate">Hodnota</string> <string name="rate">Hodnota</string>
<string name="reason">Zdůvodnění</string> <string name="reason">Zdůvodnění</string>

View file

@ -16,7 +16,7 @@
<string name="days">Tage</string> <string name="days">Tage</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="openapsma_profile_label">Profil</string> <string name="openapsma_profile_label">Profil</string>
<string name="profileviewer">Nightscout-Profil</string> <string name="nsprofile">Nightscout-Profil</string>
<string name="tempbasals_iob_label_string">IOB:</string> <string name="tempbasals_iob_label_string">IOB:</string>
<string name="tempbasals_iobtotal_label_string">Gesamt-IOB:</string> <string name="tempbasals_iobtotal_label_string">Gesamt-IOB:</string>
<string name="tempbasals_netinsulin_label_string">Ins:</string> <string name="tempbasals_netinsulin_label_string">Ins:</string>

View file

@ -72,7 +72,7 @@
<string name="objectives">Στόχοι</string> <string name="objectives">Στόχοι</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Επισκόπηση</string> <string name="overview">Επισκόπηση</string>
<string name="profileviewer">Προφίλ NS</string> <string name="nsprofile">Προφίλ NS</string>
<string name="simpleprofile">Απλό Προφίλ</string> <string name="simpleprofile">Απλό Προφίλ</string>
<string name="tempbasal">Προσ.Ρυθμός</string> <string name="tempbasal">Προσ.Ρυθμός</string>
<string name="treatments">Θεραπείες</string> <string name="treatments">Θεραπείες</string>

View file

@ -71,7 +71,7 @@
<string name="objectives">Objetivos</string> <string name="objectives">Objetivos</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Sinopsis</string> <string name="overview">Sinopsis</string>
<string name="profileviewer">Perfil NS</string> <string name="nsprofile">Perfil NS</string>
<string name="simpleprofile">Perfil simple</string> <string name="simpleprofile">Perfil simple</string>
<string name="tempbasal">Basal temporal</string> <string name="tempbasal">Basal temporal</string>
<string name="treatments">Tratamientos</string> <string name="treatments">Tratamientos</string>

View file

@ -67,7 +67,7 @@
<string name="objectives">Objectifs</string> <string name="objectives">Objectifs</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Aperçu</string> <string name="overview">Aperçu</string>
<string name="profileviewer">Profil NS</string> <string name="nsprofile">Profil NS</string>
<string name="simpleprofile">Profil simple</string> <string name="simpleprofile">Profil simple</string>
<string name="tempbasal">Basal Tempo</string> <string name="tempbasal">Basal Tempo</string>
<string name="treatments">Traitements</string> <string name="treatments">Traitements</string>

View file

@ -454,7 +454,7 @@
<string name="simpleprofile_shortname">SP</string> <string name="simpleprofile_shortname">SP</string>
<string name="quickwizard">QuickWizard</string> <string name="quickwizard">QuickWizard</string>
<string name="quickwizardsettings">Impostazioni QuickWizard</string> <string name="quickwizardsettings">Impostazioni QuickWizard</string>
<string name="profileviewer">Profilo NS</string> <string name="nsprofile">Profilo NS</string>
<string name="profile_set_ok">Profilo Basale aggiornato nel Micro</string> <string name="profile_set_ok">Profilo Basale aggiornato nel Micro</string>
<string name="profile_set_failed">Impostazione Profilo Basale fallito</string> <string name="profile_set_failed">Impostazione Profilo Basale fallito</string>
</resources> </resources>

View file

@ -71,7 +71,7 @@
<string name="objectives">목표</string> <string name="objectives">목표</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">개요</string> <string name="overview">개요</string>
<string name="profileviewer">NS 프로파일</string> <string name="nsprofile">NS 프로파일</string>
<string name="simpleprofile">Simple 프로파일</string> <string name="simpleprofile">Simple 프로파일</string>
<string name="tempbasal">임시기초</string> <string name="tempbasal">임시기초</string>
<string name="treatments">관리</string> <string name="treatments">관리</string>

View file

@ -426,7 +426,7 @@
<string name="openapsma_inputparameters_label">Berekende gegevens</string> <string name="openapsma_inputparameters_label">Berekende gegevens</string>
<string name="openapsma_iobdata_label">IOB gegevens</string> <string name="openapsma_iobdata_label">IOB gegevens</string>
<string name="openapsma_maxbasal_summary">DIt is de maximale waarde waarop het basaal door OpenAPS ingesteld kan worden</string> <string name="openapsma_maxbasal_summary">DIt is de maximale waarde waarop het basaal door OpenAPS ingesteld kan worden</string>
<string name="profileviewer">NS Profiel</string> <string name="nsprofile">NS Profiel</string>
<string name="profileviewer_shortname">NSPROFIEL</string> <string name="profileviewer_shortname">NSPROFIEL</string>
<string name="pump">Pomp</string> <string name="pump">Pomp</string>
<string name="overview_tempbasal_button">Tijdelijk basaal</string> <string name="overview_tempbasal_button">Tijdelijk basaal</string>

View file

@ -75,7 +75,7 @@
<string name="objectives">Zadania</string> <string name="objectives">Zadania</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Przegląd</string> <string name="overview">Przegląd</string>
<string name="profileviewer">NS Profil</string> <string name="nsprofile">NS Profil</string>
<string name="simpleprofile">Prosty profil</string> <string name="simpleprofile">Prosty profil</string>
<string name="tempbasal">TymczasowaBaza</string> <string name="tempbasal">TymczasowaBaza</string>
<string name="treatments">Leczenie</string> <string name="treatments">Leczenie</string>

View file

@ -69,7 +69,7 @@
<string name="objectives">Obiective</string> <string name="objectives">Obiective</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Privire ansamblu</string> <string name="overview">Privire ansamblu</string>
<string name="profileviewer">Profil NS</string> <string name="nsprofile">Profil NS</string>
<string name="simpleprofile">Profil simplu</string> <string name="simpleprofile">Profil simplu</string>
<string name="treatments">Tratamente</string> <string name="treatments">Tratamente</string>
<string name="virtualpump">Pompă virtuală</string> <string name="virtualpump">Pompă virtuală</string>

View file

@ -374,7 +374,7 @@
<string name="profile">профиль</string> <string name="profile">профиль</string>
<string name="profile_set_failed">настройка базального профиля не состоялась</string> <string name="profile_set_failed">настройка базального профиля не состоялась</string>
<string name="profile_set_ok">базальный профиль помпы обновлен</string> <string name="profile_set_ok">базальный профиль помпы обновлен</string>
<string name="profileviewer">профиль NS</string> <string name="nsprofile">профиль NS</string>
<string name="profileviewer_shortname">профильNS</string> <string name="profileviewer_shortname">профильNS</string>
<string name="pumpNotInitialized">помпа не инициализирована</string> <string name="pumpNotInitialized">помпа не инициализирована</string>
<string name="pumpNotInitializedProfileNotSet">помпа не инициализирована, профиль не установлен</string> <string name="pumpNotInitializedProfileNotSet">помпа не инициализирована, профиль не установлен</string>

View file

@ -430,7 +430,7 @@
<string name="pumpNotInitialized">Pump inte initierad</string> <string name="pumpNotInitialized">Pump inte initierad</string>
<string name="pump">Pump</string> <string name="pump">Pump</string>
<string name="profileviewer_shortname">NSProfil</string> <string name="profileviewer_shortname">NSProfil</string>
<string name="profileviewer">NS-profil</string> <string name="nsprofile">NS-profil</string>
<string name="profileswitch">Profilbyte</string> <string name="profileswitch">Profilbyte</string>
<string name="profile_set_ok">Basalprofilen uppdaterad i pumpen</string> <string name="profile_set_ok">Basalprofilen uppdaterad i pumpen</string>
<string name="profile_set_failed">Lyckades inte sätta basalprofilen</string> <string name="profile_set_failed">Lyckades inte sätta basalprofilen</string>

View file

@ -74,7 +74,7 @@
<string name="objectives">Objectives</string> <string name="objectives">Objectives</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
<string name="overview">Overview</string> <string name="overview">Overview</string>
<string name="profileviewer">NS Profile</string> <string name="nsprofile">NS Profile</string>
<string name="simpleprofile">Simple profile</string> <string name="simpleprofile">Simple profile</string>
<string name="tempbasal">TempBasal</string> <string name="tempbasal">TempBasal</string>
<string name="treatments">Treatments</string> <string name="treatments">Treatments</string>
@ -1057,11 +1057,10 @@
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string> <string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
<string name="wear_display_settings">Display Settings</string> <string name="wear_display_settings">Display Settings</string>
<string name="wear_general_settings">General Settings</string> <string name="wear_general_settings">General Settings</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
<string name="enable_nsclient">Enable NSClient</string> <string name="enable_nsclient">Enable NSClient</string>
<string name="welcometosetupwizard">Welcome to setup wizard. It will guide you through the setup process</string> <string name="welcometosetupwizard">Welcome to setup wizard. It will guide you through the setup process</string>
<string name="pumpsetup">Pump setup</string> <string name="pumpsetup">Pump setup</string>
<string name="readstatus">Read status</string> <string name="readstatus">Read status</string>
<string name="adjustprofileinns">Changes must be done in NS</string>
</resources> </resources>