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 066b6ebacf..35ee0cce39 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
@@ -629,6 +629,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
@Override
public void onClick(View v) {
+ 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);
+ String units = MainApp.getConfigBuilder().getProfileUnits();
+
FragmentManager manager = getFragmentManager();
switch (v.getId()) {
case R.id.overview_accepttempbutton:
@@ -642,8 +646,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
wizardDialog.show(manager, "WizardDialog");
break;
case R.id.overview_calibrationbutton:
- 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");
@@ -657,7 +659,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
break;
case R.id.overview_cgmbutton:
- openXdrip();
+ if (xdrip)
+ openCgmApp("com.eveningoutpost.dexdrip");
+ else if (g5 && units.equals(Constants.MGDL))
+ openCgmApp("com.dexcom.cgm.region5.mgdl");
+ else if (g5 && units.equals(Constants.MMOL))
+ openCgmApp("com.dexcom.cgm.region5.mmol");
break;
case R.id.overview_treatmentbutton:
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
@@ -695,10 +702,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
- public boolean openXdrip() {
+ public boolean openCgmApp(String packageName) {
PackageManager packageManager = getContext().getPackageManager();
try {
- Intent intent = packageManager.getLaunchIntentForPackage("com.eveningoutpost.dexdrip");
+ Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if (intent == null) {
throw new ActivityNotFoundException();
}
@@ -707,7 +714,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
return true;
} catch (ActivityNotFoundException e) {
new AlertDialog.Builder(getContext())
- .setMessage(R.string.erro_starting_xdrip)
+ .setMessage(R.string.error_starting_cgm)
.setPositiveButton("OK", null)
.show();
return false;
@@ -1174,7 +1181,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
}
if (cgmButton != null) {
- if (xDripIsBgSource && bgAvailable && SP.getBoolean(R.string.key_show_cgm_button, false)) {
+ if (xDripIsBgSource && SP.getBoolean(R.string.key_show_cgm_button, false)) {
+ cgmButton.setVisibility(View.VISIBLE);
+ } else if (g5IsBgSource && SP.getBoolean(R.string.key_show_cgm_button, false)) {
cgmButton.setVisibility(View.VISIBLE);
} else {
cgmButton.setVisibility(View.GONE);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 76abd47262..40479017ff 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -945,7 +945,7 @@
show_wizard_button
show_insulin_button
show_treatment_button
- Sends a calibration to xDrip+
+ Sends a calibration to xDrip+ or open G5 calibration dialog
Opens xDrip+, back buttons returns to AAPS
insulin_button_increment_1
insulin_button_increment_2
@@ -955,7 +955,7 @@
carbs_button_increment_3
Number of carbs to add when button is pressed
Amount of insulin to add when button is pressed
- Could not launch xDrip. Make sure only it is installed.
+ Could not launch CGM application. Make sure it is installed.
CGM
History browser
Notify on SMB