diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index ec478584a2..67057f1e9d 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment;
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
+import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
@@ -104,6 +105,7 @@ public class MainApp extends Application {
pluginsList.add(SourceXdripFragment.getPlugin());
pluginsList.add(SourceNSClientFragment.getPlugin());
pluginsList.add(SourceMM640gFragment.getPlugin());
+ pluginsList.add(SourceGlimpFragment.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
index b27a1a85b4..f45e59f4c1 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
@@ -44,6 +44,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
+import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
@@ -59,6 +60,7 @@ public class DataService extends IntentService {
boolean xDripEnabled = false;
boolean nsClientEnabled = true;
boolean mm640gEnabled = false;
+ boolean glimpEnabled = false;
public DataService() {
super("DataService");
@@ -74,14 +76,22 @@ public class DataService extends IntentService {
xDripEnabled = true;
nsClientEnabled = false;
mm640gEnabled = false;
+ glimpEnabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = true;
mm640gEnabled = false;
+ glimpEnabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = true;
+ glimpEnabled = false;
+ } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
+ xDripEnabled = false;
+ nsClientEnabled = false;
+ mm640gEnabled = false;
+ glimpEnabled = true;
}
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfile().getClass().equals(NSProfilePlugin.class);
@@ -99,6 +109,10 @@ public class DataService extends IntentService {
if (mm640gEnabled) {
handleNewDataFromMM640g(intent);
}
+ } else if (Intents.GLIMP_BG.equals(action)) {
+ if (glimpEnabled) {
+ handleNewDataFromGlimp(intent);
+ }
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
// always handle SGV if NS-Client is the source
if (nsClientEnabled) {
@@ -185,6 +199,30 @@ public class DataService extends IntentService {
MainApp.bus().post(new EventNewBG());
}
+ private void handleNewDataFromGlimp(Intent intent) {
+ Bundle bundle = intent.getExtras();
+ if (bundle == null) return;
+
+ BgReading bgReading = new BgReading();
+
+ bgReading.value = bundle.getDouble("mySGV");
+ bgReading.direction = bundle.getString("myTrend");
+ bgReading.battery_level = bundle.getInt("myBatLvl");
+ bgReading.timeIndex = bundle.getLong("myTimestamp");
+ bgReading.raw = 0;
+
+ if (Config.logIncommingBG)
+ log.debug(bundle.toString());
+ log.debug("GLIMP BG " + bgReading.toString());
+
+ try {
+ MainApp.getDbHelper().getDaoBgReadings().createIfNotExists(bgReading);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ MainApp.bus().post(new EventNewBG());
+ }
+
private void handleNewDataFromMM640g(Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle == null) return;
diff --git a/app/src/main/java/info/nightscout/androidaps/Services/Intents.java b/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
index 4787838d4f..1b7b0875e5 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
@@ -35,4 +35,6 @@ public interface Intents {
String NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR";
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
+
+ String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
}
diff --git a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java b/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
index 951d370bf3..8a0aaf96e1 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
@@ -47,7 +47,7 @@ public class BgReading implements DataPointInterface {
public BgReading(NSSgv sgv) {
timeIndex = sgv.getMills();
value = sgv.getMgdl();
- raw = sgv.getFiltered();
+ raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
direction = sgv.getDirection();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
index ba36501a9e..46c19b2eaa 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
@@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientS
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP;
+import info.nightscout.utils.ToastUtils;
public class NSClientInternalPlugin implements PluginBase {
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
@@ -189,12 +190,16 @@ public class NSClientInternalPlugin implements PluginBase {
}
private void updateLog() {
- Spanned newTextLog = Html.fromHtml("");
- for (EventNSClientNewLog log : listLog) {
- newTextLog = (Spanned) TextUtils.concat(newTextLog, log.toHtml());
+ try {
+ Spanned newTextLog = Html.fromHtml("");
+ for (EventNSClientNewLog log : listLog) {
+ newTextLog = (Spanned) TextUtils.concat(newTextLog, log.toHtml());
+ }
+ textLog = newTextLog;
+ MainApp.bus().post(new EventNSClientUpdateGUI());
+ } catch (OutOfMemoryError e) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "Out of memory!\nStop using this phone !!!", R.raw.error);
}
- textLog = newTextLog;
- MainApp.bus().post(new EventNSClientUpdateGUI());
}
public void resend(String reason) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpFragment.java
new file mode 100644
index 0000000000..85a4ee9646
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpFragment.java
@@ -0,0 +1,16 @@
+package info.nightscout.androidaps.plugins.SourceGlimp;
+
+
+import android.support.v4.app.Fragment;
+
+import info.nightscout.androidaps.interfaces.FragmentBase;
+
+public class SourceGlimpFragment extends Fragment implements FragmentBase {
+
+ private static SourceGlimpPlugin sourceGlimpPlugin = new SourceGlimpPlugin();
+
+ public static SourceGlimpPlugin getPlugin() {
+ return sourceGlimpPlugin;
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java
new file mode 100644
index 0000000000..7a5965e3df
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceGlimp/SourceGlimpPlugin.java
@@ -0,0 +1,62 @@
+package info.nightscout.androidaps.plugins.SourceGlimp;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.BgSourceInterface;
+import info.nightscout.androidaps.interfaces.PluginBase;
+import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
+
+/**
+ * Created by mike on 05.08.2016.
+ */
+public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
+ boolean fragmentEnabled = false;
+
+ @Override
+ public String getFragmentClass() {
+ return SourceGlimpFragment.class.getName();
+ }
+
+ @Override
+ public int getType() {
+ return PluginBase.BGSOURCE;
+ }
+
+ @Override
+ public String getName() {
+ return MainApp.instance().getString(R.string.Glimp);
+ }
+
+ @Override
+ public String getNameShort() {
+ // use long name as fallback (no tabs)
+ return getName();
+ }
+
+ @Override
+ public boolean isEnabled(int type) {
+ return type == BGSOURCE && fragmentEnabled;
+ }
+
+ @Override
+ public boolean isVisibleInTabs(int type) {
+ return false;
+ }
+
+ @Override
+ public boolean canBeHidden(int type) {
+ return true;
+ }
+
+ @Override
+ public void setFragmentEnabled(int type, boolean fragmentEnabled) {
+ if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
+ }
+
+ @Override
+ public void setFragmentVisible(int type, boolean fragmentVisible) {
+
+ }
+
+
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 45688577f3..5c28094f14 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -553,4 +553,5 @@
adult
Please select patient age to setup safety limits
I_understand
+ Glimp