allow to open G5 app from CGM button
This commit is contained in:
parent
e544d44799
commit
7b91f0d490
2 changed files with 18 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -945,7 +945,7 @@
|
|||
<string name="key_show_wizard_button">show_wizard_button</string>
|
||||
<string name="key_show_insulin_button">show_insulin_button</string>
|
||||
<string name="key_show_treatment_button">show_treatment_button</string>
|
||||
<string name="show_calibration_button_summary">Sends a calibration to xDrip+</string>
|
||||
<string name="show_calibration_button_summary">Sends a calibration to xDrip+ or open G5 calibration dialog</string>
|
||||
<string name="show_cgm_button_summary">Opens xDrip+, back buttons returns to AAPS</string>
|
||||
<string name="key_insulin_button_increment_1">insulin_button_increment_1</string>
|
||||
<string name="key_insulin_button_increment_2">insulin_button_increment_2</string>
|
||||
|
@ -955,7 +955,7 @@
|
|||
<string name="key_carbs_button_increment_3">carbs_button_increment_3</string>
|
||||
<string name="carb_increment_button_message">Number of carbs to add when button is pressed</string>
|
||||
<string name="insulin_increment_button_message">Amount of insulin to add when button is pressed</string>
|
||||
<string name="erro_starting_xdrip">Could not launch xDrip. Make sure only it is installed.</string>
|
||||
<string name="error_starting_cgm">Could not launch CGM application. Make sure it is installed.</string>
|
||||
<string name="overview_cgm">CGM</string>
|
||||
<string name="nav_historybrowser">History browser</string>
|
||||
<string name="wear_notifysmb_title">Notify on SMB</string>
|
||||
|
|
Loading…
Reference in a new issue