WIP: BGSOURCE screen
This commit is contained in:
parent
15f4f64c4f
commit
083730f476
|
@ -1,17 +1,28 @@
|
|||
package info.nightscout.androidaps.startupwizard;
|
||||
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class SWDefinition {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(SWDefinition.class);
|
||||
private static SWDefinition swDefinition = null;
|
||||
|
||||
public static SWDefinition getInstance() {
|
||||
|
@ -55,6 +66,48 @@ public class SWDefinition {
|
|||
.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_bgsource)
|
||||
.skippable(false)
|
||||
.add(new SWRadioButton().option(R.array.BGSourceArray, R.array.BGSourceValues).preferenceId(R.string.configbuilder_bgsource).label(R.string.configbuilder_bgsource).comment(R.string.configbuilder_bgsource))
|
||||
.validator(() -> {
|
||||
ArrayList<PluginBase> pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.BGSOURCE);
|
||||
ConfigBuilderPlugin configBuilder = ConfigBuilderPlugin.getPlugin();
|
||||
BgSourceInterface activeSource = configBuilder.getActiveBgSource();
|
||||
if (activeSource == null) {
|
||||
activeSource = SourceNSClientPlugin.getPlugin();
|
||||
configBuilder.setPluginEnabled(PluginType.BGSOURCE, true);
|
||||
}
|
||||
// this.setFragmentVisiblities(((PluginBase) activeSource).getName(), pluginsInCategory, PluginType.BGSOURCE);
|
||||
// String settingEnabled = "ConfigBuilder_" + PluginType.BGSOURCE.name() + "_" + SP.getString(R.string.configbuilder_bgsource, "SourceNSClientPlugin") + "_Enabled";
|
||||
// new plugin selected -> disable others
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
log.debug("Name is: "+ p.getClass().getSimpleName() + " setting is: "+SP.getString(R.string.configbuilder_bgsource, "SourceNSClient"));
|
||||
if (p.getClass().getSimpleName().equals(SP.getString(R.string.configbuilder_bgsource, "SourceNSClient"))) {
|
||||
// this is new selected
|
||||
p.setPluginEnabled(PluginType.BGSOURCE, true);
|
||||
p.setFragmentVisible(PluginType.BGSOURCE, true);
|
||||
String settingVisible = "ConfigBuilder_" + PluginType.BGSOURCE.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
String settingEnabled = "ConfigBuilder_" + PluginType.BGSOURCE.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
log.debug("Setting to: "+settingEnabled);
|
||||
SP.putBoolean(settingEnabled, true);
|
||||
SP.putBoolean(settingVisible, true);
|
||||
} else {
|
||||
String settingEnabled = "ConfigBuilder_" + PluginType.BGSOURCE.name() + "_" + p.getName() + "_Enabled";
|
||||
log.debug("Disable: "+settingEnabled);
|
||||
p.setPluginEnabled(PluginType.BGSOURCE, false);
|
||||
p.setFragmentVisible(PluginType.BGSOURCE, false);
|
||||
}
|
||||
}
|
||||
// Enable plugin
|
||||
// log.debug("Setting: "+settingEnabled);
|
||||
// SP.putBoolean(settingEnabled, true);
|
||||
|
||||
String settingVisible = "ConfigBuilder_" + PluginType.BGSOURCE.name() + "_" + SP.getString(R.string.configbuilder_bgsource,"SourceNSClientPlugin") + "_Visible";
|
||||
SP.putBoolean(settingVisible, true);
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
return SP.contains(R.string.configbuilder_bgsource);
|
||||
})
|
||||
)
|
||||
|
||||
;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,11 @@ import android.widget.RadioGroup;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class SWRadioButton extends SWItem {
|
||||
|
|
|
@ -105,5 +105,18 @@
|
|||
<item>@string/no</item>
|
||||
<item>@string/yes</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="BGSourceArray">
|
||||
<item>@string/xdrip</item>
|
||||
<item>@string/DexcomG5</item>
|
||||
<item>@string/nsclientbg</item>
|
||||
<item>@string/MM640g</item>
|
||||
<item>@string/Glimp</item>
|
||||
</string-array>
|
||||
<string-array name="BGSourceValues" translatable="false">
|
||||
<item>SourceXdripPlugin</item>
|
||||
<item>SourceDexcomG5Plugin</item>
|
||||
<item>SourceNSClientPlugin</item>
|
||||
<item>SourceMM640gPlugin</item>
|
||||
<item>SourceGlimpPlugin</item>
|
||||
</string-array>
|
||||
</resources>
|
Loading…
Reference in a new issue