more
This commit is contained in:
parent
71c474ef5f
commit
64b5783e4a
4 changed files with 195 additions and 5 deletions
|
@ -83,6 +83,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
.pluginName(R.string.danarspump)
|
||||
.shortName(R.string.danarspump_shortname)
|
||||
.preferencesId(R.xml.pref_danars)
|
||||
.description(R.string.description_pump_dana_rs)
|
||||
);
|
||||
|
||||
pumpDescription.isBolusCapable = true;
|
||||
|
|
|
@ -66,6 +66,7 @@ public class MessageHashTable_v2 {
|
|||
put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
||||
put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||
put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
||||
put(new MsgSetUserOptions()); // 0x330B CMD_SETTING_USER_OPTIONS_S
|
||||
put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
||||
put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE
|
||||
put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.PreferencesActivity;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -85,8 +86,14 @@ public class SWDefinition {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
SWDefinition() {
|
||||
if (BuildConfig.FLAVOR.equals("full"))
|
||||
SWDefinitionFull();
|
||||
else if (BuildConfig.FLAVOR.equals("nsclient"))
|
||||
SWDefinitionNSClient();
|
||||
}
|
||||
|
||||
private void SWDefinitionFull() {
|
||||
// List all the screens here
|
||||
add(new SWScreen(R.string.nav_setupwizard)
|
||||
.add(new SWInfotext()
|
||||
|
@ -228,6 +235,7 @@ public class SWDefinition {
|
|||
.add(new SWBreak())
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.INSULIN)
|
||||
.makeVisible(false)
|
||||
.label(R.string.configbuilder_insulin))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
|
@ -441,4 +449,177 @@ public class SWDefinition {
|
|||
;
|
||||
}
|
||||
|
||||
private void SWDefinitionNSClient() {
|
||||
// List all the screens here
|
||||
add(new SWScreen(R.string.nav_setupwizard)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.welcometosetupwizard))
|
||||
.add(new SWButton()
|
||||
.text(R.string.nav_import)
|
||||
.action(() -> ImportExportPrefs.importSharedPreferences(getActivity()))
|
||||
.visibility(ImportExportPrefs.file::exists))
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.backupismissing)
|
||||
.visibility(() -> !ImportExportPrefs.file.exists()))
|
||||
)
|
||||
.add(new SWScreen(R.string.language)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.languagesArray, R.array.languagesValues)
|
||||
.preferenceId(R.string.key_language).label(R.string.language)
|
||||
.comment(R.string.setupwizard_language_prompt))
|
||||
.validator(() -> {
|
||||
String lang = SP.getString("language", "en");
|
||||
LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang);
|
||||
return SP.contains(R.string.key_language);
|
||||
})
|
||||
)
|
||||
.add(new SWScreen(R.string.end_user_license_agreement)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.end_user_license_agreement_text))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.end_user_license_agreement_i_understand)
|
||||
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
||||
.action(() -> {
|
||||
SP.putBoolean(R.string.key_i_understand, true);
|
||||
MainApp.bus().post(new EventSWUpdate(false));
|
||||
}))
|
||||
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
||||
.validator(() -> SP.getBoolean(R.string.key_i_understand, false))
|
||||
)
|
||||
.add(new SWScreen(R.string.permission)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name))))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.askforpermission)
|
||||
.visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))
|
||||
.action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, AndroidPermission.CASE_BATTERY)))
|
||||
.visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))
|
||||
.validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)))
|
||||
)
|
||||
.add(new SWScreen(R.string.permission)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(MainApp.gs(R.string.needstoragepermission)))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.askforpermission)
|
||||
.visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE))
|
||||
.action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, AndroidPermission.CASE_STORAGE)))
|
||||
.visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE))
|
||||
.validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)))
|
||||
)
|
||||
.add(new SWScreen(R.string.nsclientinternal_title)
|
||||
.skippable(true)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.nsclientinfotext))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.enable_nsclient)
|
||||
.action(() -> {
|
||||
NSClientPlugin.getPlugin().setPluginEnabled(PluginType.GENERAL, true);
|
||||
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
MainApp.bus().post(new EventSWUpdate(true));
|
||||
})
|
||||
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
||||
.add(new SWEditUrl()
|
||||
.preferenceId(R.string.key_nsclientinternal_url)
|
||||
.label(R.string.nsclientinternal_url_title)
|
||||
.comment(R.string.nsclientinternal_url_dialogmessage))
|
||||
.add(new SWEditString()
|
||||
.validator(text -> text.length() >= 12)
|
||||
.preferenceId(R.string.key_nsclientinternal_api_secret)
|
||||
.label(R.string.nsclientinternal_secret_dialogtitle)
|
||||
.comment(R.string.nsclientinternal_secret_dialogmessage))
|
||||
.add(new SWBreak())
|
||||
.add(new SWEventListener(this)
|
||||
.label(R.string.status)
|
||||
.initialStatus(NSClientPlugin.getPlugin().status)
|
||||
.listener(new Object() {
|
||||
@Subscribe
|
||||
public void onEventNSClientStatus(EventNSClientStatus event) {
|
||||
MainApp.bus().post(new EventSWLabel(event.status));
|
||||
}
|
||||
})
|
||||
)
|
||||
.add(new SWBreak())
|
||||
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth)
|
||||
.visibility(() -> !(NSClientPlugin.getPlugin().nsClientService != null && NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth))
|
||||
)
|
||||
.add(new SWScreen(R.string.patientage)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.patientage_summary))
|
||||
.add(new SWBreak())
|
||||
.add(new SWRadioButton()
|
||||
.option(R.array.ageArray, R.array.ageValues)
|
||||
.preferenceId(R.string.key_age)
|
||||
.label(R.string.patientage)
|
||||
.comment(R.string.patientage_summary))
|
||||
.validator(() -> SP.contains(R.string.key_age))
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_insulin)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(MainApp.gs(R.string.rapid_acting_oref) + ": " + MainApp.gs(R.string.fastactinginsulincomment)))
|
||||
.add(new SWInfotext()
|
||||
.label(MainApp.gs(R.string.ultrarapid_oref) + ": " + MainApp.gs(R.string.ultrafastactinginsulincomment)))
|
||||
.add(new SWInfotext()
|
||||
.label(MainApp.gs(R.string.free_peak_oref) + ": " + MainApp.gs(R.string.free_peak_oref_description)))
|
||||
.add(new SWBreak())
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.diawarning))
|
||||
.add(new SWBreak())
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.INSULIN)
|
||||
.makeVisible(false)
|
||||
.label(R.string.configbuilder_insulin))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.insulinsourcesetup)
|
||||
.action(() -> {
|
||||
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveInsulin();
|
||||
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
|
||||
Intent i = new Intent(activity, PreferencesActivity.class);
|
||||
i.putExtra("id", plugin.getPreferencesId());
|
||||
activity.startActivity(i);
|
||||
}, null);
|
||||
})
|
||||
.visibility(() -> MainApp.getConfigBuilder().getActiveInsulin()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveInsulin()).getPreferencesId() > 0))
|
||||
.validator(() -> MainApp.getConfigBuilder().getActiveInsulin() != null)
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_sensitivity)
|
||||
.skippable(false)
|
||||
.add(new SWInfotext()
|
||||
.label(R.string.setupwizard_sensitivity_description))
|
||||
.add(new SWHtmlLink()
|
||||
.label(R.string.setupwizard_sensitivity_url))
|
||||
.add(new SWBreak())
|
||||
.add(new SWPlugin()
|
||||
.option(PluginType.SENSITIVITY)
|
||||
.label(R.string.configbuilder_sensitivity))
|
||||
.add(new SWBreak())
|
||||
.add(new SWButton()
|
||||
.text(R.string.sensitivitysetup)
|
||||
.action(() -> {
|
||||
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveSensitivity();
|
||||
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
|
||||
Intent i = new Intent(activity, PreferencesActivity.class);
|
||||
i.putExtra("id", plugin.getPreferencesId());
|
||||
activity.startActivity(i);
|
||||
}, null);
|
||||
})
|
||||
.visibility(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null && ((PluginBase) MainApp.getConfigBuilder().getActiveSensitivity()).getPreferencesId() > 0))
|
||||
.validator(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,8 @@ public class SWPlugin extends SWItem {
|
|||
private PluginType pType;
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
private boolean makeVisible = true;
|
||||
|
||||
public SWPlugin() {
|
||||
super(Type.PLUGIN);
|
||||
}
|
||||
|
@ -34,6 +36,11 @@ public class SWPlugin extends SWItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
public SWPlugin makeVisible(boolean makeVisible) {
|
||||
this.makeVisible = makeVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDialog(View view, LinearLayout layout) {
|
||||
Context context = view.getContext();
|
||||
|
@ -58,10 +65,10 @@ public class SWPlugin extends SWItem {
|
|||
|
||||
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
RadioButton rb = group.findViewById(checkedId);
|
||||
PluginBase plugin1 = (PluginBase) rb.getTag();
|
||||
plugin1.setPluginEnabled(pType, rb.isChecked());
|
||||
plugin1.setFragmentVisible(pType, rb.isChecked());
|
||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(plugin1, pType);
|
||||
PluginBase plugin = (PluginBase) rb.getTag();
|
||||
plugin.setPluginEnabled(pType, rb.isChecked());
|
||||
plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
|
||||
ConfigBuilderFragment.processOnEnabledCategoryChanged(plugin, pType);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
MainApp.bus().post(new EventSWUpdate());
|
||||
|
|
Loading…
Reference in a new issue