DanaR as profile source

This commit is contained in:
Milos Kozak 2016-07-11 14:04:57 +02:00
parent 076135195b
commit 3127870770
32 changed files with 504 additions and 257 deletions

View file

@ -23,8 +23,8 @@ android {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1006 versionCode 1007
versionName "1.0.06" versionName "1.0.07"
} }
buildTypes { buildTypes {
release { release {

View file

@ -15,13 +15,14 @@ public interface PluginBase {
int CONSTRAINTS = 7; int CONSTRAINTS = 7;
int LOOP = 8; int LOOP = 8;
int BGSOURCE = 9; int BGSOURCE = 9;
int LAST = 10; // keep always highest number
public int getType(); public int getType();
String getName(); String getName();
boolean isEnabled(); boolean isEnabled(int type);
boolean isVisibleInTabs(); boolean isVisibleInTabs(int type);
boolean canBeHidden(); boolean canBeHidden(int type);
void setFragmentEnabled(boolean fragmentEnabled); void setFragmentEnabled(int type, boolean fragmentEnabled);
void setFragmentVisible(boolean fragmentVisible); void setFragmentVisible(int type, boolean fragmentVisible);
} }

View file

@ -101,27 +101,27 @@ public class CareportalFragment extends Fragment implements PluginBase, View.OnC
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -327,6 +327,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
break; break;
case R.id.careportal_announcement: case R.id.careportal_announcement:
data.put("eventType", "Announcement"); data.put("eventType", "Announcement");
data.put("isAnnouncement", true);
break; break;
case R.id.careportal_cgmsensorinsert: case R.id.careportal_cgmsensorinsert:
data.put("eventType", "Sensor Change"); data.put("eventType", "Sensor Change");

View file

@ -145,31 +145,31 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
void setViews() { void setViews() {
// TODO: hide empty categories // 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); bgsourceListView.setAdapter(bgsourceDataAdapter);
setListViewHeightBasedOnChildren(bgsourceListView); 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); pumpListView.setAdapter(pumpDataAdapter);
setListViewHeightBasedOnChildren(pumpListView); 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); loopListView.setAdapter(loopDataAdapter);
setListViewHeightBasedOnChildren(loopListView); 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); treatmentsListView.setAdapter(treatmentsDataAdapter);
setListViewHeightBasedOnChildren(treatmentsListView); 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); tempsListView.setAdapter(tempsDataAdapter);
setListViewHeightBasedOnChildren(tempsListView); 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); profileListView.setAdapter(profileDataAdapter);
setListViewHeightBasedOnChildren(profileListView); 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); apsListView.setAdapter(apsDataAdapter);
setListViewHeightBasedOnChildren(apsListView); 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); constraintsListView.setAdapter(constraintsDataAdapter);
setListViewHeightBasedOnChildren(constraintsListView); 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); generalListView.setAdapter(generalDataAdapter);
setListViewHeightBasedOnChildren(generalListView); setListViewHeightBasedOnChildren(generalListView);
@ -189,27 +189,27 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return true; return true;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return true; return true;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return false; return false;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
// Always enabled // Always enabled
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
// Always visible // Always visible
} }
@ -414,12 +414,14 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> { private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
private ArrayList<PluginBase> pluginList; private ArrayList<PluginBase> pluginList;
final private int type;
public PluginCustomAdapter(Context context, int textViewResourceId, public PluginCustomAdapter(Context context, int textViewResourceId,
ArrayList<PluginBase> pluginList) { ArrayList<PluginBase> pluginList, int type) {
super(context, textViewResourceId, pluginList); super(context, textViewResourceId, pluginList);
this.pluginList = new ArrayList<PluginBase>(); this.pluginList = new ArrayList<PluginBase>();
this.pluginList.addAll(pluginList); this.pluginList.addAll(pluginList);
this.type = type;
} }
private class PluginViewHolder { private class PluginViewHolder {
@ -446,9 +448,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
public void onClick(View v) { public void onClick(View v) {
CheckBox cb = (CheckBox) v; CheckBox cb = (CheckBox) v;
PluginBase plugin = (PluginBase) cb.getTag(); PluginBase plugin = (PluginBase) cb.getTag();
plugin.setFragmentEnabled(cb.isChecked()); plugin.setFragmentEnabled(type, cb.isChecked());
if (cb.isChecked()) plugin.setFragmentVisible(true); if (cb.isChecked()) plugin.setFragmentVisible(type, true);
onEnabledCategoryChanged(plugin); onEnabledCategoryChanged(plugin, type);
storeSettings(); storeSettings();
} }
}); });
@ -457,7 +459,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
public void onClick(View v) { public void onClick(View v) {
CheckBox cb = (CheckBox) v; CheckBox cb = (CheckBox) v;
PluginBase plugin = (PluginBase) cb.getTag(); PluginBase plugin = (PluginBase) cb.getTag();
plugin.setFragmentVisible(cb.isChecked()); plugin.setFragmentVisible(type, cb.isChecked());
storeSettings(); storeSettings();
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
} }
@ -468,13 +470,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
PluginBase plugin = pluginList.get(position); PluginBase plugin = pluginList.get(position);
holder.name.setText(plugin.getName()); holder.name.setText(plugin.getName());
holder.checkboxEnabled.setChecked(plugin.isEnabled()); holder.checkboxEnabled.setChecked(plugin.isEnabled(type));
holder.checkboxVisible.setChecked(plugin.isVisibleInTabs()); holder.checkboxVisible.setChecked(plugin.isVisibleInTabs(type));
holder.name.setTag(plugin); holder.name.setTag(plugin);
holder.checkboxEnabled.setTag(plugin); holder.checkboxEnabled.setTag(plugin);
holder.checkboxVisible.setTag(plugin); holder.checkboxVisible.setTag(plugin);
if (!plugin.canBeHidden()) { if (!plugin.canBeHidden(type)) {
holder.checkboxEnabled.setEnabled(false); holder.checkboxEnabled.setEnabled(false);
holder.checkboxVisible.setEnabled(false); holder.checkboxVisible.setEnabled(false);
} }
@ -491,7 +493,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
// Hide disabled profiles by default // Hide disabled profiles by default
if (type == PluginBase.PROFILE) { if (type == PluginBase.PROFILE) {
if (!plugin.isEnabled()) { if (!plugin.isEnabled(type)) {
holder.checkboxVisible.setEnabled(false); holder.checkboxVisible.setEnabled(false);
holder.checkboxVisible.setChecked(false); holder.checkboxVisible.setChecked(false);
} else { } else {
@ -530,9 +532,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
return activeLoop; return activeLoop;
} }
void onEnabledCategoryChanged(PluginBase changedPlugin) { void onEnabledCategoryChanged(PluginBase changedPlugin, int type) {
int category = changedPlugin.getType(); int category = changedPlugin.getType();
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category); ArrayList<PluginBase> pluginsInCategory = null;
switch (category) { switch (category) {
// Multiple selection allowed // Multiple selection allowed
case PluginBase.APS: case PluginBase.APS:
@ -541,116 +543,115 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
break; break;
// Single selection allowed // Single selection allowed
case PluginBase.PROFILE: case PluginBase.PROFILE:
case PluginBase.PUMP: pluginsInCategory = MainActivity.getSpecificPluginsListByInterface(ProfileInterface.class);
break;
case PluginBase.BGSOURCE: case PluginBase.BGSOURCE:
case PluginBase.LOOP: case PluginBase.LOOP:
case PluginBase.TEMPBASAL: case PluginBase.TEMPBASAL:
case PluginBase.TREATMENT: case PluginBase.TREATMENT:
boolean newSelection = changedPlugin.isEnabled(); case PluginBase.PUMP:
if (newSelection) { // new plugin selected -> disable others pluginsInCategory = MainActivity.getSpecificPluginsList(category);
for (PluginBase p : pluginsInCategory) {
if (p.getName().equals(changedPlugin.getName())) {
// this is new selected
} else {
p.setFragmentEnabled(false);
setViews();
}
}
} else { // enable first plugin in list
pluginsInCategory.get(0).setFragmentEnabled(true);
}
break; 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(type, false);
setViews();
}
}
} else { // enable first plugin in list
pluginsInCategory.get(0).setFragmentEnabled(type, true);
}
}
} }
private void verifySelectionInCategories() { 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;
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);
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);
}
}
break;
case PluginBase.PUMP:
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory);
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);
}
}
break;
case PluginBase.LOOP:
activeLoop = (LoopFragment) getTheOneEnabledInArray(pluginsInCategory);
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);
}
}
}
break;
case PluginBase.TEMPBASAL:
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory);
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);
}
}
break;
case PluginBase.TREATMENT:
activeTreatments = (TreatmentsInterface) getTheOneEnabledInArray(pluginsInCategory);
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);
}
}
break;
}
// 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(PluginBase.PROFILE, false);
}
}
// 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(PluginBase.PUMP, false);
}
}
// 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(PluginBase.LOOP, false);
}
}
}
// 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(PluginBase.TEMPBASAL, false);
}
}
// 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(PluginBase.TREATMENT, false);
}
} }
} }
@Nullable @Nullable
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory) { private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory, int type) {
PluginBase found = null; PluginBase found = null;
for (PluginBase p : pluginsInCategory) { for (PluginBase p : pluginsInCategory) {
if (p.isEnabled() && found == null) { if (p.isEnabled(type) && found == null) {
found = p; found = p;
continue; continue;
} else if (p.isEnabled()) { } else if (p.isEnabled(type)) {
// set others disabled // set others disabled
p.setFragmentEnabled(false); p.setFragmentEnabled(type, false);
} }
} }
// If none enabled, enable first one // 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 settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
for (PluginBase p : pluginList) { for (int type = 1; type < PluginBase.LAST; type++) {
editor.putBoolean("ConfigBuilder" + p.getName() + "Enabled", p.isEnabled()); for (PluginBase p : pluginList) {
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(); editor.commit();
verifySelectionInCategories(); verifySelectionInCategories();
@ -678,12 +683,16 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
private void loadSettings() { private void loadSettings() {
if (Config.logPrefsChange) if (Config.logPrefsChange)
log.debug("Loading stored settings"); log.debug("Loading stored settings");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
for (PluginBase p : pluginList) { for (int type = 1; type < PluginBase.LAST; type++) {
if (settings.contains("ConfigBuilder" + p.getName() + "Enabled")) for (PluginBase p : pluginList) {
p.setFragmentEnabled(settings.getBoolean("ConfigBuilder" + p.getName() + "Enabled", true)); String settingEnabled = "ConfigBuilder_" + type + "_" + p.getName() + "_Enabled";
if (settings.contains("ConfigBuilder" + p.getName() + "Visible")) String settingVisible = "ConfigBuilder_" + p.getName() + "_Visible";
p.setFragmentVisible(settings.getBoolean("ConfigBuilder" + p.getName() + "Visible", true)); 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(); verifySelectionInCategories();
} }
@ -724,7 +733,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
result = result && constrain.isLoopEnabled(); result = result && constrain.isLoopEnabled();
} }
return result; return result;
@ -737,7 +746,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
result = result && constrain.isClosedModeEnabled(); result = result && constrain.isClosedModeEnabled();
} }
return result; return result;
@ -750,7 +759,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
result = result && constrain.isAutosensModeEnabled(); result = result && constrain.isAutosensModeEnabled();
} }
return result; return result;
@ -763,7 +772,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
result = result && constrain.isAMAModeEnabled(); result = result && constrain.isAMAModeEnabled();
} }
return result; return result;
@ -775,7 +784,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
rateAfterConstrain = Math.min(constrain.applyBasalConstraints(absoluteRate), rateAfterConstrain); rateAfterConstrain = Math.min(constrain.applyBasalConstraints(absoluteRate), rateAfterConstrain);
} }
return rateAfterConstrain; return rateAfterConstrain;
@ -787,7 +796,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
rateAfterConstrain = Math.min(constrain.applyBasalConstraints(percentRate), rateAfterConstrain); rateAfterConstrain = Math.min(constrain.applyBasalConstraints(percentRate), rateAfterConstrain);
} }
return rateAfterConstrain; return rateAfterConstrain;
@ -799,7 +808,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
insulinAfterConstrain = Math.min(constrain.applyBolusConstraints(insulin), insulinAfterConstrain); insulinAfterConstrain = Math.min(constrain.applyBolusConstraints(insulin), insulinAfterConstrain);
} }
return insulinAfterConstrain; return insulinAfterConstrain;
@ -811,7 +820,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
carbsAfterConstrain = Math.min(constrain.applyCarbsConstraints(carbs), carbsAfterConstrain); carbsAfterConstrain = Math.min(constrain.applyCarbsConstraints(carbs), carbsAfterConstrain);
} }
return carbsAfterConstrain; return carbsAfterConstrain;
@ -823,7 +832,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class); ArrayList<PluginBase> constraintsPlugins = MainActivity.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) { for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constrain = (ConstraintsInterface) p; ConstraintsInterface constrain = (ConstraintsInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
maxIobAfterConstrain = Math.min(constrain.applyMaxIOBConstraints(maxIob), maxIobAfterConstrain); maxIobAfterConstrain = Math.min(constrain.applyMaxIOBConstraints(maxIob), maxIobAfterConstrain);
} }
return maxIobAfterConstrain; return maxIobAfterConstrain;

View file

@ -333,6 +333,7 @@ public class DanaConnection {
mSerialEngine.sendMessage(new MsgSettingPumpTime()); mSerialEngine.sendMessage(new MsgSettingPumpTime());
mSerialEngine.sendMessage(new MsgSettingActiveProfile()); mSerialEngine.sendMessage(new MsgSettingActiveProfile());
mSerialEngine.sendMessage(new MsgSettingProfileRatios()); mSerialEngine.sendMessage(new MsgSettingProfileRatios());
mSerialEngine.sendMessage(new MsgSettingProfileRatiosAll());
danaRPump.lastSettingsRead = now; danaRPump.lastSettingsRead = now;
} }

View file

@ -7,10 +7,13 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.otto.Subscribe; 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.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; 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.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
import info.nightscout.utils.SetWarnColor; 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); private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
Handler mHandler; Handler mHandler;
@ -56,13 +59,16 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
private static DanaRPump sDanaRPump = new DanaRPump(); private static DanaRPump sDanaRPump = new DanaRPump();
private static boolean useExtendedBoluses = false; private static boolean useExtendedBoluses = false;
boolean fragmentEnabled = true; boolean fragmentPumpEnabled = true;
boolean fragmentVisible = true; boolean fragmentProfileEnabled = true;
boolean fragmentPumpVisible = true;
boolean visibleNow = false; boolean visibleNow = false;
Handler loopHandler = new Handler(); Handler loopHandler = new Handler();
Runnable refreshLoop = null; Runnable refreshLoop = null;
NSProfile convertedProfile = null;
TextView lastConnectionView; TextView lastConnectionView;
TextView btConnectionView; TextView btConnectionView;
TextView lastBolusView; TextView lastBolusView;
@ -73,6 +79,7 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
TextView batteryView; TextView batteryView;
TextView reservoirView; TextView reservoirView;
TextView iobView; TextView iobView;
Button viewProfileButton;
public static DanaConnection getDanaConnection() { public static DanaConnection getDanaConnection() {
return sDanaConnection; return sDanaConnection;
@ -148,6 +155,16 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
batteryView = (TextView) view.findViewById(R.id.danar_battery); batteryView = (TextView) view.findViewById(R.id.danar_battery);
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir); reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
iobView = (TextView) view.findViewById(R.id.danar_iob); 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() { btConnectionView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -225,28 +242,35 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; if (type == PluginBase.PROFILE) return fragmentProfileEnabled;
else if (type == PluginBase.PUMP) return fragmentPumpEnabled;
else if (type == PluginBase.CONSTRAINTS) return fragmentPumpEnabled;
return false;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; if (type == PluginBase.PROFILE || type == PluginBase.CONSTRAINTS) return false;
else if (type == PluginBase.PUMP) return fragmentPumpVisible;
return false;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; if (type == PluginBase.PROFILE) this.fragmentProfileEnabled = fragmentEnabled;
} else if (type == PluginBase.PUMP) this.fragmentPumpEnabled = fragmentEnabled;
}
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; if (type == PluginBase.PUMP)
this.fragmentPumpVisible = fragmentVisible;
} }
// Pump interface // Pump interface
@ -803,5 +827,14 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
return maxIob; 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 // TODO: daily total constraint
} }

View file

@ -1,7 +1,15 @@
package info.nightscout.androidaps.plugins.DanaR; 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 java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.client.data.NSProfile;
/** /**
* Created by mike on 04.07.2016. * Created by mike on 04.07.2016.
*/ */
@ -10,7 +18,7 @@ public class DanaRPump {
public static final int UNITS_MMOL = 1; public static final int UNITS_MMOL = 1;
Date lastConnection = new Date(0); Date lastConnection = new Date(0);
Date lastSettingsRead = new Date(0); public Date lastSettingsRead = new Date(0);
// Info // Info
public String serialNumber = ""; public String serialNumber = "";
@ -56,19 +64,19 @@ public class DanaRPump {
public int easyBasalMode; public int easyBasalMode;
public boolean basal48Enable = false; public boolean basal48Enable = false;
public int currentCIR; public int currentCIR;
public int currentCF; public double currentCF;
public int currentAI; public double currentAI;
public int currentTarget; public double currentTarget;
public int currentAIDR; public int currentAIDR;
public int morningCIR; public int morningCIR;
public int morningCF; public double morningCF;
public int afternoonCIR; public int afternoonCIR;
public int afternoonCF; public double afternoonCF;
public int eveningCIR; public int eveningCIR;
public int eveningCF; public double eveningCF;
public int nightCIR; public int nightCIR;
public int nightCF; public double nightCF;
public int activeProfile = 0; public int activeProfile = 0;
@ -77,4 +85,65 @@ public class DanaRPump {
//Limits //Limits
public double maxBolus; public double maxBolus;
public double maxBasal; public double maxBasal;
NSProfile convertedProfile = null;
public void createConvertedProfile() {
JSONObject json = new JSONObject();
JSONObject store = new JSONObject();
JSONObject profile = new JSONObject();
// Morning / 6:0010:59
// Afternoon / 11:0016:59
// Evening / 17:0021:59
// Night / 22:005: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));
}
} }

View file

@ -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());
}
}

View file

@ -21,15 +21,15 @@ public class MsgSettingProfileRatios extends DanaRMessage {
if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) { if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) {
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2); DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 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().currentTarget = intFromBuff(bytes, 6, 2);
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 6, 1); DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 8, 1);
} else { } else {
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2); DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100; DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100d;
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100; DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100; DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100d;
DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 6, 1); DanaRFragment.getDanaRPump().currentAIDR = intFromBuff(bytes, 8, 1);
} }
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {

View file

@ -29,13 +29,13 @@ public class MsgSettingProfileRatiosAll extends DanaRMessage {
DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2); DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2);
} else { } else {
DanaRFragment.getDanaRPump().morningCIR = intFromBuff(bytes, 0, 2); 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().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().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().nightCIR = intFromBuff(bytes, 12, 2);
DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2) / 100; DanaRFragment.getDanaRPump().nightCF = intFromBuff(bytes, 14, 2) / 100d;
} }
if (Config.logDanaMessageDetail) { 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 CIR: " + DanaRFragment.getDanaRPump().nightCIR);
log.debug("Current pump night CF: " + DanaRFragment.getDanaRPump().nightCF); log.debug("Current pump night CF: " + DanaRFragment.getDanaRPump().nightCF);
} }
}
DanaRFragment.getDanaRPump().createConvertedProfile();
}
} }

View file

@ -21,13 +21,13 @@ public class MsgStatusProfile extends DanaRMessage {
if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) { if (DanaRFragment.getDanaRPump().units == DanaRPump.UNITS_MGDL) {
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2); DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 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().currentTarget = intFromBuff(bytes, 6, 2);
} else { } else {
DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2); DanaRFragment.getDanaRPump().currentCIR = intFromBuff(bytes, 0, 2);
DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100; DanaRFragment.getDanaRPump().currentCF = intFromBuff(bytes, 2, 2) / 100d;
DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100; DanaRFragment.getDanaRPump().currentAI = intFromBuff(bytes, 4, 2) / 100d;
DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100; DanaRFragment.getDanaRPump().currentTarget = intFromBuff(bytes, 6, 2) / 100d;
} }
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {

View file

@ -116,27 +116,27 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }
@ -229,14 +229,14 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder(); ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder();
APSResult result = null; APSResult result = null;
if (constraintsInterface == null || configBuilder == null || !isEnabled()) if (constraintsInterface == null || configBuilder == null || !isEnabled(PluginBase.GENERAL))
return; return;
APSInterface usedAPS = null; APSInterface usedAPS = null;
ArrayList<PluginBase> apsPlugins = MainActivity.getSpecificPluginsList(PluginBase.APS); ArrayList<PluginBase> apsPlugins = MainActivity.getSpecificPluginsList(PluginBase.APS);
for (PluginBase p : apsPlugins) { for (PluginBase p : apsPlugins) {
APSInterface aps = (APSInterface) p; APSInterface aps = (APSInterface) p;
if (!p.isEnabled()) continue; if (!p.isEnabled(PluginBase.APS)) continue;
aps.invoke(); aps.invoke();
result = aps.getLastAPSResult(); result = aps.getLastAPSResult();
if (result == null) continue; if (result == null) continue;

View file

@ -118,27 +118,27 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }
@ -218,7 +218,7 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
if (!isEnabled()) { if (!isEnabled(PluginBase.APS)) {
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled)); updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); log.debug(MainApp.instance().getString(R.string.openapsma_disabled));

View file

@ -61,27 +61,27 @@ public class NSProfileViewerFragment extends Fragment implements PluginBase, Pro
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -54,26 +54,26 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return true; return true;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -278,7 +278,7 @@ public class DetermineBasalAdapterJS implements Parcelable {
mProfile.add("min_bg", minBg); mProfile.add("min_bg", minBg);
mProfile.add("max_bg", maxBg); mProfile.add("max_bg", maxBg);
mProfile.add("carbratio", profile.getIc(profile.secondsFromMidnight())); 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()); mProfile.add("current_basal", pump.getBaseBasalRate());
mCurrentTemp.add("duration", pump.getTempBasalRemainingMinutes()); mCurrentTemp.add("duration", pump.getTempBasalRemainingMinutes());

View file

@ -107,27 +107,27 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@ -214,7 +214,7 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
if (!isEnabled()) { if (!isEnabled(PluginBase.APS)) {
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled)); updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); log.debug(MainApp.instance().getString(R.string.openapsma_disabled));

View file

@ -102,27 +102,27 @@ public class OverviewFragment extends Fragment implements PluginBase {
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return true; return true;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return true; return true;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return false; return false;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
// Always enabled // Always enabled
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
// Always visible // Always visible
} }

View file

@ -34,27 +34,27 @@ public class SafetyFragment extends Fragment implements PluginBase, ConstraintsI
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return true; return true;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return false; return false;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int tyep, boolean fragmentEnabled) {
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
} }
public static SafetyFragment newInstance() { public static SafetyFragment newInstance() {

View file

@ -77,27 +77,27 @@ public class SimpleProfileFragment extends Fragment implements PluginBase, Profi
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -31,27 +31,27 @@ public class SourceNSClientFragment extends Fragment implements PluginBase, BgSo
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return false; return false;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
} }

View file

@ -32,27 +32,27 @@ public class SourceXdripFragment extends Fragment implements PluginBase, BgSourc
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return false; return false;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
} }
public static SourceXdripFragment newInstance() { public static SourceXdripFragment newInstance() {

View file

@ -72,27 +72,27 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -73,27 +73,27 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
@Override @Override
public void setFragmentEnabled(boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -58,26 +58,27 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
} }
@Override @Override
public boolean isEnabled() { public boolean isEnabled(int type) {
return fragmentEnabled; return fragmentEnabled;
} }
@Override @Override
public boolean isVisibleInTabs() { public boolean isVisibleInTabs(int type) {
return fragmentVisible; return fragmentVisible;
} }
@Override @Override
public boolean canBeHidden() { public boolean canBeHidden(int type) {
return true; return true;
} }
public void setFragmentEnabled(boolean fragmentEnabled) { @Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
} }
@Override @Override
public void setFragmentVisible(boolean fragmentVisible) { public void setFragmentVisible(int type, boolean fragmentVisible) {
this.fragmentVisible = fragmentVisible; this.fragmentVisible = fragmentVisible;
} }

View file

@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment; import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
import info.nightscout.androidaps.plugins.DanaR.Services.DanaRService; import info.nightscout.androidaps.plugins.DanaR.Services.DanaRService;
@ -31,7 +32,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
log.debug("KeepAlive received"); log.debug("KeepAlive received");
DanaRFragment danaRFragment = (DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class); 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); Intent intent = new Intent(context, DanaRService.class);
context.startService(intent); context.startService(intent);
} }

View file

@ -45,7 +45,7 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
public void registerNewFragment(Fragment fragment) { public void registerNewFragment(Fragment fragment) {
PluginBase plugin = (PluginBase) fragment; PluginBase plugin = (PluginBase) fragment;
fragmentList.add(plugin); fragmentList.add(plugin);
if (plugin.isVisibleInTabs()) { if (plugin.isVisibleInTabs(plugin.getType())) {
visibleFragmentList.add(plugin); visibleFragmentList.add(plugin);
notifyDataSetChanged(); notifyDataSetChanged();
} }

View file

@ -213,7 +213,7 @@ public class NSProfile {
JSONObject profile = getDefaultProfile(); JSONObject profile = getDefaultProfile();
if (profile != null) { if (profile != null) {
try { 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) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -250,6 +250,18 @@
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout> </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> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -113,6 +113,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" /> 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> </LinearLayout>
</ScrollView> </ScrollView>

View file

@ -234,5 +234,7 @@
<string name="hoursago">h ago</string> <string name="hoursago">h ago</string>
<string name="danar_invalidinput">Invalid input data</string> <string name="danar_invalidinput">Invalid input data</string>
<string name="danar_valuenotsetproperly">Value not set properly</string> <string name="danar_valuenotsetproperly">Value not set properly</string>
<string name="reloadprofile">Reload profile</string>
<string name="danar_viewprofile">View profile</string>
</resources> </resources>