This commit is contained in:
Milos Kozak 2019-04-09 22:55:17 +02:00
commit 158724aea1
6 changed files with 33 additions and 14 deletions

View file

@ -196,7 +196,6 @@ dependencies {
implementation "com.jjoe64:graphview:4.0.1" implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1" implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-wearable:10.2.1'
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar") implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
implementation 'com.madgag.spongycastle:core:1.58.0.0' implementation 'com.madgag.spongycastle:core:1.58.0.0'

View file

@ -118,7 +118,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
} }
boolean isCommand(String command, String number) { boolean isCommand(String command, String number) {
switch(command.toUpperCase()) { switch (command.toUpperCase()) {
case "BG": case "BG":
case "LOOP": case "LOOP":
case "TREATMENTS": case "TREATMENTS":
@ -760,11 +760,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
void sendSMS(Sms sms) { void sendSMS(Sms sms) {
SmsManager smsManager = SmsManager.getDefault(); SmsManager smsManager = SmsManager.getDefault();
sms.text = stripAccents(sms.text); sms.text = stripAccents(sms.text);
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
try { try {
if (L.isEnabled(L.SMS)) if (L.isEnabled(L.SMS))
log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text); log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text);
if (sms.text.getBytes().length <= 140)
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null); smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
else {
ArrayList<String> parts = smsManager.divideMessage(sms.text);
smsManager.sendMultipartTextMessage(sms.phoneNumber, null, parts,
null, null);
}
messages.add(sms); messages.add(sms);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL); Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);

View file

@ -625,10 +625,12 @@ public class ActionStringHandler {
} }
generateTempTarget(duration, low, high); generateTempTarget(duration, low, high);
} else if ("wizard2".equals(act[0])) { } else if ("wizard2".equals(act[0])) {
if (lastBolusWizard != null) {
//use last calculation as confirmed string matches //use last calculation as confirmed string matches
doBolus(lastBolusWizard.calculatedTotalInsulin, lastBolusWizard.carbs); doBolus(lastBolusWizard.calculatedTotalInsulin, lastBolusWizard.carbs);
lastBolusWizard = null; lastBolusWizard = null;
}
} else if ("bolus".equals(act[0])) { } else if ("bolus".equals(act[0])) {
double insulin = SafeParse.stringToDouble(act[1]); double insulin = SafeParse.stringToDouble(act[1]);
int carbs = SafeParse.stringToInt(act[2]); int carbs = SafeParse.stringToInt(act[2]);

View file

@ -482,6 +482,8 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
for (; runningTime < now; runningTime += 5 * 60 * 1000) { for (; runningTime < now; runningTime += 5 * 60 * 1000) {
Profile profileTB = ProfileFunctions.getInstance().getProfile(runningTime); Profile profileTB = ProfileFunctions.getInstance().getProfile(runningTime);
if (profileTB == null)
return;
//basal rate //basal rate
endBasalValue = profile.getBasal(runningTime); endBasalValue = profile.getBasal(runningTime);
if (endBasalValue != beginBasalValue) { if (endBasalValue != beginBasalValue) {

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
@ -187,6 +188,10 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (insulinInterface == null) if (insulinInterface == null)
return total; return total;
PumpInterface pumpInterface = ConfigBuilderPlugin.getPlugin().getActivePump();
if (pumpInterface == null)
return total;
double dia = profile.getDia(); double dia = profile.getDia();
synchronized (treatments) { synchronized (treatments) {
@ -210,7 +215,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
} }
} }
if (!ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) if (!pumpInterface.isFakingTempsByExtendedBoluses())
synchronized (extendedBoluses) { synchronized (extendedBoluses) {
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) { for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
ExtendedBolus e = extendedBoluses.get(pos); ExtendedBolus e = extendedBoluses.get(pos);

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.queue.events.EventQueueChanged; import info.nightscout.androidaps.queue.events.EventQueueChanged;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.T;
/** /**
* Created by mike on 09.11.2017. * Created by mike on 09.11.2017.
@ -28,9 +29,8 @@ public class QueueThread extends Thread {
private CommandQueue queue; private CommandQueue queue;
private long lastCommandTime = 0;
private boolean connectLogged = false; private boolean connectLogged = false;
public boolean waitingForDisconnect = false; boolean waitingForDisconnect = false;
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
@ -41,14 +41,17 @@ public class QueueThread extends Thread {
Context context = MainApp.instance().getApplicationContext(); Context context = MainApp.instance().getApplicationContext();
if (context != null) { if (context != null) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (powerManager != null)
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:QueueThread"); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:QueueThread");
} }
} }
@Override @Override
public final void run() { public final void run() {
mWakeLock.acquire(); if (mWakeLock != null)
mWakeLock.acquire(T.mins(10).msecs());
MainApp.bus().post(new EventQueueChanged()); MainApp.bus().post(new EventQueueChanged());
long lastCommandTime;
long connectionStartTime = lastCommandTime = System.currentTimeMillis(); long connectionStartTime = lastCommandTime = System.currentTimeMillis();
try { try {
@ -72,7 +75,7 @@ public class QueueThread extends Thread {
//BLUETOOTH-WATCHDOG //BLUETOOTH-WATCHDOG
boolean watchdog = SP.getBoolean(R.string.key_btwatchdog, false); boolean watchdog = SP.getBoolean(R.string.key_btwatchdog, false);
long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0l); long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0L);
watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000); watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000);
if (watchdog) { if (watchdog) {
if (L.isEnabled(L.PUMPQUEUE)) if (L.isEnabled(L.PUMPQUEUE))
@ -170,6 +173,7 @@ public class QueueThread extends Thread {
} }
} }
} finally { } finally {
if (mWakeLock != null)
mWakeLock.release(); mWakeLock.release();
if (L.isEnabled(L.PUMPQUEUE)) if (L.isEnabled(L.PUMPQUEUE))
log.debug("thread end"); log.debug("thread end");