Merge branch 'g5cal' into buttons

This commit is contained in:
Milos Kozak 2018-02-25 15:31:43 +01:00
commit 32f2f4d6fa
2 changed files with 21 additions and 10 deletions

View file

@ -34,7 +34,6 @@ import android.widget.CompoundButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.crashlytics.android.answers.CustomEvent; import com.crashlytics.android.answers.CustomEvent;
import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.GraphView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
@ -106,13 +105,14 @@ import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData; import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore; 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.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog; import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.BolusWizard; import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.utils.OKDialog; import info.nightscout.utils.OKDialog;
import info.nightscout.utils.Profiler; import info.nightscout.utils.Profiler;
@ -120,8 +120,6 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.SingleClickButton; import info.nightscout.utils.SingleClickButton;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
import static java.util.Objects.requireNonNull;
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, View.OnLongClickListener { public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, View.OnLongClickListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class); private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
@ -263,9 +261,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
treatmentButton = requireNonNull(view.findViewById(R.id.overview_treatmentbutton)); treatmentButton = (SingleClickButton) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton.setOnClickListener(this); treatmentButton.setOnClickListener(this);
wizardButton = requireNonNull(view.findViewById(R.id.overview_wizardbutton)); wizardButton = (SingleClickButton) view.findViewById(R.id.overview_wizardbutton);
wizardButton.setOnClickListener(this); wizardButton.setOnClickListener(this);
insulinButton = (SingleClickButton) view.findViewById(R.id.overview_insulinbutton); insulinButton = (SingleClickButton) view.findViewById(R.id.overview_insulinbutton);
if (insulinButton != null) if (insulinButton != null)
@ -276,7 +274,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
acceptTempButton = (SingleClickButton) view.findViewById(R.id.overview_accepttempbutton); acceptTempButton = (SingleClickButton) view.findViewById(R.id.overview_accepttempbutton);
if (acceptTempButton != null) if (acceptTempButton != null)
acceptTempButton.setOnClickListener(this); acceptTempButton.setOnClickListener(this);
quickWizardButton = requireNonNull(view.findViewById(R.id.overview_quickwizardbutton)); quickWizardButton = (SingleClickButton) view.findViewById(R.id.overview_quickwizardbutton);
quickWizardButton.setOnClickListener(this); quickWizardButton.setOnClickListener(this);
quickWizardButton.setOnLongClickListener(this); quickWizardButton.setOnLongClickListener(this);
calibrationButton = (SingleClickButton) view.findViewById(R.id.overview_calibrationbutton); calibrationButton = (SingleClickButton) view.findViewById(R.id.overview_calibrationbutton);
@ -644,8 +642,19 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
wizardDialog.show(manager, "WizardDialog"); wizardDialog.show(manager, "WizardDialog");
break; break;
case R.id.overview_calibrationbutton: case R.id.overview_calibrationbutton:
CalibrationDialog calibrationDialog = new CalibrationDialog(); boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE);
calibrationDialog.show(manager, "CalibrationDialog"); 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) {
try {
Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity");
startActivity(i);
} catch (ActivityNotFoundException e) {
ToastUtils.showToastInUiThread(getActivity(), MainApp.gs(R.string.g5appnotdetected));
}
}
break; break;
case R.id.overview_cgmbutton: case R.id.overview_cgmbutton:
openXdrip(); openXdrip();
@ -1155,9 +1164,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** Calibration & CGM buttons **** // **** Calibration & CGM buttons ****
boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE); boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE);
boolean g5IsBgSource = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginBase.BGSOURCE);
boolean bgAvailable = DatabaseHelper.actualBg() != null; boolean bgAvailable = DatabaseHelper.actualBg() != null;
if (calibrationButton != null) { if (calibrationButton != null) {
if (xDripIsBgSource && bgAvailable && SP.getBoolean(R.string.key_show_calibration_button, true)) { if ((xDripIsBgSource || g5IsBgSource) && bgAvailable && SP.getBoolean(R.string.key_show_calibration_button, true)) {
calibrationButton.setVisibility(View.VISIBLE); calibrationButton.setVisibility(View.VISIBLE);
} else { } else {
calibrationButton.setVisibility(View.GONE); calibrationButton.setVisibility(View.GONE);

View file

@ -967,5 +967,6 @@
<string name="data_choices">Data Choices</string> <string name="data_choices">Data Choices</string>
<string name="fabric_upload">Fabric Upload</string> <string name="fabric_upload">Fabric Upload</string>
<string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string> <string name="allow_automated_crash_reporting">Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service.</string>
<string name="g5appnotdetected">Please update your G5 app to supported version</string>
</resources> </resources>