commit
638b9c263c
|
@ -70,7 +70,7 @@ android {
|
|||
dimension "limits"
|
||||
buildConfigField "int", "MAXBOLUS", "5"
|
||||
}
|
||||
full {
|
||||
full {
|
||||
dimension "standard"
|
||||
buildConfigField "boolean", "APS", "true"
|
||||
buildConfigField "boolean", "PUMPDRIVERS", "true"
|
||||
|
|
|
@ -31,4 +31,6 @@ public interface Intents {
|
|||
String ACTION_NEW_BG_ESTIMATE_NO_DATA = "com.eveningoutpost.dexdrip.BgEstimateNoData";
|
||||
|
||||
String NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR";
|
||||
|
||||
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
|
||||
}
|
||||
|
|
|
@ -6,6 +6,14 @@ import android.support.annotation.Nullable;
|
|||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.stmt.PreparedQuery;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -21,6 +29,7 @@ import info.nightscout.utils.Round;
|
|||
*/
|
||||
|
||||
public class GlucoseStatus {
|
||||
private static Logger log = LoggerFactory.getLogger(GlucoseStatus.class);
|
||||
public double glucose = 0d;
|
||||
public double delta = 0d;
|
||||
public double avgdelta = 0d;
|
||||
|
@ -124,6 +133,48 @@ public class GlucoseStatus {
|
|||
return status.round();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last BgReading from database or null if db is empty
|
||||
*/
|
||||
@Nullable
|
||||
public static BgReading lastBg() {
|
||||
List<BgReading> bgList = null;
|
||||
|
||||
try {
|
||||
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
|
||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
||||
queryBuilder.orderBy("timeIndex", false);
|
||||
queryBuilder.limit(1L);
|
||||
queryBuilder.where().gt("value", 38);
|
||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||
bgList = daoBgReadings.query(preparedQuery);
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
}
|
||||
if (bgList != null && bgList.size() > 0)
|
||||
return bgList.get(0);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return bg reading if not old ( <9 min )
|
||||
* or null if older
|
||||
*/
|
||||
@Nullable
|
||||
public static BgReading actualBg() {
|
||||
BgReading lastBg = lastBg();
|
||||
|
||||
if (lastBg == null)
|
||||
return null;
|
||||
|
||||
if (lastBg.timeIndex > new Date().getTime() - 9 * 60 * 1000)
|
||||
return lastBg;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static double average(ArrayList<Double> array) {
|
||||
double sum = 0d;
|
||||
|
||||
|
|
|
@ -172,48 +172,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
return getDao(DanaRHistoryRecord.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last BgReading from database or null if db is empty
|
||||
*/
|
||||
@Nullable
|
||||
public BgReading lastBg() {
|
||||
List<BgReading> bgList = null;
|
||||
|
||||
try {
|
||||
Dao<BgReading, Long> daoBgReadings = getDaoBgReadings();
|
||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
||||
queryBuilder.orderBy("timeIndex", false);
|
||||
queryBuilder.limit(1L);
|
||||
queryBuilder.where().gt("value", 38);
|
||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||
bgList = daoBgReadings.query(preparedQuery);
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
}
|
||||
if (bgList != null && bgList.size() > 0)
|
||||
return bgList.get(0);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return bg reading if not old ( <9 min )
|
||||
* or null if older
|
||||
*/
|
||||
@Nullable
|
||||
public BgReading actualBg() {
|
||||
BgReading lastBg = lastBg();
|
||||
|
||||
if (lastBg == null)
|
||||
return null;
|
||||
|
||||
if (lastBg.timeIndex > new Date().getTime() - 9 * 60 * 1000)
|
||||
return lastBg;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||
try {
|
||||
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
||||
|
|
|
@ -496,7 +496,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
// Compare with extended rate in progress
|
||||
if (Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < 0.02D) { // Allow some rounding diff
|
||||
if (isExtendedBoluslInProgress() && Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
|
||||
// correct extended already set
|
||||
result.success = true;
|
||||
result.absolute = getDanaRPump().extendedBolusAbsoluteRate;
|
||||
|
|
|
@ -496,7 +496,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
}
|
||||
|
||||
// Compare with extended rate in progress
|
||||
if (Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < 0.02D) { // Allow some rounding diff
|
||||
if (isExtendedBoluslInProgress() && Math.abs(getDanaRPump().extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
|
||||
// correct extended already set
|
||||
result.success = true;
|
||||
result.absolute = getDanaRPump().extendedBolusAbsoluteRate;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package info.nightscout.androidaps.plugins.Overview.Dialogs;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.XdripCalibrations;
|
||||
|
||||
public class CalibrationDialog extends DialogFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(CalibrationDialog.class);
|
||||
|
||||
Button okButton;
|
||||
PlusMinusEditText bgText;
|
||||
TextView unitsView;
|
||||
|
||||
Context parentContext;
|
||||
|
||||
public CalibrationDialog() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
parentContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.overview_calibration_dialog, container, false);
|
||||
|
||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton);
|
||||
okButton.setOnClickListener(this);
|
||||
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
Double bg = NSProfile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits());
|
||||
if (profile.getUnits().equals(Constants.MMOL))
|
||||
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
else
|
||||
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
|
||||
unitsView.setText(profile.getUnits());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.overview_calibration_okbutton:
|
||||
final Double bg = bgText.getValue();
|
||||
XdripCalibrations.confirmAndSendCalibration(bg, parentContext);
|
||||
dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ import java.util.Date;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||
|
@ -278,7 +279,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
else editBg.setStep(0.1d);
|
||||
|
||||
// Set BG if not old
|
||||
BgReading lastBg = MainApp.getDbHelper().actualBg();
|
||||
BgReading lastBg = GlucoseStatus.actualBg();
|
||||
|
||||
if (lastBg != null) {
|
||||
Double lastBgValue = lastBg.valueToUnits(units);
|
||||
|
|
|
@ -75,12 +75,14 @@ import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotificati
|
|||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
@ -125,6 +127,7 @@ public class OverviewFragment extends Fragment {
|
|||
Button cancelTempButton;
|
||||
Button treatmentButton;
|
||||
Button wizardButton;
|
||||
Button calibrationButton;
|
||||
Button acceptTempButton;
|
||||
Button quickWizardButton;
|
||||
|
||||
|
@ -172,6 +175,7 @@ public class OverviewFragment extends Fragment {
|
|||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
||||
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
|
||||
calibrationButton = (Button) view.findViewById(R.id.overview_calibration);
|
||||
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
||||
|
||||
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
||||
|
@ -233,6 +237,15 @@ public class OverviewFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
calibrationButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
CalibrationDialog calibrationDialog = new CalibrationDialog();
|
||||
calibrationDialog.setContext(getContext());
|
||||
calibrationDialog.show(manager, "CalibrationDialog");
|
||||
}
|
||||
});
|
||||
|
||||
acceptTempButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -278,7 +291,7 @@ public class OverviewFragment extends Fragment {
|
|||
}
|
||||
|
||||
void processQuickWizard() {
|
||||
final BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||
final BgReading lastBG = GlucoseStatus.lastBg();
|
||||
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
|
||||
return;
|
||||
final NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||
|
@ -465,8 +478,8 @@ public class OverviewFragment extends Fragment {
|
|||
@SuppressLint("SetTextI18n")
|
||||
public void updateGUI() {
|
||||
updateNotifications();
|
||||
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||
BgReading actualBG = GlucoseStatus.actualBg();
|
||||
BgReading lastBG = GlucoseStatus.lastBg();
|
||||
|
||||
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
||||
initializingView.setText(R.string.noprofileset);
|
||||
|
@ -571,6 +584,13 @@ public class OverviewFragment extends Fragment {
|
|||
acceptTempLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// **** Calibration button ****
|
||||
if (MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE) && profile != null && GlucoseStatus.actualBg() != null) {
|
||||
calibrationButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
calibrationButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
TempBasal activeTemp = pump.getTempBasal();
|
||||
if (pump.isTempBasalInProgress()) {
|
||||
cancelTempLayout.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommuni
|
|||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.XdripCalibrations;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -63,6 +64,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
String confirmCode;
|
||||
double bolusRequested = 0d;
|
||||
double tempBasal = 0d;
|
||||
double calibrationRequested = 0d;
|
||||
|
||||
public Sms(SmsMessage message) {
|
||||
phoneNumber = message.getOriginatingAddress();
|
||||
|
@ -94,6 +96,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
Sms cancelTempBasalWaitingForConfirmation = null;
|
||||
Sms tempBasalWaitingForConfirmation = null;
|
||||
Sms bolusWaitingForConfirmation = null;
|
||||
Sms calibrationWaitingForConfirmation = null;
|
||||
Date lastRemoteBolusTime = new Date(0);
|
||||
|
||||
ArrayList<Sms> messages = new ArrayList<>();
|
||||
|
@ -121,7 +124,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.smscommunicator_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
|
@ -212,8 +215,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
if (splited.length > 0) {
|
||||
switch (splited[0].toUpperCase()) {
|
||||
case "BG":
|
||||
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||
BgReading actualBG = GlucoseStatus.actualBg();
|
||||
BgReading lastBG = GlucoseStatus.lastBg();
|
||||
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
String units = profile.getUnits();
|
||||
|
@ -366,6 +369,23 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case "CAL":
|
||||
if (splited.length > 1) {
|
||||
amount = SafeParse.stringToDouble(splited[1]);
|
||||
boolean remoteCommandsAllowed = sharedPreferences.getBoolean("smscommunicator_remotecommandsallowed", false);
|
||||
if (amount > 0d && remoteCommandsAllowed) {
|
||||
passCode = generatePasscode();
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationreplywithcode), amount, passCode);
|
||||
receivedSms.processed = true;
|
||||
resetWaitingMessages();
|
||||
sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode));
|
||||
calibrationWaitingForConfirmation.calibrationRequested = amount;
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotecalibrationnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: // expect passCode here
|
||||
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
|
@ -419,6 +439,17 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.processed = true;
|
||||
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
|
||||
if (result) {
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_calibrationsent));
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_calibrationfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else {
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
|
||||
}
|
||||
|
@ -471,6 +502,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
tempBasalWaitingForConfirmation = null;
|
||||
cancelTempBasalWaitingForConfirmation = null;
|
||||
bolusWaitingForConfirmation = null;
|
||||
calibrationWaitingForConfirmation = null;
|
||||
}
|
||||
|
||||
public static String stripAccents(String s) {
|
||||
|
|
|
@ -182,7 +182,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
private void sendData() {
|
||||
|
||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||
BgReading lastBG = GlucoseStatus.lastBg();
|
||||
if (lastBG != null) {
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
|
||||
|
@ -290,7 +290,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
private void resendData() {
|
||||
if(googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); }
|
||||
long startTime = System.currentTimeMillis() - (long)(60000 * 60 * 5.5);
|
||||
BgReading last_bg = MainApp.getDbHelper().lastBg();
|
||||
BgReading last_bg = GlucoseStatus.lastBg();
|
||||
|
||||
if (last_bg == null) return;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class PersistentNotificationPlugin implements PluginBase{
|
|||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
|
||||
|
||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||
BgReading lastBG = GlucoseStatus.lastBg();
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
|
||||
if(profile != null && lastBG != null) {
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package info.nightscout.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
||||
/**
|
||||
* Created by mike on 10.02.2017.
|
||||
*/
|
||||
|
||||
public class XdripCalibrations {
|
||||
private static Logger log = LoggerFactory.getLogger(XdripCalibrations.class);
|
||||
|
||||
public static void confirmAndSendCalibration(final Double bg, Context parentContext) {
|
||||
if (parentContext != null) {
|
||||
String confirmMessage = String.format(MainApp.sResources.getString(R.string.send_calibration), bg);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
sendIntent(bg);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean sendIntent(Double bg) {
|
||||
final NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putDouble("glucose_number", bg);
|
||||
bundle.putString("units", profile.getUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
||||
bundle.putLong("timestamp", new Date().getTime());
|
||||
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
if (q.size() < 1) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.xdripnotinstalled));
|
||||
log.debug(MainApp.sResources.getString(R.string.xdripnotinstalled));
|
||||
return false;
|
||||
} else {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.calibrationsent));
|
||||
log.debug(MainApp.sResources.getString(R.string.calibrationsent));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
86
app/src/main/res/layout/overview_calibration_dialog.xml
Normal file
86
app/src/main/res/layout/overview_calibration_dialog.xml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="@string/overview_calibration_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:id="@+id/overview_calibration_units"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_calibration_bg_minus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center_horizontal"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="100dp"
|
||||
android:padding="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_calibration_bg_plus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/overview_calibration_okbutton"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="OK"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginTop="30dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -217,8 +217,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="Accept new temp\n0.25U/h"
|
||||
|
@ -237,8 +237,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="Cancel temp basal"
|
||||
|
@ -257,8 +257,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/overview_bolus_label"
|
||||
|
@ -270,12 +270,25 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/overview_calculator_label"
|
||||
android:textColor="@color/colorWizardButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/overview_calibration"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/overview_calibration"
|
||||
android:textColor="@color/colorCalibrationButton" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -289,8 +302,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:drawableLeft="@drawable/bread"
|
||||
|
|
|
@ -450,4 +450,13 @@
|
|||
<string name="error_only_numeric_digits_allowed">Povoleny pouze číslice</string>
|
||||
<string name="error_only_numeric_digits_range_allowed">Povoleny pouze čísla v rozsahu %1$s - %2$s</string>
|
||||
<string name="error_phone_not_valid">Neplatné telefonní číslo</string>
|
||||
<string name="calibrationsent">Kalibrace odeslána do xDripu</string>
|
||||
<string name="overview_calibration">Kalibrace</string>
|
||||
<string name="overview_calibration_bg_label">Kalibrační glykémie</string>
|
||||
<string name="send_calibration">Poslat do xDripu kalibraci %.1f ?</string>
|
||||
<string name="xdripnotinstalled">xDrip+ není nainstalován</string>
|
||||
<string name="smscommunicator_calibrationfailed">xDrip nepřijímá kalibrace</string>
|
||||
<string name="smscommunicator_calibrationreplywithcode" formatted="false">Odeslání kalibrace %.2f potvrďte kódem %s</string>
|
||||
<string name="smscommunicator_calibrationsent">Kalibrace odeslána</string>
|
||||
<string name="smscommunicator_remotecalibrationnotallowed">Vzdálené kalibrace nejsou povoleny</string>
|
||||
</resources>
|
||||
|
|
|
@ -398,4 +398,8 @@
|
|||
<string name="configbuilder_shortname">" "</string>
|
||||
<string name="circadian_percentage_profile_shortname">" "</string>
|
||||
<string name="careportal_shortname">" "</string>
|
||||
<string name="error_field_must_not_be_empty">필수 입력 항목입니다.</string>
|
||||
<string name="error_only_numeric_digits_allowed">숫자만 입력가능합니다.</string>
|
||||
<string name="error_only_numeric_digits_range_allowed">이 범위(%1$s - %2$s)안에 해당하는 숫자만 입력가능합니다.</string>
|
||||
<string name="error_phone_not_valid">유효한 도메인 이름이 아닙니다.</string>
|
||||
</resources>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<color name="colorSetExtendedButton">#FFDD7792</color>
|
||||
<color name="colorProfileSwitchButton">#ca77dd</color>
|
||||
<color name="colorTempTargetButton">#d43429</color>
|
||||
<color name="colorCalibrationButton">#ceb812</color>
|
||||
|
||||
<color name="colorInProgress">#c45026</color>
|
||||
<color name="colorAffectingIOB">#830400</color>
|
||||
|
|
|
@ -253,6 +253,7 @@
|
|||
<string name="smscommunicator_allowednumbers">Allowed phone numbers</string>
|
||||
<string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string>
|
||||
<string name="smscommunicator_bolusreplywithcode" formatted="false">To deliver bolus %.2fU reply with code %s</string>
|
||||
<string name="smscommunicator_calibrationreplywithcode" formatted="false">To send calibration %.2f reply with code %s</string>
|
||||
<string name="smscommunicator_bolusfailed">Bolus failed</string>
|
||||
<string name="bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string>
|
||||
<string name="bolusrequested" formatted="false">Going to deliver %.2fU</string>
|
||||
|
@ -454,7 +455,7 @@
|
|||
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
|
||||
<string name="advancedsettings_title">Advanced Settings</string>
|
||||
<string name="virtualpump_firmware_label">Firmware:</string>
|
||||
<string formatted="false" name="danar_model">Model: %02X Protocol: %02X Code: %02X</string>
|
||||
<string name="danar_model" formatted="false">Model: %02X Protocol: %02X Code: %02X</string>
|
||||
<string name="profile">Profile</string>
|
||||
<string name="openapsama_max_daily_safety_multiplier" translatable="false">max_daily_safety_multiplier</string>
|
||||
<string name="openapsama_max_daily_safety_multiplier_summary">Default value: 3\nThis is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps.</string>
|
||||
|
@ -480,4 +481,12 @@
|
|||
<string name="copy_to_clipboard">Copy To Clipboard</string>
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="nav_show_logcat">Show log</string>
|
||||
<string name="overview_calibration">Calibration</string>
|
||||
<string name="overview_calibration_bg_label">Calibration BG</string>
|
||||
<string name="send_calibration" formatted="false">Send calibration %.1f to xDrip?</string>
|
||||
<string name="xdripnotinstalled">xDrip+ not installed</string>
|
||||
<string name="calibrationsent">Calibration sent to xDrip</string>
|
||||
<string name="smscommunicator_remotecalibrationnotallowed">Remote calibration not allowed</string>
|
||||
<string name="smscommunicator_calibrationsent">Calibration sent</string>
|
||||
<string name="smscommunicator_calibrationfailed">xDrip is not receiving calibrations</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue