From a063fb05b4d087fda8b33180050b3574be3c15a8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 19 Feb 2018 00:22:27 +0100 Subject: [PATCH 1/2] G5 calibration button --- .../plugins/Overview/OverviewFragment.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 fef0a5d4bd..63166717d4 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 @@ -103,6 +103,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock; import info.nightscout.androidaps.plugins.Overview.graphData.GraphData; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore; +import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin; import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog; import info.nightscout.androidaps.queue.Callback; @@ -625,8 +626,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, wizardDialog.show(manager, "WizardDialog"); break; case R.id.overview_calibrationbutton: - CalibrationDialog calibrationDialog = new CalibrationDialog(); - calibrationDialog.show(manager, "CalibrationDialog"); + boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE); + boolean g5 = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginBase.BGSOURCE); + if (xdrip) { + CalibrationDialog calibrationDialog = new CalibrationDialog(); + calibrationDialog.show(manager, "CalibrationDialog"); + } else if (g5) { + Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity"); + startActivity(i); + } break; case R.id.overview_treatmentbutton: NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog(); @@ -1116,7 +1124,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // **** Calibration button **** if (calibrationButton != null) { - if (MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE) && profile != null && DatabaseHelper.actualBg() != null) { + boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE); + boolean g5 = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginBase.BGSOURCE); + if ((xdrip || g5) && profile != null && DatabaseHelper.actualBg() != null) { calibrationButton.setVisibility(View.VISIBLE); } else { calibrationButton.setVisibility(View.GONE); From cb8fc905bb069753f7e774ff1d8a5bf716568ead Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 25 Feb 2018 15:23:25 +0100 Subject: [PATCH 2/2] catch if G5 app is missing --- .../androidaps/plugins/Overview/OverviewFragment.java | 9 +++++++-- app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) 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 63166717d4..e4b2c344d8 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 @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview; import android.annotation.SuppressLint; import android.app.Activity; import android.app.NotificationManager; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -632,8 +633,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, CalibrationDialog calibrationDialog = new CalibrationDialog(); calibrationDialog.show(manager, "CalibrationDialog"); } else if (g5) { - Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity"); - startActivity(i); + try { + Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity"); + startActivity(i); + } catch (ActivityNotFoundException e) { + ToastUtils.showToastInUiThread(getActivity(), MainApp.gs(R.string.g5appnotdetected)); + } } break; case R.id.overview_treatmentbutton: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 319ebc2413..4a802632d6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -935,5 +935,6 @@ Create announcements from errors Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments) G5 + Please update your G5 app to supported version