DanaR as profile source
This commit is contained in:
parent
076135195b
commit
3127870770
|
@ -23,8 +23,8 @@ android {
|
|||
applicationId "info.nightscout.androidaps"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 23
|
||||
versionCode 1006
|
||||
versionName "1.0.06"
|
||||
versionCode 1007
|
||||
versionName "1.0.07"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -15,13 +15,14 @@ public interface PluginBase {
|
|||
int CONSTRAINTS = 7;
|
||||
int LOOP = 8;
|
||||
int BGSOURCE = 9;
|
||||
int LAST = 10; // keep always highest number
|
||||
|
||||
public int getType();
|
||||
|
||||
String getName();
|
||||
boolean isEnabled();
|
||||
boolean isVisibleInTabs();
|
||||
boolean canBeHidden();
|
||||
void setFragmentEnabled(boolean fragmentEnabled);
|
||||
void setFragmentVisible(boolean fragmentVisible);
|
||||
boolean isEnabled(int type);
|
||||
boolean isVisibleInTabs(int type);
|
||||
boolean canBeHidden(int type);
|
||||
void setFragmentEnabled(int type, boolean fragmentEnabled);
|
||||
void setFragmentVisible(int type, boolean fragmentVisible);
|
||||
}
|
|
@ -101,27 +101,27 @@ public class CareportalFragment extends Fragment implements PluginBase, View.OnC
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -327,6 +327,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
break;
|
||||
case R.id.careportal_announcement:
|
||||
data.put("eventType", "Announcement");
|
||||
data.put("isAnnouncement", true);
|
||||
break;
|
||||
case R.id.careportal_cgmsensorinsert:
|
||||
data.put("eventType", "Sensor Change");
|
||||
|
|
|
@ -145,31 +145,31 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
|
||||
void setViews() {
|
||||
// TODO: hide empty categories
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE));
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE), PluginBase.BGSOURCE);
|
||||
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
||||
setListViewHeightBasedOnChildren(bgsourceListView);
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP), PluginBase.PUMP);
|
||||
pumpListView.setAdapter(pumpDataAdapter);
|
||||
setListViewHeightBasedOnChildren(pumpListView);
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.LOOP));
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.LOOP), PluginBase.LOOP);
|
||||
loopListView.setAdapter(loopDataAdapter);
|
||||
setListViewHeightBasedOnChildren(loopListView);
|
||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TREATMENT));
|
||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TREATMENT), PluginBase.TREATMENT);
|
||||
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(treatmentsListView);
|
||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL));
|
||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL), PluginBase.TEMPBASAL);
|
||||
tempsListView.setAdapter(tempsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(tempsListView);
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PROFILE));
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsListByInterface(ProfileInterface.class), PluginBase.PROFILE);
|
||||
profileListView.setAdapter(profileDataAdapter);
|
||||
setListViewHeightBasedOnChildren(profileListView);
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.APS));
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.APS), PluginBase.APS);
|
||||
apsListView.setAdapter(apsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(apsListView);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class));
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class), PluginBase.CONSTRAINTS);
|
||||
constraintsListView.setAdapter(constraintsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(constraintsListView);
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.GENERAL));
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.GENERAL), PluginBase.GENERAL);
|
||||
generalListView.setAdapter(generalDataAdapter);
|
||||
setListViewHeightBasedOnChildren(generalListView);
|
||||
|
||||
|
@ -189,27 +189,27 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
// Always enabled
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
// Always visible
|
||||
}
|
||||
|
||||
|
@ -414,12 +414,14 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
|
||||
|
||||
private ArrayList<PluginBase> pluginList;
|
||||
final private int type;
|
||||
|
||||
public PluginCustomAdapter(Context context, int textViewResourceId,
|
||||
ArrayList<PluginBase> pluginList) {
|
||||
ArrayList<PluginBase> pluginList, int type) {
|
||||
super(context, textViewResourceId, pluginList);
|
||||
this.pluginList = new ArrayList<PluginBase>();
|
||||
this.pluginList.addAll(pluginList);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private class PluginViewHolder {
|
||||
|
@ -446,9 +448,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
public void onClick(View v) {
|
||||
CheckBox cb = (CheckBox) v;
|
||||
PluginBase plugin = (PluginBase) cb.getTag();
|
||||
plugin.setFragmentEnabled(cb.isChecked());
|
||||
if (cb.isChecked()) plugin.setFragmentVisible(true);
|
||||
onEnabledCategoryChanged(plugin);
|
||||
plugin.setFragmentEnabled(type, cb.isChecked());
|
||||
if (cb.isChecked()) plugin.setFragmentVisible(type, true);
|
||||
onEnabledCategoryChanged(plugin, type);
|
||||
storeSettings();
|
||||
}
|
||||
});
|
||||
|
@ -457,7 +459,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
public void onClick(View v) {
|
||||
CheckBox cb = (CheckBox) v;
|
||||
PluginBase plugin = (PluginBase) cb.getTag();
|
||||
plugin.setFragmentVisible(cb.isChecked());
|
||||
plugin.setFragmentVisible(type, cb.isChecked());
|
||||
storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
}
|
||||
|
@ -468,13 +470,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
|
||||
PluginBase plugin = pluginList.get(position);
|
||||
holder.name.setText(plugin.getName());
|
||||
holder.checkboxEnabled.setChecked(plugin.isEnabled());
|
||||
holder.checkboxVisible.setChecked(plugin.isVisibleInTabs());
|
||||
holder.checkboxEnabled.setChecked(plugin.isEnabled(type));
|
||||
holder.checkboxVisible.setChecked(plugin.isVisibleInTabs(type));
|
||||
holder.name.setTag(plugin);
|
||||
holder.checkboxEnabled.setTag(plugin);
|
||||
holder.checkboxVisible.setTag(plugin);
|
||||
|
||||
if (!plugin.canBeHidden()) {
|
||||
if (!plugin.canBeHidden(type)) {
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
holder.checkboxVisible.setEnabled(false);
|
||||
}
|
||||
|
@ -491,7 +493,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
|
||||
// Hide disabled profiles by default
|
||||
if (type == PluginBase.PROFILE) {
|
||||
if (!plugin.isEnabled()) {
|
||||
if (!plugin.isEnabled(type)) {
|
||||
holder.checkboxVisible.setEnabled(false);
|
||||
holder.checkboxVisible.setChecked(false);
|
||||
} else {
|
||||
|
@ -530,9 +532,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
return activeLoop;
|
||||
}
|
||||
|
||||
void onEnabledCategoryChanged(PluginBase changedPlugin) {
|
||||
void onEnabledCategoryChanged(PluginBase changedPlugin, int type) {
|
||||
int category = changedPlugin.getType();
|
||||
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||
ArrayList<PluginBase> pluginsInCategory = null;
|
||||
switch (category) {
|
||||
// Multiple selection allowed
|
||||
case PluginBase.APS:
|
||||
|
@ -541,116 +543,115 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
break;
|
||||
// Single selection allowed
|
||||
case PluginBase.PROFILE:
|
||||
case PluginBase.PUMP:
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
break;
|
||||
case PluginBase.BGSOURCE:
|
||||
case PluginBase.LOOP:
|
||||
case PluginBase.TEMPBASAL:
|
||||
case PluginBase.TREATMENT:
|
||||
boolean newSelection = changedPlugin.isEnabled();
|
||||
case PluginBase.PUMP:
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||
break;
|
||||
}
|
||||
if (pluginsInCategory != null) {
|
||||
boolean newSelection = changedPlugin.isEnabled(type);
|
||||
if (newSelection) { // new plugin selected -> disable others
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (p.getName().equals(changedPlugin.getName())) {
|
||||
// this is new selected
|
||||
} else {
|
||||
p.setFragmentEnabled(false);
|
||||
p.setFragmentEnabled(type, false);
|
||||
setViews();
|
||||
}
|
||||
}
|
||||
} else { // enable first plugin in list
|
||||
pluginsInCategory.get(0).setFragmentEnabled(true);
|
||||
pluginsInCategory.get(0).setFragmentEnabled(type, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void verifySelectionInCategories() {
|
||||
for (int category : new int[]{PluginBase.GENERAL, PluginBase.APS, PluginBase.PROFILE, PluginBase.PUMP, PluginBase.LOOP, PluginBase.TEMPBASAL, PluginBase.TREATMENT, PluginBase.BGSOURCE}) {
|
||||
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||
switch (category) {
|
||||
// Multiple selection allowed
|
||||
case PluginBase.APS:
|
||||
case PluginBase.GENERAL:
|
||||
case PluginBase.CONSTRAINTS:
|
||||
break;
|
||||
// Single selection allowed
|
||||
case PluginBase.BGSOURCE:
|
||||
activeBgSource = (BgSourceInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected bgSource interface: " + ((PluginBase) activeBgSource).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeBgSource).getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Single selection allowed
|
||||
case PluginBase.PROFILE:
|
||||
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
ArrayList<PluginBase> pluginsInCategory;
|
||||
|
||||
// PluginBase.PROFILE
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PROFILE);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected profile interface: " + ((PluginBase) activeProfile).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeProfile).getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
p.setFragmentVisible(PluginBase.PROFILE, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PluginBase.PUMP:
|
||||
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
|
||||
// PluginBase.BGSOURCE
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE);
|
||||
activeBgSource = (BgSourceInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.BGSOURCE);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected bgSource interface: " + ((PluginBase) activeBgSource).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeBgSource).getName())) {
|
||||
p.setFragmentVisible(PluginBase.BGSOURCE, false);
|
||||
}
|
||||
}
|
||||
|
||||
// PluginBase.PUMP
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(PluginBase.PUMP);
|
||||
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected pump interface: " + ((PluginBase) activePump).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activePump).getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
p.setFragmentVisible(PluginBase.PUMP, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PluginBase.LOOP:
|
||||
activeLoop = (LoopFragment) getTheOneEnabledInArray(pluginsInCategory);
|
||||
|
||||
// PluginBase.LOOP
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(PluginBase.LOOP);
|
||||
activeLoop = (LoopFragment) getTheOneEnabledInArray(pluginsInCategory, PluginBase.LOOP);
|
||||
if (activeLoop != null) {
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected loop interface: " + activeLoop.getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(activeLoop.getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
p.setFragmentVisible(PluginBase.LOOP, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PluginBase.TEMPBASAL:
|
||||
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
|
||||
// PluginBase.TEMPBASAL
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL);
|
||||
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.TEMPBASAL);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected tempbasal interface: " + ((PluginBase) activeTempBasals).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeTempBasals).getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
p.setFragmentVisible(PluginBase.TEMPBASAL, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PluginBase.TREATMENT:
|
||||
activeTreatments = (TreatmentsInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
|
||||
// PluginBase.TREATMENT
|
||||
pluginsInCategory = MainActivity.getSpecificPluginsList(PluginBase.TREATMENT);
|
||||
activeTreatments = (TreatmentsInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.TREATMENT);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected treatment interface: " + ((PluginBase) activeTreatments).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeTreatments).getName())) {
|
||||
p.setFragmentVisible(false);
|
||||
p.setFragmentVisible(PluginBase.TREATMENT, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory) {
|
||||
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory, int type) {
|
||||
PluginBase found = null;
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (p.isEnabled() && found == null) {
|
||||
if (p.isEnabled(type) && found == null) {
|
||||
found = p;
|
||||
continue;
|
||||
} else if (p.isEnabled()) {
|
||||
} else if (p.isEnabled(type)) {
|
||||
// set others disabled
|
||||
p.setFragmentEnabled(false);
|
||||
p.setFragmentEnabled(type, false);
|
||||
}
|
||||
}
|
||||
// If none enabled, enable first one
|
||||
|
@ -666,9 +667,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
|
||||
for (int type = 1; type < PluginBase.LAST; type++) {
|
||||
for (PluginBase p : pluginList) {
|
||||
editor.putBoolean("ConfigBuilder" + p.getName() + "Enabled", p.isEnabled());
|
||||
editor.putBoolean("ConfigBuilder" + p.getName() + "Visible", p.isVisibleInTabs());
|
||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getName() + "_Enabled";
|
||||
String settingVisible = "ConfigBuilder_" + p.getName() + "_Visible";
|
||||
editor.putBoolean(settingEnabled, p.isEnabled(type));
|
||||
editor.putBoolean(settingVisible, p.isVisibleInTabs(type));
|
||||
}
|
||||
}
|
||||
editor.commit();
|
||||
verifySelectionInCategories();
|
||||
|
@ -678,12 +683,16 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
private void loadSettings() {
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Loading stored settings");
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
for (int type = 1; type < PluginBase.LAST; type++) {
|
||||
for (PluginBase p : pluginList) {
|
||||
if (settings.contains("ConfigBuilder" + p.getName() + "Enabled"))
|
||||
p.setFragmentEnabled(settings.getBoolean("ConfigBuilder" + p.getName() + "Enabled", true));
|
||||
if (settings.contains("ConfigBuilder" + p.getName() + "Visible"))
|
||||
p.setFragmentVisible(settings.getBoolean("ConfigBuilder" + p.getName() + "Visible", true));
|
||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getName() + "_Enabled";
|
||||
String settingVisible = "ConfigBuilder_" + p.getName() + "_Visible";
|
||||
if (SP.contains(settingEnabled))
|
||||
p.setFragmentEnabled(type, SP.getBoolean(settingEnabled, true));
|
||||
if (SP.contains("ConfigBuilder" + p.getName() + "Visible"))
|
||||
p.setFragmentVisible(type, SP.getBoolean(settingVisible, true));
|
||||
}
|
||||
}
|
||||
verifySelectionInCategories();
|
||||
}
|
||||
|
@ -724,7 +733,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
result = result && constrain.isLoopEnabled();
|
||||
}
|
||||
return result;
|
||||
|
@ -737,7 +746,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
result = result && constrain.isClosedModeEnabled();
|
||||
}
|
||||
return result;
|
||||
|
@ -750,7 +759,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
result = result && constrain.isAutosensModeEnabled();
|
||||
}
|
||||
return result;
|
||||
|
@ -763,7 +772,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
result = result && constrain.isAMAModeEnabled();
|
||||
}
|
||||
return result;
|
||||
|
@ -775,7 +784,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
rateAfterConstrain = Math.min(constrain.applyBasalConstraints(absoluteRate), rateAfterConstrain);
|
||||
}
|
||||
return rateAfterConstrain;
|
||||
|
@ -787,7 +796,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
rateAfterConstrain = Math.min(constrain.applyBasalConstraints(percentRate), rateAfterConstrain);
|
||||
}
|
||||
return rateAfterConstrain;
|
||||
|
@ -799,7 +808,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
insulinAfterConstrain = Math.min(constrain.applyBolusConstraints(insulin), insulinAfterConstrain);
|
||||
}
|
||||
return insulinAfterConstrain;
|
||||
|
@ -811,7 +820,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
carbsAfterConstrain = Math.min(constrain.applyCarbsConstraints(carbs), carbsAfterConstrain);
|
||||
}
|
||||
return carbsAfterConstrain;
|
||||
|
@ -823,7 +832,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
maxIobAfterConstrain = Math.min(constrain.applyMaxIOBConstraints(maxIob), maxIobAfterConstrain);
|
||||
}
|
||||
return maxIobAfterConstrain;
|
||||
|
|
|
@ -333,6 +333,7 @@ public class DanaConnection {
|
|||
mSerialEngine.sendMessage(new MsgSettingPumpTime());
|
||||
mSerialEngine.sendMessage(new MsgSettingActiveProfile());
|
||||
mSerialEngine.sendMessage(new MsgSettingProfileRatios());
|
||||
mSerialEngine.sendMessage(new MsgSettingProfileRatiosAll());
|
||||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,13 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
@ -35,18 +38,18 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
|
||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SetWarnColor;
|
||||
|
||||
public class DanaRFragment extends Fragment implements PluginBase, PumpInterface, ConstraintsInterface {
|
||||
public class DanaRFragment extends Fragment implements PluginBase, PumpInterface, ConstraintsInterface, ProfileInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
|
||||
|
||||
Handler mHandler;
|
||||
|
@ -56,13 +59,16 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
|
|||
private static DanaRPump sDanaRPump = new DanaRPump();
|
||||
private static boolean useExtendedBoluses = false;
|
||||
|
||||
boolean fragmentEnabled = true;
|
||||
boolean fragmentVisible = true;
|
||||
boolean fragmentPumpEnabled = true;
|
||||
boolean fragmentProfileEnabled = true;
|
||||
boolean fragmentPumpVisible = true;
|
||||
boolean visibleNow = false;
|
||||
|
||||
Handler loopHandler = new Handler();
|
||||
Runnable refreshLoop = null;
|
||||
|
||||
NSProfile convertedProfile = null;
|
||||
|
||||
TextView lastConnectionView;
|
||||
TextView btConnectionView;
|
||||
TextView lastBolusView;
|
||||
|
@ -73,6 +79,7 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
|
|||
TextView batteryView;
|
||||
TextView reservoirView;
|
||||
TextView iobView;
|
||||
Button viewProfileButton;
|
||||
|
||||
public static DanaConnection getDanaConnection() {
|
||||
return sDanaConnection;
|
||||
|
@ -148,6 +155,16 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
|
|||
batteryView = (TextView) view.findViewById(R.id.danar_battery);
|
||||
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
|
||||
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
||||
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
||||
|
||||
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
||||
profileViewDialog.show(manager, "ProfileViewDialog");
|
||||
}
|
||||
});
|
||||
|
||||
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -225,28 +242,35 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return fragmentEnabled;
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PROFILE) return fragmentProfileEnabled;
|
||||
else if (type == PluginBase.PUMP) return fragmentPumpEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return fragmentPumpEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
return fragmentVisible;
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
if (type == PluginBase.PROFILE || type == PluginBase.CONSTRAINTS) return false;
|
||||
else if (type == PluginBase.PUMP) return fragmentPumpVisible;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
// Pump interface
|
||||
|
@ -803,5 +827,14 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
|
|||
return maxIob;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NSProfile getProfile() {
|
||||
DanaRPump pump = getDanaRPump();
|
||||
if (pump.lastSettingsRead.getTime() == 0)
|
||||
return null; // no info now
|
||||
return pump.convertedProfile;
|
||||
}
|
||||
|
||||
// TODO: daily total constraint
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.DanaR;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
||||
/**
|
||||
* Created by mike on 04.07.2016.
|
||||
*/
|
||||
|
@ -10,7 +18,7 @@ public class DanaRPump {
|
|||
public static final int UNITS_MMOL = 1;
|
||||
|
||||
Date lastConnection = new Date(0);
|
||||
Date lastSettingsRead = new Date(0);
|
||||
public Date lastSettingsRead = new Date(0);
|
||||
|
||||
// Info
|
||||
public String serialNumber = "";
|
||||
|
@ -56,19 +64,19 @@ public class DanaRPump {
|
|||
public int easyBasalMode;
|
||||
public boolean basal48Enable = false;
|
||||
public int currentCIR;
|
||||
public int currentCF;
|
||||
public int currentAI;
|
||||
public int currentTarget;
|
||||
public double currentCF;
|
||||
public double currentAI;
|
||||
public double currentTarget;
|
||||
public int currentAIDR;
|
||||
|
||||
public int morningCIR;
|
||||
public int morningCF;
|
||||
public double morningCF;
|
||||
public int afternoonCIR;
|
||||
public int afternoonCF;
|
||||
public double afternoonCF;
|
||||
public int eveningCIR;
|
||||
public int eveningCF;
|
||||
public double eveningCF;
|
||||
public int nightCIR;
|
||||
public int nightCF;
|
||||
public double nightCF;
|
||||
|
||||
|
||||
public int activeProfile = 0;
|
||||
|
@ -77,4 +85,65 @@ public class DanaRPump {
|
|||
//Limits
|
||||
public double maxBolus;
|
||||
public double maxBasal;
|
||||
|
||||
NSProfile convertedProfile = null;
|
||||
|
||||
public void createConvertedProfile() {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject store = new JSONObject();
|
||||
JSONObject profile = new JSONObject();
|
||||
|
||||
// Morning / 6:00–10:59
|
||||
// Afternoon / 11:00–16:59
|
||||
// Evening / 17:00–21:59
|
||||
// Night / 22:00–5:59
|
||||
|
||||
try {
|
||||
json.put("defaultProfile", "" + (activeProfile + 1));
|
||||
json.put("store", store);
|
||||
profile.put("dia", 3); // TODO: fixed DIA, maybe would be needed to have it configurable in settings
|
||||
|
||||
JSONArray carbratios = new JSONArray();
|
||||
carbratios.put(new JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCF));
|
||||
carbratios.put(new JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCF));
|
||||
carbratios.put(new JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCF));
|
||||
carbratios.put(new JSONObject().put("time", "14:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCF));
|
||||
carbratios.put(new JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCF));
|
||||
profile.put("carbratio", carbratios);
|
||||
|
||||
profile.put("carbs_hr", 20); // TODO: fixed CAR, maybe would be needed to have it configurable in settings
|
||||
|
||||
JSONArray sens = new JSONArray();
|
||||
sens.put(new JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCIR));
|
||||
sens.put(new JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCIR));
|
||||
sens.put(new JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCIR));
|
||||
sens.put(new JSONObject().put("time", "17:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCIR));
|
||||
sens.put(new JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCIR));
|
||||
profile.put("sens", sens);
|
||||
|
||||
JSONArray basals = new JSONArray();
|
||||
int basalValues = basal48Enable ? 48 : 24;
|
||||
int basalIncrement = basal48Enable ? 30 * 60 : 60 * 60;
|
||||
for (int h = 0; h < basalValues; h++) {
|
||||
String time;
|
||||
DecimalFormat df = new DecimalFormat("00");
|
||||
if (basal48Enable) {
|
||||
time = df.format((long) h / 2) + ":" + df.format(30 * (h % 2));
|
||||
} else {
|
||||
time = df.format(h) + ":00";
|
||||
}
|
||||
basals.put(new JSONObject().put("time", time).put("timeAsSeconds", h * basalIncrement).put("value", pumpProfiles[activeProfile][h]));
|
||||
}
|
||||
profile.put("basal", basals);
|
||||
|
||||
profile.put("target_low", new JSONArray().put(new JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", currentTarget)));
|
||||
profile.put("target_high", new JSONArray().put(new JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", currentTarget)));
|
||||
profile.put("units", units == UNITS_MGDL ? Constants.MGDL : Constants.MMOL);
|
||||
store.put("" + (activeProfile + 1), profile);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
convertedProfile = new NSProfile(json, "" + (activeProfile + 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package info.nightscout.androidaps.plugins.DanaR.Dialogs;
|
||||
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
||||
/**
|
||||
* Created by mike on 10.07.2016.
|
||||
*/
|
||||
public class ProfileViewDialog extends DialogFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class);
|
||||
|
||||
private static TextView noProfile;
|
||||
private static TextView units;
|
||||
private static TextView dia;
|
||||
private static TextView activeProfile;
|
||||
private static TextView ic;
|
||||
private static TextView isf;
|
||||
private static TextView basal;
|
||||
private static TextView target;
|
||||
|
||||
private static Button refreshButton;
|
||||
|
||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||
|
||||
Handler mHandler;
|
||||
static HandlerThread mHandlerThread;
|
||||
|
||||
NSProfile profile = null;
|
||||
|
||||
public ProfileViewDialog() {
|
||||
mHandlerThread = new HandlerThread(ProfileViewDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
profile = ((DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class)).getProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.nsprofileviewer_fragment, container, false);
|
||||
|
||||
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
|
||||
units = (TextView) layout.findViewById(R.id.profileview_units);
|
||||
dia = (TextView) layout.findViewById(R.id.profileview_dia);
|
||||
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
|
||||
ic = (TextView) layout.findViewById(R.id.profileview_ic);
|
||||
isf = (TextView) layout.findViewById(R.id.profileview_isf);
|
||||
basal = (TextView) layout.findViewById(R.id.profileview_basal);
|
||||
target = (TextView) layout.findViewById(R.id.profileview_target);
|
||||
refreshButton = (Button) layout.findViewById(R.id.profileview_reload);
|
||||
refreshButton.setVisibility(View.VISIBLE);
|
||||
refreshButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DanaRFragment.getDanaRPump().lastSettingsRead = new Date(0);
|
||||
DanaRFragment.getDanaConnection().connectIfNotConnected("ProfileViewDialog");
|
||||
//refreshButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
//refreshButton.setVisibility(View.GONE);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
setContent();
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
if (profile == null) {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
} else {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
}
|
||||
units.setText(profile.getUnits());
|
||||
dia.setText(formatNumber2decimalplaces.format(profile.getDia()) + " h");
|
||||
activeProfile.setText(profile.getActiveProfile());
|
||||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
target.setText(profile.getTargetList());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -21,15 +21,15 @@ public class MsgSettingProfileRatios extends DanaRMessage {
|
|||
if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) {
|
||||
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2);
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2);
|
||||
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 6, 1);
|
||||
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 8, 1);
|
||||
} else {
|
||||
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 6, 1);
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 8, 1);
|
||||
}
|
||||
|
||||
if (Config.logDanaMessageDetail) {
|
||||
|
|
|
@ -29,13 +29,13 @@ public class MsgSettingProfileRatiosAll extends DanaRMessage {
|
|||
DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2);
|
||||
} else {
|
||||
DanaRFragment.getDanaRPump().morningCIR = intFromBuff(bytes, 0, 2);
|
||||
DanaRFragment.getDanaRPump().morningCF = intFromBuff(bytes, 2, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().morningCF = intFromBuff(bytes, 2, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().afternoonCIR = intFromBuff(bytes, 4, 2);
|
||||
DanaRFragment.getDanaRPump().afternoonCF = intFromBuff(bytes, 6, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().afternoonCF = intFromBuff(bytes, 6, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().eveningCIR = intFromBuff(bytes, 8, 2);
|
||||
DanaRFragment.getDanaRPump().eveningCF = intFromBuff(bytes, 10, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().eveningCF = intFromBuff(bytes, 10, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().nightCIR = intFromBuff(bytes, 12, 2);
|
||||
DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2) / 100d;
|
||||
}
|
||||
|
||||
if (Config.logDanaMessageDetail) {
|
||||
|
@ -49,6 +49,7 @@ public class MsgSettingProfileRatiosAll extends DanaRMessage {
|
|||
log.debug("Current pump night CIR: " + DanaRFragment.getDanaRPump().nightCIR);
|
||||
log.debug("Current pump night CF: " + DanaRFragment.getDanaRPump().nightCF);
|
||||
}
|
||||
}
|
||||
|
||||
DanaRFragment.getDanaRPump().createConvertedProfile();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ public class MsgStatusProfile extends DanaRMessage {
|
|||
if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) {
|
||||
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2);
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2);
|
||||
} else {
|
||||
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100;
|
||||
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
|
||||
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100d;
|
||||
}
|
||||
|
||||
if (Config.logDanaMessageDetail) {
|
||||
|
|
|
@ -116,27 +116,27 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
@ -229,14 +229,14 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
|||
ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder();
|
||||
APSResult result = null;
|
||||
|
||||
if (constraintsInterface == null || configBuilder == null || !isEnabled())
|
||||
if (constraintsInterface == null || configBuilder == null || !isEnabled(PluginBase.GENERAL))
|
||||
return;
|
||||
|
||||
APSInterface usedAPS = null;
|
||||
ArrayList<PluginBase> apsPlugins = MainActivity.getSpecificPluginsList(PluginBase.APS);
|
||||
for (PluginBase p : apsPlugins) {
|
||||
APSInterface aps = (APSInterface) p;
|
||||
if (!p.isEnabled()) continue;
|
||||
if (!p.isEnabled(PluginBase.APS)) continue;
|
||||
aps.invoke();
|
||||
result = aps.getLastAPSResult();
|
||||
if (result == null) continue;
|
||||
|
|
|
@ -118,27 +118,27 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
|||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
|
||||
if (!isEnabled()) {
|
||||
if (!isEnabled(PluginBase.APS)) {
|
||||
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
if (Config.logAPSResult)
|
||||
log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
|
|
|
@ -61,27 +61,27 @@ public class NSProfileViewerFragment extends Fragment implements PluginBase, Pro
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,26 +54,26 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ public class DetermineBasalAdapterJS implements Parcelable {
|
|||
mProfile.add("min_bg", minBg);
|
||||
mProfile.add("max_bg", maxBg);
|
||||
mProfile.add("carbratio", profile.getIc(profile.secondsFromMidnight()));
|
||||
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(profile.secondsFromMidnight()).doubleValue(), units));
|
||||
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
|
||||
|
||||
mProfile.add("current_basal", pump.getBaseBasalRate());
|
||||
mCurrentTemp.add("duration", pump.getTempBasalRemainingMinutes());
|
||||
|
|
|
@ -107,27 +107,27 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
|||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
|
||||
if (!isEnabled()) {
|
||||
if (!isEnabled(PluginBase.APS)) {
|
||||
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
if (Config.logAPSResult)
|
||||
log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
|
|
|
@ -102,27 +102,27 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
// Always enabled
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
// Always visible
|
||||
}
|
||||
|
||||
|
|
|
@ -34,27 +34,27 @@ public class SafetyFragment extends Fragment implements PluginBase, ConstraintsI
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int tyep, boolean fragmentEnabled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
}
|
||||
|
||||
public static SafetyFragment newInstance() {
|
||||
|
|
|
@ -77,27 +77,27 @@ public class SimpleProfileFragment extends Fragment implements PluginBase, Profi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,27 +31,27 @@ public class SourceNSClientFragment extends Fragment implements PluginBase, BgSo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,27 +32,27 @@ public class SourceXdripFragment extends Fragment implements PluginBase, BgSourc
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
}
|
||||
|
||||
public static SourceXdripFragment newInstance() {
|
||||
|
|
|
@ -72,27 +72,27 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,27 +73,27 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,26 +58,27 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs() {
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(boolean fragmentVisible) {
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
|
||||
import info.nightscout.androidaps.plugins.DanaR.Services.DanaRService;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
|||
|
||||
log.debug("KeepAlive received");
|
||||
DanaRFragment danaRFragment = (DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class);
|
||||
if (Config.DANAR && danaRFragment != null && danaRFragment.isEnabled()) {
|
||||
if (Config.DANAR && danaRFragment != null && danaRFragment.isEnabled(PluginBase.PUMP)) {
|
||||
Intent intent = new Intent(context, DanaRService.class);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
|||
public void registerNewFragment(Fragment fragment) {
|
||||
PluginBase plugin = (PluginBase) fragment;
|
||||
fragmentList.add(plugin);
|
||||
if (plugin.isVisibleInTabs()) {
|
||||
if (plugin.isVisibleInTabs(plugin.getType())) {
|
||||
visibleFragmentList.add(plugin);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class NSProfile {
|
|||
JSONObject profile = getDefaultProfile();
|
||||
if (profile != null) {
|
||||
try {
|
||||
return getValuesList(profile.getJSONArray("carbratio"), null, new DecimalFormat("0"), "g");
|
||||
return getValuesList(profile.getJSONArray("carbratio"), null, new DecimalFormat("0.0"), "g");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -250,6 +250,18 @@
|
|||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/danar_viewprofile"
|
||||
android:id="@+id/danar_viewprofile" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
@ -113,6 +113,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reloadprofile"
|
||||
android:id="@+id/profileview_reload"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
|
|
@ -234,5 +234,7 @@
|
|||
<string name="hoursago">h ago</string>
|
||||
<string name="danar_invalidinput">Invalid input data</string>
|
||||
<string name="danar_valuenotsetproperly">Value not set properly</string>
|
||||
<string name="reloadprofile">Reload profile</string>
|
||||
<string name="danar_viewprofile">View profile</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue