diff --git a/app/build.gradle b/app/build.gradle
index d558896ee6..d98f585fca 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -75,6 +75,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "true"
+ buildConfigField "boolean", "G5UPLOADER", "false"
}
openloop {
dimension "standard"
@@ -87,6 +88,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
+ buildConfigField "boolean", "G5UPLOADER", "false"
}
pumpcontrol {
dimension "standard"
@@ -99,6 +101,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
+ buildConfigField "boolean", "G5UPLOADER", "false"
}
nsclient {
dimension "standard"
@@ -111,6 +114,20 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "false"
buildConfigField "boolean", "NSCLIENTOLNY", "true"
buildConfigField "boolean", "CLOSEDLOOP", "false"
+ buildConfigField "boolean", "G5UPLOADER", "false"
+ }
+ g5uploader {
+ dimension "standard"
+ resValue "string", "app_name", "NSClient"
+ versionName version + "-nsclient"
+ manifestPlaceholders = [
+ appIcon: "@mipmap/yellowowl"
+ ]
+ buildConfigField "boolean", "APS", "false"
+ buildConfigField "boolean", "PUMPDRIVERS", "false"
+ buildConfigField "boolean", "NSCLIENTOLNY", "false"
+ buildConfigField "boolean", "CLOSEDLOOP", "false"
+ buildConfigField "boolean", "G5UPLOADER", "true"
}
}
}
@@ -161,7 +178,7 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
compile(name: 'android-edittext-validator-v1.3.4-mod', ext: 'aar')
- compile ('com.google.android:flexbox:0.3.0') {
+ compile('com.google.android:flexbox:0.3.0') {
exclude group: 'com.android.support'
}
compile('io.socket:socket.io-client:0.8.3') {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 13a6400b79..8290c46004 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -75,6 +75,8 @@
+
+
diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java
index d900da7d43..1bf72e6765 100644
--- a/app/src/main/java/info/nightscout/androidaps/Config.java
+++ b/app/src/main/java/info/nightscout/androidaps/Config.java
@@ -10,16 +10,17 @@ public class Config {
public static final boolean APS = BuildConfig.APS;
// PLUGINS
public static final boolean NSCLIENT = BuildConfig.NSCLIENTOLNY;
+ public static final boolean G5UPLOADER = BuildConfig.G5UPLOADER;
- public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS;
+ public static final boolean DANAR = BuildConfig.PUMPDRIVERS;
- public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY;
- public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY;
- public static final boolean MDI = !BuildConfig.NSCLIENTOLNY;
- public static final boolean OTHERPROFILES = !BuildConfig.NSCLIENTOLNY;
- public static final boolean SAFETY = !BuildConfig.NSCLIENTOLNY;
+ public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
+ public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
+ public static final boolean MDI = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
+ public static final boolean OTHERPROFILES = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
+ public static final boolean SAFETY = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
- public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY;
+ public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean detailedLog = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index 8f08d284dc..f0f5136937 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -369,7 +369,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
case R.id.nav_about:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION);
- if (Config.NSCLIENT)
+ if (Config.NSCLIENT|| Config.G5UPLOADER)
builder.setIcon(R.mipmap.yellowowl);
else
builder.setIcon(R.mipmap.blueowl);
diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index f8b4bcf0f7..a0ba2a6843 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -64,6 +64,7 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
+import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
@@ -144,13 +145,16 @@ public class MainApp extends Application {
pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
- if (!Config.NSCLIENT)
+ if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceXdripPlugin.getPlugin());
- pluginsList.add(SourceNSClientPlugin.getPlugin());
- if (!Config.NSCLIENT)
+ if (!Config.G5UPLOADER)
+ pluginsList.add(SourceNSClientPlugin.getPlugin());
+ if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceMM640gPlugin.getPlugin());
- if (!Config.NSCLIENT)
+ if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceGlimpPlugin.getPlugin());
+ if (!Config.NSCLIENT)
+ pluginsList.add(SourceDexcomG5Plugin.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
pluginsList.add(FoodPlugin.getPlugin());
diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
index ad795f6421..6706e88fd9 100644
--- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java
@@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
+import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
import info.nightscout.utils.LocaleHelper;
@@ -126,15 +127,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(id);
addPreferencesFromResource(R.xml.pref_advanced);
} else {
- if (!Config.NSCLIENT) {
+ if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_password);
}
addPreferencesFromResource(R.xml.pref_age);
addPreferencesFromResource(R.xml.pref_language);
- if (!Config.NSCLIENT) {
+ if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_quickwizard);
}
+ addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginBase.BGSOURCE);
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginBase.GENERAL);
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginBase.CONSTRAINTS);
if (Config.APS) {
@@ -147,7 +149,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY);
- if (!Config.NSCLIENT) {
+ if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_profile);
}
@@ -165,14 +167,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
}
- addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP);
+ if (!Config.NSCLIENT && !Config.G5UPLOADER) {
+ addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP);
+ }
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN);
addPreferencesFromResourceIfEnabled(NSClientInternalPlugin.getPlugin(), PluginBase.GENERAL);
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginBase.GENERAL);
- if (!Config.NSCLIENT) {
+ if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_others);
}
addPreferencesFromResource(R.xml.pref_advanced);
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 0b475ddf4f..540df96fe8 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
@@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
+import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
@@ -38,6 +39,7 @@ import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.utils.BundleLogger;
+import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
@@ -48,6 +50,7 @@ public class DataService extends IntentService {
boolean nsClientEnabled = true;
boolean mm640gEnabled = false;
boolean glimpEnabled = false;
+ boolean dexcomG5Enabled = false;
public DataService() {
super("DataService");
@@ -64,21 +67,31 @@ public class DataService extends IntentService {
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = false;
+ dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = true;
mm640gEnabled = false;
glimpEnabled = false;
+ dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = true;
glimpEnabled = false;
+ dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = true;
+ dexcomG5Enabled = false;
+ } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) {
+ xDripEnabled = false;
+ nsClientEnabled = false;
+ mm640gEnabled = false;
+ glimpEnabled = false;
+ dexcomG5Enabled = true;
}
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
@@ -99,6 +112,10 @@ public class DataService extends IntentService {
if (glimpEnabled) {
handleNewDataFromGlimp(intent);
}
+ } else if (Intents.DEXCOMG5_BG.equals(action)) {
+ if (dexcomG5Enabled) {
+ handleNewDataFromDexcomG5(intent);
+ }
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
// always handle SGV if NS-Client is the source
if (nsClientEnabled) {
@@ -187,6 +204,37 @@ public class DataService extends IntentService {
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP");
}
+ private void handleNewDataFromDexcomG5(Intent intent) {
+ // onHandleIntent Bundle{ data => [{"m_time":1511939180,"m_trend":"NotComputable","m_value":335}]; android.support.content.wakelockid => 95; }Bundle
+
+ Bundle bundle = intent.getExtras();
+ if (bundle == null) return;
+
+ BgReading bgReading = new BgReading();
+
+ String data = bundle.getString("data");
+ log.debug("Received Dexcom Data", data);
+
+ try {
+ JSONArray jsonArray = new JSONArray(data);
+ log.debug("Received Dexcom Data size:" + jsonArray.length());
+ for(int i = 0; i < jsonArray.length(); i++) {
+ JSONObject json = jsonArray.getJSONObject(i);
+ bgReading.value = json.getInt("m_value");
+ bgReading.direction = json.getString("m_trend");
+ bgReading.date = json.getLong("m_time") * 1000L;
+ bgReading.raw = 0;
+ boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
+ if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
+ NSUpload.uploadBg(bgReading);
+ }
+ }
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
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 5e2335862b..b9c90e905c 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/Intents.java
@@ -45,4 +45,6 @@ public interface Intents {
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
+
+ String DEXCOMG5_BG = "com.dexcom.cgm.DATA";
}
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 cbe1850958..4d43f942e3 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/BgReading.java
@@ -96,7 +96,9 @@ public class BgReading implements DataPointWithLabelInterface {
direction.compareTo("NOT COMPUTABLE") == 0 ||
direction.compareTo("OUT_OF_RANGE") == 0 ||
direction.compareTo("OUT OF RANGE") == 0 ||
- direction.compareTo("NONE") == 0) {
+ direction.compareTo("NONE") == 0 ||
+ direction.compareTo("NotComputable") == 0
+ ) {
return true;
} else {
return false;
diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
index 2767f7611a..7e8085a0ce 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java
@@ -343,7 +343,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
// ------------------- BgReading handling -----------------------
- public void createIfNotExists(BgReading bgReading, String from) {
+ public boolean createIfNotExists(BgReading bgReading, String from) {
try {
bgReading.date = roundDateToSec(bgReading.date);
BgReading old = getDaoBgReadings().queryForId(bgReading.date);
@@ -351,18 +351,20 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoBgReadings().create(bgReading);
log.debug("BG: New record from: " + from + " " + bgReading.toString());
scheduleBgChange();
- return;
+ return true;
}
if (!old.isEqual(bgReading)) {
+ log.debug("BG: Similiar found: " + old.toString());
old.copyFrom(bgReading);
getDaoBgReadings().update(old);
- log.debug("BG: Updating record from: " + from + " " + old.toString());
+ log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
scheduleBgChange();
- return;
+ return false;
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
+ return false;
}
private static void scheduleBgChange() {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
index bee1c3b923..4070bc880f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
@@ -14,6 +14,7 @@ import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.BuildConfig;
+import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore;
@@ -104,7 +105,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
butonsLayout.setVisibility(View.VISIBLE);
}
- if (BuildConfig.NSCLIENTOLNY)
+ if (Config.NSCLIENT || Config.G5UPLOADER)
statsLayout.setVisibility(View.GONE); // visible on overview
updateGUI();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java
index fc6dd7fd05..a72fc200ea 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalPlugin.java
@@ -67,7 +67,7 @@ public class CareportalPlugin implements PluginBase {
@Override
public boolean showInList(int type) {
- return !Config.NSCLIENT;
+ return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java
index 9f91080710..d898d48388 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java
@@ -77,7 +77,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
@Override
public boolean isVisibleInTabs(int type) {
- return type == CONSTRAINTS && fragmentVisible && !BuildConfig.NSCLIENTOLNY;
+ return type == CONSTRAINTS && fragmentVisible && !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
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 d5ca87a479..cdca4e5b41 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
@@ -122,7 +122,7 @@ public class NSClientInternalPlugin implements PluginBase {
@Override
public boolean showInList(int type) {
- return !Config.NSCLIENT;
+ return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
index e3cab1a62c..f06baaaed6 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
@@ -198,9 +198,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
View view;
- if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
+ if (MainApp.sResources.getBoolean(R.bool.isTablet) && (Config.NSCLIENT || Config.G5UPLOADER)) {
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
- } else if (BuildConfig.NSCLIENTOLNY) {
+ } else if (Config.NSCLIENT || Config.G5UPLOADER) {
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
shorttextmode = true;
} else if (smallHeight || landscape) {
@@ -975,7 +975,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
tempTargetView.setVisibility(View.VISIBLE);
}
- if (Config.NSCLIENT && tempTarget == null) {
+ if ((Config.NSCLIENT || Config.G5UPLOADER) && tempTarget == null) {
tempTargetView.setVisibility(View.GONE);
}
@@ -1026,7 +1026,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (activeTemp != null) {
basalText = activeTemp.toStringFull() + " ";
}
- if (Config.NSCLIENT)
+ if (Config.NSCLIENT || Config.G5UPLOADER)
basalText += "(" + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + " U/h)";
else if (pump.getPumpDescription().isTempBasalCapable) {
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
index 9efa4250bc..f4b4aaabcc 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java
@@ -72,12 +72,12 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
@Override
public boolean isEnabled(int type) {
- return type == PROFILE && (Config.NSCLIENT || fragmentEnabled);
+ return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentEnabled);
}
@Override
public boolean isVisibleInTabs(int type) {
- return type == PROFILE && (Config.NSCLIENT || fragmentVisible);
+ return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentVisible);
}
@Override
@@ -92,7 +92,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
@Override
public boolean showInList(int type) {
- return !Config.NSCLIENT;
+ return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
index 4853847e5b..c278f7fb16 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
@@ -166,7 +166,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public boolean isFakingTempsByExtendedBoluses() {
- return Config.NSCLIENT && fromNSAreCommingFakedExtendedBoluses;
+ return (Config.NSCLIENT || Config.G5UPLOADER) && fromNSAreCommingFakedExtendedBoluses;
}
@Override
@@ -196,7 +196,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public void connect(String reason) {
- if (!BuildConfig.NSCLIENTOLNY)
+ if (!Config.NSCLIENT && !Config.G5UPLOADER)
NSUpload.uploadDeviceStatus();
lastDataTime = new Date();
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/SourceDexcomG5Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/SourceDexcomG5Plugin.java
new file mode 100644
index 0000000000..56934d0081
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/SourceDexcomG5Plugin.java
@@ -0,0 +1,84 @@
+package info.nightscout.androidaps.plugins.SourceDexcomG5;
+
+import info.nightscout.androidaps.Config;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.BgSourceInterface;
+import info.nightscout.androidaps.interfaces.PluginBase;
+
+/**
+ * Created by mike on 28.11.2017.
+ */
+
+public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
+ private boolean fragmentEnabled = false;
+
+ private static SourceDexcomG5Plugin plugin = null;
+
+ public static SourceDexcomG5Plugin getPlugin() {
+ if (plugin == null)
+ plugin = new SourceDexcomG5Plugin();
+ return plugin;
+ }
+
+ @Override
+ public String getFragmentClass() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return PluginBase.BGSOURCE;
+ }
+
+ @Override
+ public String getName() {
+ return MainApp.instance().getString(R.string.DexcomG5);
+ }
+
+ @Override
+ public String getNameShort() {
+ // use long name as fallback (no tabs)
+ return getName();
+ }
+
+ @Override
+ public boolean isEnabled(int type) {
+ return Config.G5UPLOADER || type == BGSOURCE && fragmentEnabled;
+ }
+
+ @Override
+ public boolean isVisibleInTabs(int type) {
+ return false;
+ }
+
+ @Override
+ public boolean canBeHidden(int type) {
+ return true;
+ }
+
+ @Override
+ public boolean hasFragment() {
+ return false;
+ }
+
+ @Override
+ public boolean showInList(int type) {
+ return !Config.G5UPLOADER;
+ }
+
+ @Override
+ public void setFragmentEnabled(int type, boolean fragmentEnabled) {
+ if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
+ }
+
+ @Override
+ public void setFragmentVisible(int type, boolean fragmentVisible) {
+
+ }
+
+ @Override
+ public int getPreferencesId() {
+ return R.xml.pref_dexcomg5;
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
index 6466591a87..8f0dca4996 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
@@ -108,7 +108,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public boolean showInList(int type) {
- return !Config.NSCLIENT;
+ return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
index 300a2827c1..60d784d377 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java
@@ -113,7 +113,7 @@ public class StatuslinePlugin implements PluginBase {
@Override
public boolean showInList(int type) {
- return !Config.NSCLIENT;
+ return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override
diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java
index 215bd732e7..d6e8254cd6 100644
--- a/app/src/main/java/info/nightscout/utils/NSUpload.java
+++ b/app/src/main/java/info/nightscout/utils/NSUpload.java
@@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo;
+import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch;
@@ -383,6 +384,30 @@ public class NSUpload {
DbLogger.dbAdd(intent, data.toString());
}
+ public static void uploadBg(BgReading reading) {
+ Context context = MainApp.instance().getApplicationContext();
+ Bundle bundle = new Bundle();
+ bundle.putString("action", "dbAdd");
+ bundle.putString("collection", "entries");
+ JSONObject data = new JSONObject();
+ try {
+ data.put("device", "AndroidAPS-DexcomG5");
+ data.put("date", reading.date);
+ data.put("dateString", DateUtil.toISOString(reading.date));
+ data.put("sgv", reading.value);
+ data.put("direction", reading.direction);
+ data.put("type", "sgv");
+ } catch (JSONException e) {
+ log.error("Unhandled exception", e);
+ }
+ bundle.putString("data", data.toString());
+ Intent intent = new Intent(Intents.ACTION_DATABASE);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ DbLogger.dbAdd(intent, data.toString());
+ }
+
public static void uploadAppStart() {
if (SP.getBoolean(R.string.key_ns_logappstartedevent, true)) {
Context context = MainApp.instance().getApplicationContext();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0e2833c970..1c423b4918 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -772,5 +772,10 @@
missed_bg_readings_threshold
Urgent Alarm
INFO
+ DexcomG5 App (patched)
+ Upload BG data to NS
+ dexcomg5_nsupload
+ G5 upload settings
+ Customized APK for download
diff --git a/app/src/main/res/xml/pref_dexcomg5.xml b/app/src/main/res/xml/pref_dexcomg5.xml
new file mode 100644
index 0000000000..75631b3b85
--- /dev/null
+++ b/app/src/main/res/xml/pref_dexcomg5.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file