SW Import settings, Skip wizard

This commit is contained in:
Milos Kozak 2018-05-10 23:59:20 +02:00
parent 0beccdea54
commit 376fffa6ec
5 changed files with 21 additions and 5 deletions

View file

@ -8,6 +8,7 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -34,6 +35,7 @@ import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin; 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.ImportExportPrefs;
import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.LocaleHelper;
import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.PasswordProtection;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -67,6 +69,13 @@ public class SWDefinition {
add(new SWScreen(R.string.nav_setupwizard) add(new SWScreen(R.string.nav_setupwizard)
.add(new SWInfotext() .add(new SWInfotext()
.label(R.string.welcometosetupwizard)) .label(R.string.welcometosetupwizard))
.add(new SWButton()
.text(R.string.nav_import)
.action(() -> ImportExportPrefs.importSharedPreferences(getActivity()))
.visibility(ImportExportPrefs.file::exists))
.add(new SWButton()
.text(R.string.exitwizard)
.action(() -> getActivity().finish()))
) )
.add(new SWScreen(R.string.language) .add(new SWScreen(R.string.language)
.skippable(false) .skippable(false)
@ -239,7 +248,7 @@ public class SWDefinition {
.add(new SWInfotext() .add(new SWInfotext()
.label(R.string.setupwizard_objectives_description)) .label(R.string.setupwizard_objectives_description))
.add(new SWButton() .add(new SWButton()
.text(R.string.objectives_button_start) .text(R.string.enableobjectives)
.action(() -> { .action(() -> {
ObjectivesPlugin.getPlugin().setPluginEnabled(PluginType.CONSTRAINTS, true); ObjectivesPlugin.getPlugin().setPluginEnabled(PluginType.CONSTRAINTS, true);
ObjectivesPlugin.getPlugin().setFragmentVisible(PluginType.CONSTRAINTS, true); ObjectivesPlugin.getPlugin().setFragmentVisible(PluginType.CONSTRAINTS, true);

View file

@ -18,6 +18,7 @@ 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.EventProfileStoreChanged;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
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;
@ -95,6 +96,11 @@ public class SetupWizardActivity extends AppCompatActivity {
updateButtons(); updateButtons();
} }
@Subscribe
public void onEventProfileStoreChanged(EventProfileSwitchChange 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));

View file

@ -33,7 +33,7 @@ import info.nightscout.androidaps.events.EventAppExit;
public class ImportExportPrefs { public class ImportExportPrefs {
private static Logger log = LoggerFactory.getLogger(ImportExportPrefs.class); private static Logger log = LoggerFactory.getLogger(ImportExportPrefs.class);
static File path = new File(Environment.getExternalStorageDirectory().toString()); static File path = new File(Environment.getExternalStorageDirectory().toString());
static final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences"); static public final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences");
private static final int REQUEST_EXTERNAL_STORAGE = 1; private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = { private static String[] PERMISSIONS_STORAGE = {

View file

@ -545,7 +545,7 @@
<string name="overview_extendedbolus_cancel_button">Zrušit prodloužený bolus</string> <string name="overview_extendedbolus_cancel_button">Zrušit prodloužený bolus</string>
<string name="overview_newtempbasal_basalabsolute">Hodnota bazálu [U/h]</string> <string name="overview_newtempbasal_basalabsolute">Hodnota bazálu [U/h]</string>
<string name="overview_newtempbasal_basaltype_label">Typ bazálu</string> <string name="overview_newtempbasal_basaltype_label">Typ bazálu</string>
<string name="profileswitch">PřepnutíProfilu</string> <string name="profileswitch">Přepnutí profilu</string>
<string name="pump">Pumpa</string> <string name="pump">Pumpa</string>
<string name="xdripstatus">Statusový řádek xDripu (hodinky)</string> <string name="xdripstatus">Statusový řádek xDripu (hodinky)</string>
<string name="xdripstatus_settings">Status z xDripu (hodinky)</string> <string name="xdripstatus_settings">Status z xDripu (hodinky)</string>

View file

@ -1063,9 +1063,10 @@
<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> <string name="adjustprofileinns">Changes must be done in NS</string>
<string name="exitwizard">Exit setup wizard?</string> <string name="exitwizard">Skip setup wizard</string>
<string name="setupwizard_bgsource_description">Where should blood glucose(BG) data be comming from ?</string> <string name="setupwizard_bgsource_description">Where should blood glucose(BG) data be comming from ?</string>
<string name="setupwizard_loop_description">Press the button below to enable AndroidAPS to suggest/make basal changes</string> <string name="setupwizard_loop_description">Press the button below to enable AndroidAPS to suggest/make basal changes</string>
<string name="setupwizard_objectives_description">Press the button below to enable Objectives. Look in the Objectives tab, after you finish this wizard, to make AndroidAPS completely functional.</string> <string name="setupwizard_objectives_description">Press the button below to enable Objectives. Look in the Objectives tab, after you finish this wizard, to make AndroidAPS completely functional.</string>
<string name="enableobjectives">Enable Objectives</string>
</resources> </resources>