Merge branch 'dev' into move-to-range-in-profile
|
@ -44,7 +44,7 @@ android {
|
|||
minSdkVersion 21
|
||||
targetSdkVersion 23
|
||||
versionCode 1500
|
||||
version "1.5d"
|
||||
version "1.5f"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||
}
|
||||
|
@ -183,4 +183,4 @@ dependencies {
|
|||
compile 'com.google.code.gson:gson:2.7'
|
||||
compile 'com.google.guava:guava:20.0'
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,16 +56,6 @@
|
|||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<!-- Receiver from NSClient -->
|
||||
<action android:name="info.nightscout.client.NEW_SGV" />
|
||||
<action android:name="info.nightscout.client.NEW_TREATMENT" />
|
||||
<action android:name="info.nightscout.client.CHANGED_TREATMENT" />
|
||||
<action android:name="info.nightscout.client.REMOVED_TREATMENT" />
|
||||
<action android:name="info.nightscout.client.NEW_PROFILE" />
|
||||
<action android:name="info.nightscout.client.NEW_STATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_MBG" />
|
||||
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_CAL" />
|
||||
<!-- Receive new SMS messages -->
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
<!-- Receiver from xDrip -->
|
||||
|
@ -76,20 +66,6 @@
|
|||
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".receivers.NSAlarmReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<!-- Receiver from NSClient -->
|
||||
<action android:name="info.nightscout.client.ANNOUNCEMENT" />
|
||||
<action android:name="info.nightscout.client.ALARM" />
|
||||
<action android:name="info.nightscout.client.URGENT_ALARM" />
|
||||
<action android:name="info.nightscout.client.CLEAR_ALARM" />
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
||||
<receiver android:name=".receivers.KeepAliveReceiver" />
|
||||
|
||||
|
@ -120,14 +96,6 @@
|
|||
<action android:name="info.nightscout.client.DBACCESS" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".plugins.NSClientInternal.receivers.AckAlarmReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="info.nightscout.client.ACK_ALARM" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Service processing incomming data -->
|
||||
<service
|
||||
|
|
|
@ -2,8 +2,10 @@ package info.nightscout.androidaps;
|
|||
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
|
@ -17,6 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
@ -32,6 +35,7 @@ import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFast
|
|||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||
|
@ -59,7 +63,9 @@ import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
|||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
|
@ -77,6 +83,11 @@ public class MainApp extends Application {
|
|||
|
||||
private static ArrayList<PluginBase> pluginsList = null;
|
||||
|
||||
private static DataReceiver dataReceiver = new DataReceiver();
|
||||
private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
|
||||
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
|
||||
private LocalBroadcastManager lbm;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
@ -92,6 +103,8 @@ public class MainApp extends Application {
|
|||
sInstance = this;
|
||||
sResources = getResources();
|
||||
|
||||
registerLocalBroadcastReceiver();
|
||||
|
||||
if (pluginsList == null) {
|
||||
pluginsList = new ArrayList<>();
|
||||
// Register all tabs in app here
|
||||
|
@ -155,6 +168,29 @@ public class MainApp extends Application {
|
|||
}
|
||||
});
|
||||
t.start();
|
||||
|
||||
}
|
||||
|
||||
private void registerLocalBroadcastReceiver() {
|
||||
lbm = LocalBroadcastManager.getInstance(this);
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_DEVICESTATUS));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
|
||||
|
||||
//register alarms
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ALARM));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ANNOUNCEMENT));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
|
||||
|
||||
//register ack alarm
|
||||
lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
|
||||
}
|
||||
|
||||
private void startKeepAliveService() {
|
||||
|
|
|
@ -506,7 +506,7 @@ public class DataService extends IntentService {
|
|||
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(trJson);
|
||||
}
|
||||
|
||||
if (trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
|
||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
|
||||
long date = trJson.getLong("mills");
|
||||
long now = System.currentTimeMillis();
|
||||
if (date > now - 15 * 60 * 1000L && trJson.has("notes")) {
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.05.2017.
|
||||
*/
|
||||
|
||||
// Zero duration means end of interval
|
||||
|
||||
public abstract class Intervals<T extends Interval> {
|
||||
|
||||
LongSparseArray<T> rawData = new LongSparseArray<T>(); // oldest at index 0
|
||||
|
||||
public synchronized Intervals reset() {
|
||||
rawData = new LongSparseArray<T>();
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract void merge();
|
||||
|
||||
/**
|
||||
* The List must be sorted by `T.start()` in ascending order
|
||||
*
|
||||
* */
|
||||
public synchronized void add(List<T> list) {
|
||||
for (T interval : list) {
|
||||
rawData.put(interval.start(), interval);
|
||||
}
|
||||
merge();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public synchronized List<T> getList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = 0; i < rawData.size(); i++)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
public synchronized List<T> getReversedList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = rawData.size() -1; i>=0; i--)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
protected synchronized int binarySearch(long value) {
|
||||
int lo = 0;
|
||||
int hi = rawData.size() - 1;
|
||||
|
||||
while (lo <= hi) {
|
||||
final int mid = (lo + hi) >>> 1;
|
||||
final Interval midVal = rawData.valueAt(mid);
|
||||
|
||||
if (midVal.before(value)) {
|
||||
lo = mid + 1;
|
||||
} else if (midVal.after(value)) {
|
||||
hi = mid - 1;
|
||||
} else if (midVal.match(value)) {
|
||||
return mid; // value found
|
||||
}
|
||||
}
|
||||
return ~lo; // value not present
|
||||
}
|
||||
|
||||
public abstract T getValueByInterval(long time);
|
||||
|
||||
public synchronized int size() {
|
||||
return rawData.size();
|
||||
}
|
||||
|
||||
public synchronized T get(int index) {
|
||||
return rawData.valueAt(index);
|
||||
}
|
||||
|
||||
public synchronized T getReversed(int index) {
|
||||
return rawData.valueAt(size() - 1 - index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
|
||||
/**
|
||||
* Created by adrian on 15/07/17.
|
||||
*/
|
||||
|
||||
public class NonOverlappingIntervals<T extends Interval> extends Intervals<T> {
|
||||
|
||||
protected synchronized void merge() {
|
||||
for (int index = 0; index < rawData.size() - 1; index++) {
|
||||
Interval i = rawData.valueAt(index);
|
||||
long startOfNewer = rawData.valueAt(index + 1).start();
|
||||
if (i.originalEnd() > startOfNewer) {
|
||||
i.cutEndTo(startOfNewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public synchronized T getValueByInterval(long time) {
|
||||
int index = binarySearch(time);
|
||||
if (index >= 0) return rawData.valueAt(index);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,99 +1,43 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.05.2017.
|
||||
* Created by adrian on 15/07/17.
|
||||
*/
|
||||
|
||||
// Zero duration means end of interval
|
||||
public class OverlappingIntervals<T extends Interval> extends Intervals<T> {
|
||||
|
||||
public class OverlappingIntervals<T extends Interval> {
|
||||
protected synchronized void merge() {
|
||||
boolean needToCut = false;
|
||||
long cutTime = 0;
|
||||
|
||||
private LongSparseArray<T> rawData = new LongSparseArray<>(); // oldest at index 0
|
||||
|
||||
public OverlappingIntervals reset() {
|
||||
rawData = new LongSparseArray<>();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void add(T newInterval) {
|
||||
rawData.put(newInterval.start(), newInterval);
|
||||
merge();
|
||||
}
|
||||
|
||||
public void add(List<T> list) {
|
||||
for (T interval : list) {
|
||||
rawData.put(interval.start(), interval);
|
||||
}
|
||||
merge();
|
||||
}
|
||||
|
||||
private void merge() {
|
||||
for (int index = 0; index < rawData.size() - 1; index++) {
|
||||
Interval i = rawData.valueAt(index);
|
||||
long startOfNewer = rawData.valueAt(index + 1).start();
|
||||
if (i.originalEnd() > startOfNewer) {
|
||||
i.cutEndTo(startOfNewer);
|
||||
for (int index = rawData.size()-1; index > 0; index--) { //begin with newest
|
||||
Interval cur = rawData.valueAt(index);
|
||||
if (cur.isEndingEvent()){
|
||||
needToCut = true;
|
||||
cutTime = cur.start();
|
||||
} else {
|
||||
//event that is no EndingEvent might need to be stopped by an ending event
|
||||
if(needToCut&&cur.end() > cutTime){
|
||||
cur.cutEndTo(cutTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Interval getValueByInterval(long time) {
|
||||
int index = binarySearch(time);
|
||||
if (index >= 0) return rawData.valueAt(index);
|
||||
public synchronized T getValueByInterval(long time) {
|
||||
for (int index = rawData.size()-1; index > 0; index--) { //begin with newest
|
||||
T cur = rawData.valueAt(index);
|
||||
if (cur.match(time)){
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = 0; i < rawData.size(); i++)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<T> getReversedList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = rawData.size() -1; i>=0; i--)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
private int binarySearch(long value) {
|
||||
int lo = 0;
|
||||
int hi = rawData.size() - 1;
|
||||
|
||||
while (lo <= hi) {
|
||||
final int mid = (lo + hi) >>> 1;
|
||||
final Interval midVal = rawData.valueAt(mid);
|
||||
|
||||
if (midVal.before(value)) {
|
||||
lo = mid + 1;
|
||||
} else if (midVal.after(value)) {
|
||||
hi = mid - 1;
|
||||
} else if (midVal.match(value)) {
|
||||
return mid; // value found
|
||||
}
|
||||
}
|
||||
return ~lo; // value not present
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return rawData.size();
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
return rawData.valueAt(index);
|
||||
}
|
||||
|
||||
public T getReversed(int index) {
|
||||
return rawData.valueAt(size() - 1 - index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,24 +19,24 @@ public class ProfileIntervals<T extends Interval> {
|
|||
|
||||
private LongSparseArray<T> rawData = new LongSparseArray<>(); // oldest at index 0
|
||||
|
||||
public ProfileIntervals reset() {
|
||||
public synchronized ProfileIntervals reset() {
|
||||
rawData = new LongSparseArray<>();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void add(T newInterval) {
|
||||
public synchronized void add(T newInterval) {
|
||||
rawData.put(newInterval.start(), newInterval);
|
||||
merge();
|
||||
}
|
||||
|
||||
public void add(List<T> list) {
|
||||
public synchronized void add(List<T> list) {
|
||||
for (T interval : list) {
|
||||
rawData.put(interval.start(), interval);
|
||||
}
|
||||
merge();
|
||||
}
|
||||
|
||||
private void merge() {
|
||||
private synchronized void merge() {
|
||||
for (int index = 0; index < rawData.size() - 1; index++) {
|
||||
Interval i = rawData.valueAt(index);
|
||||
long startOfNewer = rawData.valueAt(index + 1).start();
|
||||
|
@ -47,27 +47,27 @@ public class ProfileIntervals<T extends Interval> {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public Interval getValueToTime(long time) {
|
||||
public synchronized Interval getValueToTime(long time) {
|
||||
int index = binarySearch(time);
|
||||
if (index >= 0) return rawData.valueAt(index);
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
public synchronized List<T> getList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = 0; i < rawData.size(); i++)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<T> getReversedList() {
|
||||
public synchronized List<T> getReversedList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (int i = rawData.size() -1; i>=0; i--)
|
||||
list.add(rawData.valueAt(i));
|
||||
return list;
|
||||
}
|
||||
|
||||
private int binarySearch(long value) {
|
||||
private synchronized int binarySearch(long value) {
|
||||
if (rawData.size() == 0)
|
||||
return -1;
|
||||
int lo = 0;
|
||||
|
@ -95,15 +95,15 @@ public class ProfileIntervals<T extends Interval> {
|
|||
return -1; // value not present
|
||||
}
|
||||
|
||||
public int size() {
|
||||
public synchronized int size() {
|
||||
return rawData.size();
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
public synchronized T get(int index) {
|
||||
return rawData.valueAt(index);
|
||||
}
|
||||
|
||||
public T getReversed(int index) {
|
||||
public synchronized T getReversed(int index) {
|
||||
return rawData.valueAt(size() - 1 - index);
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ public class TempTarget implements Interval {
|
|||
return false;
|
||||
if (high != other.high)
|
||||
return false;
|
||||
if (reason != other.reason)
|
||||
if (!Objects.equals(reason, other.reason))
|
||||
return false;
|
||||
if (!Objects.equals(_id, other._id))
|
||||
return false;
|
||||
|
|
|
@ -289,17 +289,17 @@ public class TemporaryBasal implements Interval {
|
|||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
double rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
return DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
|
||||
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
|
||||
DateUtil.timeString(date) +
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "'";
|
||||
} else if (isAbsolute) {
|
||||
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" +
|
||||
DateUtil.timeString(date) +
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "'";
|
||||
} else { // percent
|
||||
return percentRate + "% @" +
|
||||
DateUtil.timeString(date) +
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||
" " + getRealDuration() + "/" + durationInMinutes + "'";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,6 +330,31 @@ public class TemporaryBasal implements Interval {
|
|||
}
|
||||
}
|
||||
|
||||
private String getCalcuatedPercentageIfNeeded(){
|
||||
if (isAbsolute || isFakeExtended) {
|
||||
|
||||
double rate = 0d;
|
||||
if (isFakeExtended) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
} else if (isAbsolute){
|
||||
rate = absoluteRate;
|
||||
}
|
||||
|
||||
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if(profile != null) {
|
||||
double basal = profile.getBasal();
|
||||
if(basal != 0){
|
||||
return Math.round(rate*100d/basal) + "% ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String toStringVeryShort() {
|
||||
if (isAbsolute || isFakeExtended) {
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ public interface PumpInterface {
|
|||
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes);
|
||||
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
|
||||
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
||||
PumpEnactResult cancelTempBasal();
|
||||
//some pumps might set a very short temp close to 100% as canecelling a temp can be noisy
|
||||
//when the cancel request is requested by the user, the pump should always do a real cancel
|
||||
PumpEnactResult cancelTempBasal(boolean userRequested);
|
||||
PumpEnactResult cancelExtendedBolus();
|
||||
|
||||
// Status to be passed to NS
|
||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||
|
||||
/**
|
||||
|
@ -42,18 +42,18 @@ public interface TreatmentsInterface {
|
|||
TemporaryBasal getTempBasalFromHistory(long time);
|
||||
double getTempBasalAbsoluteRateHistory();
|
||||
double getTempBasalRemainingMinutesFromHistory();
|
||||
OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory();
|
||||
Intervals<TemporaryBasal> getTemporaryBasalsFromHistory();
|
||||
|
||||
boolean isInHistoryExtendedBoluslInProgress();
|
||||
ExtendedBolus getExtendedBolusFromHistory(long time);
|
||||
OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory();
|
||||
Intervals<ExtendedBolus> getExtendedBolusesFromHistory();
|
||||
|
||||
boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus);
|
||||
|
||||
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||
|
||||
TempTarget getTempTargetFromHistory(long time);
|
||||
OverlappingIntervals<TempTarget> getTempTargetsFromHistory();
|
||||
Intervals<TempTarget> getTempTargetsFromHistory();
|
||||
|
||||
ProfileSwitch getProfileSwitchFromHistory(long time);
|
||||
ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory();
|
||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
|
@ -31,11 +32,12 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
|
|||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class ActionsFragment extends Fragment implements View.OnClickListener {
|
||||
public class ActionsFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
|
||||
static ActionsPlugin actionsPlugin = new ActionsPlugin();
|
||||
|
||||
|
@ -48,6 +50,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
Button extendedBolus;
|
||||
Button extendedBolusCancel;
|
||||
Button tempBasal;
|
||||
Button tempBasalCancel;
|
||||
Button fill;
|
||||
|
||||
private static Handler sHandler;
|
||||
|
@ -73,6 +76,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
||||
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
||||
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
||||
fill = (Button) view.findViewById(R.id.actions_fill);
|
||||
|
||||
profileSwitch.setOnClickListener(this);
|
||||
|
@ -80,77 +84,93 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
extendedBolus.setOnClickListener(this);
|
||||
extendedBolusCancel.setOnClickListener(this);
|
||||
tempBasal.setOnClickListener(this);
|
||||
tempBasalCancel.setOnClickListener(this);
|
||||
fill.setOnClickListener(this);
|
||||
|
||||
updateGUIIfVisible();
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||
updateGUIIfVisible();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
||||
updateGUIIfVisible();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||
updateGUIIfVisible();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||
updateGUIIfVisible();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
void updateGUIIfVisible() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null)
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null) {
|
||||
tempTarget.setVisibility(View.GONE);
|
||||
profileSwitch.setVisibility(View.GONE);
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
tempBasalCancel.setVisibility(View.GONE);
|
||||
fill.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1;
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !allowProfileSwitch)
|
||||
profileSwitch.setVisibility(View.GONE);
|
||||
else
|
||||
profileSwitch.setVisibility(View.VISIBLE);
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
|
||||
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
else {
|
||||
extendedBolus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
else {
|
||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
|
||||
} else {
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
|
||||
} else {
|
||||
extendedBolus.setVisibility(View.VISIBLE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
else
|
||||
tempBasal.setVisibility(View.VISIBLE);
|
||||
tempBasalCancel.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
tempBasalCancel.setVisibility(View.VISIBLE);
|
||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
|
||||
} else {
|
||||
tempBasal.setVisibility(View.VISIBLE);
|
||||
tempBasalCancel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
|
||||
fill.setVisibility(View.GONE);
|
||||
else
|
||||
fill.setVisibility(View.VISIBLE);
|
||||
|
||||
if (!Config.APS)
|
||||
tempTarget.setVisibility(View.GONE);
|
||||
else
|
||||
|
@ -194,6 +214,17 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
});
|
||||
}
|
||||
break;
|
||||
case R.id.actions_canceltempbasal:
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pump.cancelTempBasal(true);
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case R.id.actions_settempbasal:
|
||||
NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
|
||||
newTempDialog.show(manager, "NewTempDialog");
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
|
@ -35,14 +36,14 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
RadioButton percentRadio;
|
||||
RadioButton absoluteRadio;
|
||||
RadioGroup basalTypeRadioGroup;
|
||||
RelativeLayout typeSelectorLayout;
|
||||
LinearLayout typeSelectorLayout;
|
||||
|
||||
LinearLayout percentLayout;
|
||||
LinearLayout absoluteLayout;
|
||||
|
||||
PlusMinusEditText basalPercent;
|
||||
PlusMinusEditText basalAbsolute;
|
||||
PlusMinusEditText duration;
|
||||
NumberPicker basalPercent;
|
||||
NumberPicker basalAbsolute;
|
||||
NumberPicker duration;
|
||||
|
||||
Handler mHandler;
|
||||
public static HandlerThread mHandlerThread;
|
||||
|
@ -65,22 +66,24 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
percentRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_percent_radio);
|
||||
basalTypeRadioGroup = (RadioGroup) view.findViewById(R.id.overview_newtempbasal_radiogroup);
|
||||
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio);
|
||||
typeSelectorLayout = (RelativeLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
|
||||
typeSelectorLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
|
||||
|
||||
PumpDescription pumpDescription = MainApp.getConfigBuilder().getPumpDescription();
|
||||
|
||||
basalPercent = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalpercentinput, R.id.overview_newtempbasal_basalpercent_plus, R.id.overview_newtempbasal_basalpercent_minus,
|
||||
100d, 0d, (double) pumpDescription.maxTempPercent, (double) pumpDescription.tempPercentStep, new DecimalFormat("0"), true);
|
||||
basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
||||
double maxTempPercent = pumpDescription.maxTempPercent;
|
||||
double tempPercentStep = pumpDescription.tempPercentStep;
|
||||
basalPercent.setParams(100d, 0d, maxTempPercent, tempPercentStep, new DecimalFormat("0"), true);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Double currentBasal = profile.getBasal();
|
||||
basalAbsolute = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalabsoluteinput, R.id.overview_newtempbasal_basalabsolute_plus, R.id.overview_newtempbasal_basalabsolute_minus,
|
||||
currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
|
||||
Double currentBasal = profile != null ? profile.getBasal() : 0d;
|
||||
basalAbsolute = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
|
||||
basalAbsolute.setParams(currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
|
||||
|
||||
double tempDurationStep = MainApp.getConfigBuilder().getPumpDescription().tempDurationStep;
|
||||
double tempMaxDuration = MainApp.getConfigBuilder().getPumpDescription().tempMaxDuration;
|
||||
duration = new PlusMinusEditText(view, R.id.overview_newtempbasal_duration, R.id.overview_newtempbasal_duration_plus, R.id.overview_newtempbasal_duration_minus,
|
||||
tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false);
|
||||
double tempDurationStep = pumpDescription.tempDurationStep;
|
||||
double tempMaxDuration = pumpDescription.tempMaxDuration;
|
||||
duration = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_duration);
|
||||
duration.setParams(tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false);
|
||||
|
||||
if ((pumpDescription.tempBasalStyle & PumpDescription.PERCENT) == PumpDescription.PERCENT && (pumpDescription.tempBasalStyle & PumpDescription.ABSOLUTE) == PumpDescription.ABSOLUTE) {
|
||||
// Both allowed
|
||||
|
@ -107,13 +110,6 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
|
|
@ -19,9 +19,10 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||
|
||||
public class CareportalFragment extends Fragment implements View.OnClickListener {
|
||||
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
|
||||
static CareportalPlugin careportalPlugin;
|
||||
|
||||
|
@ -178,24 +179,13 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
|
|||
newDialog.show(manager, "NewNSTreatmentDialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventCareportalEventChange c) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
updateAge(activity, sage, iage, cage, pbage);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.Common;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
abstract public class SubscriberFragment extends Fragment {
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
protected abstract void updateGUI();
|
||||
}
|
|
@ -23,7 +23,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
|
@ -83,7 +83,6 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
MainApp.bus().register(this);
|
||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "ConfigBuilderPlugin");
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -510,8 +509,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
PumpEnactResult result = activePump.cancelTempBasal();
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
PumpEnactResult result = activePump.cancelTempBasal(userRequested);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("cancelTempBasal success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
|
@ -560,7 +559,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
if (isTempBasalInProgress()) {
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: cancelTempBasal()");
|
||||
result = cancelTempBasal();
|
||||
result = cancelTempBasal(false);
|
||||
} else {
|
||||
result = new PumpEnactResult();
|
||||
result.absolute = request.rate;
|
||||
|
@ -827,7 +826,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
|
||||
public Intervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
|
||||
return activeTreatments.getTemporaryBasalsFromHistory();
|
||||
}
|
||||
|
||||
|
@ -874,7 +873,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() {
|
||||
public Intervals<ExtendedBolus> getExtendedBolusesFromHistory() {
|
||||
return activeTreatments.getExtendedBolusesFromHistory();
|
||||
}
|
||||
|
||||
|
@ -896,7 +895,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() {
|
||||
public Intervals<TempTarget> getTempTargetsFromHistory() {
|
||||
return activeTreatments.getTempTargetsFromHistory();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public class ActivityGraph extends GraphView {
|
|||
getViewport().setMaxX(hours * 60);
|
||||
getGridLabelRenderer().setNumHorizontalLabels(hours + 1);
|
||||
getGridLabelRenderer().setHorizontalAxisTitle("[min]");
|
||||
getGridLabelRenderer().setVerticalLabelsColor(activitySeries.getColor());
|
||||
|
||||
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
|
||||
iobDataPoints = iobArray.toArray(iobDataPoints);
|
||||
|
@ -72,5 +73,6 @@ public class ActivityGraph extends GraphView {
|
|||
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
|
||||
getSecondScale().setMinY(0);
|
||||
getSecondScale().setMaxY(1);
|
||||
getGridLabelRenderer().setVerticalLabelsSecondScaleColor(Color.MAGENTA);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,22 @@ public class InsulinFastactingFragment extends Fragment {
|
|||
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
||||
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
||||
|
||||
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
|
||||
insulinComment.setText(insulinFastactingPlugin.getComment());
|
||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
|
||||
insulinGraph.show(insulinFastactingPlugin);
|
||||
updateGUI();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
private void updateGUI() {
|
||||
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
|
||||
insulinComment.setText(insulinFastactingPlugin.getComment());
|
||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
|
||||
insulinGraph.show(insulinFastactingPlugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,12 +36,22 @@ public class InsulinFastactingProlongedFragment extends Fragment {
|
|||
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
||||
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
||||
|
||||
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
|
||||
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
|
||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
|
||||
insulinGraph.show(insulinFastactingProlongedPlugin);
|
||||
updateGUI();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
private void updateGUI() {
|
||||
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
|
||||
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
|
||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
|
||||
insulinGraph.show(insulinFastactingProlongedPlugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Loop;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -19,10 +18,11 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||
|
||||
public class LoopFragment extends Fragment implements View.OnClickListener {
|
||||
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
||||
|
||||
private static LoopPlugin loopPlugin;
|
||||
|
@ -61,18 +61,6 @@ public class LoopFragment extends Fragment implements View.OnClickListener {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
@ -110,7 +98,8 @@ public class LoopFragment extends Fragment implements View.OnClickListener {
|
|||
}
|
||||
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -28,12 +28,13 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class NSClientInternalFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
||||
|
||||
static NSClientInternalPlugin nsClientInternalPlugin;
|
||||
|
@ -150,25 +151,13 @@ public class NSClientInternalFragment extends Fragment implements View.OnClickLi
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNSClientUpdateGUI ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -159,7 +159,7 @@ public class NSClientInternalPlugin implements PluginBase {
|
|||
MainApp.bus().post(new EventNSClientUpdateGUI());
|
||||
}
|
||||
|
||||
void clearLog() {
|
||||
synchronized void clearLog() {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -169,7 +169,7 @@ public class NSClientInternalPlugin implements PluginBase {
|
|||
});
|
||||
}
|
||||
|
||||
private void addToLog(final EventNSClientNewLog ev) {
|
||||
private synchronized void addToLog(final EventNSClientNewLog ev) {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -183,7 +183,7 @@ public class NSClientInternalPlugin implements PluginBase {
|
|||
});
|
||||
}
|
||||
|
||||
static void updateLog() {
|
||||
static synchronized void updateLog() {
|
||||
try {
|
||||
StringBuilder newTextLog = new StringBuilder();
|
||||
List<EventNSClientNewLog> temporaryList = new ArrayList<>(listLog);
|
||||
|
|
|
@ -4,14 +4,18 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 11.06.2017.
|
||||
|
@ -21,6 +25,7 @@ public class BroadcastAckAlarm {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
|
||||
|
||||
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("level", originalAlarm.getLevel());
|
||||
bundle.putString("group", originalAlarm.getGroup());
|
||||
|
@ -28,10 +33,18 @@ public class BroadcastAckAlarm {
|
|||
Intent intent = new Intent(Intents.ACTION_ACK_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("ACKALARM " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putInt("level", originalAlarm.getLevel());
|
||||
bundle.putString("group", originalAlarm.getGroup());
|
||||
bundle.putLong("silenceTime", silenceTimeInMsec);
|
||||
intent = new Intent(Intents.ACTION_ACK_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -25,9 +29,15 @@ public class BroadcastAlarm {
|
|||
Intent intent = new Intent(Intents.ACTION_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("ALARM " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("data", alarm.toString());
|
||||
intent = new Intent(Intents.ACTION_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -12,7 +13,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -26,9 +30,15 @@ public class BroadcastAnnouncement {
|
|||
Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("ANNOUNCEMENT " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("data", announcement.toString());
|
||||
intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -20,15 +24,23 @@ public class BroadcastCals {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastCals.class);
|
||||
|
||||
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("cals", cals.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_CAL);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("CAL " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("cals", cals.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_CAL);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -25,9 +29,15 @@ public class BroadcastClearAlarm {
|
|||
Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("CLEARALARM " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("data", clearalarm.toString());
|
||||
intent = new Intent(Intents.ACTION_CLEAR_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -12,7 +13,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
||||
public class BroadcastDeviceStatus {
|
||||
|
@ -25,12 +29,20 @@ public class BroadcastDeviceStatus {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("DEVICESTATUS " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("devicestatus", status.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
|
||||
|
||||
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
|
||||
for (JSONArray part: splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -39,10 +51,20 @@ public class BroadcastDeviceStatus {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
log.debug("DEVICESTATUS " + part.length() + " records " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
splitted = BroadcastTreatment.splitArray(statuses);
|
||||
for (JSONArray part : splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("devicestatuses", part.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -20,15 +24,23 @@ public class BroadcastMbgs {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class);
|
||||
|
||||
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mbgs", mbgs.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_MBG);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("MBG " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("mbgs", mbgs.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_MBG);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,18 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,16 +25,24 @@ public class BroadcastProfile {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class);
|
||||
|
||||
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("profile", profile.getData().toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_PROFILE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("PROFILE " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("profile", profile.getData().toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_PROFILE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,13 +5,18 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.02.2016.
|
||||
*/
|
||||
public class BroadcastQueueStatus {
|
||||
public static void handleNewStatus(int size, Context context) {
|
||||
|
||||
if(!SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) return;
|
||||
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"sendQueue");
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -12,7 +13,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 22.02.2016.
|
||||
|
@ -21,16 +25,24 @@ public class BroadcastSgvs {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class);
|
||||
|
||||
public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("sgv", sgv.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("SGV " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("sgv", sgv.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
|
||||
|
@ -40,10 +52,17 @@ public class BroadcastSgvs {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("SGV " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("sgvs", sgvs.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -12,9 +13,11 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 24.02.2016.
|
||||
|
@ -23,13 +26,14 @@ public class BroadcastStatus {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class);
|
||||
|
||||
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
try {
|
||||
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
|
||||
bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
};
|
||||
}
|
||||
bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName);
|
||||
bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode);
|
||||
bundle.putString("status", status.getData().toString());
|
||||
|
@ -37,9 +41,24 @@ public class BroadcastStatus {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_STATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("STATUS: " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
try {
|
||||
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
|
||||
bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName);
|
||||
bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode);
|
||||
bundle.putString("status", status.getData().toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_STATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.TransactionTooLargeException;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -14,8 +16,12 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
/**
|
||||
* Created by mike on 20.02.2016.
|
||||
|
@ -24,19 +30,28 @@ public class BroadcastTreatment {
|
|||
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
|
||||
|
||||
public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.getData().toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("TREAT_ADD " + treatment.getEventType() + " " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.getData().toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
||||
|
||||
List<JSONArray> splitted = splitArray(treatments);
|
||||
for (JSONArray part: splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -45,72 +60,114 @@ public class BroadcastTreatment {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)){
|
||||
splitted = splitArray(treatments);
|
||||
for (JSONArray part: splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatments", part.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
try {
|
||||
log.debug("TREAT_CHANGE " + treatment.getString("_id") + " " + x.size() + " receivers");
|
||||
} catch (JSONException e) {
|
||||
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
||||
|
||||
List<JSONArray> splitted = splitArray(treatments);
|
||||
for (JSONArray part: splitted) {
|
||||
for (JSONArray part : splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatments", part.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
log.debug("TREAT_CHANGE " + part.length() + " " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
splitted = splitArray(treatments);
|
||||
for (JSONArray part : splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatments", part.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
try {
|
||||
log.debug("TREAT_REMOVE " + treatment.getString("_id") + " " + x.size() + " receivers");
|
||||
} catch (JSONException e) {
|
||||
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatments", treatments.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("TREAT_REMOVE " + treatments.length() + " treatments " + x.size() + " receivers");
|
||||
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("treatments", treatments.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 26.06.2016.
|
||||
|
@ -25,9 +29,15 @@ public class BroadcastUrgentAlarm {
|
|||
Intent intent = new Intent(Intents.ACTION_URGENT_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
|
||||
log.debug("URGENTALARM " + x.size() + " receivers");
|
||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("data", urgentalarm.toString());
|
||||
intent = new Intent(Intents.ACTION_URGENT_ALARM);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,8 +207,6 @@ public class NSSettingsStatus {
|
|||
return ret;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private Integer getIntegerOrNull(String key) {
|
||||
Integer ret = null;
|
||||
if (data.has(key)) {
|
||||
|
@ -221,8 +219,6 @@ public class NSSettingsStatus {
|
|||
return ret;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private Long getLongOrNull(String key) {
|
||||
Long ret = null;
|
||||
if (data.has(key)) {
|
||||
|
@ -235,8 +231,6 @@ public class NSSettingsStatus {
|
|||
return ret;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private Date getDateOrNull(String key) {
|
||||
Date ret = null;
|
||||
if (data.has(key)) {
|
||||
|
@ -249,8 +243,6 @@ public class NSSettingsStatus {
|
|||
return ret;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private boolean getBooleanOrNull(String key) {
|
||||
boolean ret = false;
|
||||
if (data.has(key)) {
|
||||
|
|
|
@ -24,7 +24,7 @@ public class NSSgv {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Integer getIntegerOrNull(String key) {
|
||||
Integer ret = null;
|
||||
|
@ -36,7 +36,7 @@ public class NSSgv {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Long getLongOrNull(String key) {
|
||||
Long ret = null;
|
||||
|
@ -48,7 +48,7 @@ public class NSSgv {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
public JSONObject getData () { return data; }
|
||||
public Integer getMgdl () { return getIntegerOrNull("mgdl"); }
|
||||
|
|
|
@ -25,7 +25,7 @@ public class NSTreatment {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Double getDoubleOrNull(String key) {
|
||||
Double ret = null;
|
||||
|
@ -37,7 +37,7 @@ public class NSTreatment {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Integer getIntegerOrNull(String key) {
|
||||
Integer ret = null;
|
||||
|
@ -49,7 +49,7 @@ public class NSTreatment {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Long getLongOrNull(String key) {
|
||||
Long ret = null;
|
||||
|
@ -61,7 +61,7 @@ public class NSTreatment {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
private Date getDateOrNull(String key) {
|
||||
Date ret = null;
|
||||
|
@ -73,7 +73,7 @@ public class NSTreatment {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
public String getAction() { return action; }
|
||||
public JSONObject getData() { return data; }
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DetermineBasalResultAMA extends APSResult {
|
|||
}
|
||||
if (result.contains("duration")) {
|
||||
duration = result.getInteger("duration");
|
||||
changeRequested = changeRequested;
|
||||
//changeRequested as above
|
||||
} else {
|
||||
duration = -1;
|
||||
changeRequested = false;
|
||||
|
|
|
@ -20,11 +20,12 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.JSONFormatter;
|
||||
|
||||
public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener {
|
||||
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
|
||||
|
||||
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
|
@ -81,18 +82,6 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
updateGUI();
|
||||
|
@ -103,7 +92,8 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
|
|||
updateResultGUI(ev.text);
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DetermineBasalResultMA extends APSResult {
|
|||
}
|
||||
if (result.contains("duration")) {
|
||||
duration = result.getInteger("duration");
|
||||
changeRequested = changeRequested;
|
||||
//changeRequested as above
|
||||
} else {
|
||||
duration = -1;
|
||||
changeRequested = false;
|
||||
|
|
|
@ -18,11 +18,12 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.JSONFormatter;
|
||||
|
||||
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener {
|
||||
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
||||
|
||||
private static OpenAPSMAPlugin openAPSMAPlugin;
|
||||
|
@ -75,18 +76,6 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
updateGUI();
|
||||
|
@ -97,7 +86,8 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
|
|||
updateResultGUI(ev.text);
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
@ -123,7 +113,7 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
|
|||
});
|
||||
}
|
||||
|
||||
void updateResultGUI(final String text) {
|
||||
private void updateResultGUI(final String text) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -213,9 +213,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin);
|
||||
cobLayout = (LinearLayout) view.findViewById(R.id.treatments_wizard_cob_layout);
|
||||
cob = (TextView) view.findViewById(R.id.treatments_wizard_cob);
|
||||
;
|
||||
cobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_cobinsulin);
|
||||
;
|
||||
|
||||
bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox);
|
||||
bolusIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bolusiobcheckbox);
|
||||
|
@ -315,6 +313,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||
}
|
||||
pump.cancelTempBasal(true);
|
||||
result = pump.setTempBasalAbsolute(0d, 120);
|
||||
if (!result.success) {
|
||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror), result.comment, null);
|
||||
|
|
|
@ -175,7 +175,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
LinearLayoutManager llm;
|
||||
|
||||
LinearLayout acceptTempLayout;
|
||||
Button cancelTempButton;
|
||||
Button treatmentButton;
|
||||
Button wizardButton;
|
||||
Button calibrationButton;
|
||||
|
@ -269,9 +268,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||
|
||||
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton);
|
||||
if (cancelTempButton != null)
|
||||
cancelTempButton.setOnClickListener(this);
|
||||
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
||||
treatmentButton.setOnClickListener(this);
|
||||
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
||||
|
@ -415,7 +411,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -436,7 +432,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -450,7 +446,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -464,7 +460,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -478,7 +474,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -492,7 +488,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -506,6 +502,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
|
@ -520,6 +517,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
|
@ -534,6 +532,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
|
@ -548,6 +547,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
|
@ -583,18 +583,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
|
||||
treatmentDialogFragment.show(manager, "TreatmentDialog");
|
||||
break;
|
||||
case R.id.overview_canceltempbutton:
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pump.cancelTempBasal();
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case R.id.overview_pumpstatus:
|
||||
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
|
||||
sHandler.post(new Runnable() {
|
||||
|
@ -1010,15 +998,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (cancelTempButton != null) {
|
||||
if (activeTemp != null) {
|
||||
cancelTempButton.setVisibility(View.VISIBLE);
|
||||
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
|
||||
} else {
|
||||
cancelTempButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
String basalText = "";
|
||||
if (shorttextmode) {
|
||||
if (activeTemp != null) {
|
||||
|
@ -1047,6 +1026,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
|
||||
}
|
||||
}
|
||||
if (activeTemp != null) {
|
||||
baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal));
|
||||
} else {
|
||||
baseBasalView.setTextColor(Color.WHITE);
|
||||
|
||||
}
|
||||
|
||||
baseBasalView.setText(basalText);
|
||||
|
||||
final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
|
|
|
@ -39,10 +39,11 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
public class CircadianPercentageProfileFragment extends Fragment {
|
||||
public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class);
|
||||
|
||||
private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin();
|
||||
|
@ -309,16 +310,14 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
percentageView.addTextChangedListener(textWatch);
|
||||
timeshiftView.addTextChangedListener(textWatch);
|
||||
|
||||
updateGui();
|
||||
updateGUI();
|
||||
|
||||
onStatusEvent(new EventInitializationChanged());
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void updateGui() {
|
||||
|
||||
|
||||
public void updateGUI() {
|
||||
updateProfileInfo();
|
||||
|
||||
diaView.removeTextChangedListener(textWatch);
|
||||
|
@ -434,7 +433,6 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
|
||||
if (i == 0) {
|
||||
copyprevbutton.setVisibility(View.INVISIBLE);
|
||||
;
|
||||
} else {
|
||||
final int j = i; //needs to be final to be passed to inner class.
|
||||
copyprevbutton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -485,15 +483,12 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
}
|
||||
basalEditDialog = null;
|
||||
|
||||
MainApp.bus().unregister(this);
|
||||
fl.requestFocusFromTouch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateGui();
|
||||
MainApp.bus().register(this);
|
||||
onStatusEvent(new EventInitializationChanged());
|
||||
fl.requestFocusFromTouch();
|
||||
}
|
||||
|
@ -521,7 +516,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateGui();
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,10 +27,11 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.TimeListEdit;
|
||||
|
||||
public class LocalProfileFragment extends Fragment {
|
||||
public class LocalProfileFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
|
||||
|
||||
private static LocalProfilePlugin localProfilePlugin = new LocalProfilePlugin();
|
||||
|
@ -73,7 +74,7 @@ public class LocalProfileFragment extends Fragment {
|
|||
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
onStatusEvent(null);
|
||||
updateGUI();
|
||||
|
||||
mgdlView.setChecked(localProfilePlugin.mgdl);
|
||||
mmolView.setChecked(localProfilePlugin.mmol);
|
||||
|
@ -130,26 +131,18 @@ public class LocalProfileFragment extends Fragment {
|
|||
|
||||
diaView.addTextChangedListener(textWatch);
|
||||
|
||||
onStatusEvent(null);
|
||||
updateGUI();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
onStatusEvent(null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged e) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -13,10 +13,11 @@ import com.squareup.otto.Subscribe;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
public class NSProfileFragment extends Fragment {
|
||||
public class NSProfileFragment extends SubscriberFragment {
|
||||
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
|
||||
|
||||
public static NSProfilePlugin getPlugin() {
|
||||
|
@ -50,18 +51,6 @@ public class NSProfileFragment extends Fragment {
|
|||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
|
||||
Activity activity = getActivity();
|
||||
|
@ -74,7 +63,8 @@ public class NSProfileFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
if (MainApp.getConfigBuilder().getProfile() == null) {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
|
|
|
@ -25,9 +25,10 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
public class SimpleProfileFragment extends Fragment {
|
||||
public class SimpleProfileFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
|
||||
|
||||
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();
|
||||
|
@ -66,7 +67,7 @@ public class SimpleProfileFragment extends Fragment {
|
|||
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
onStatusEvent(null);
|
||||
updateGUI();
|
||||
|
||||
mgdlView.setChecked(simpleProfilePlugin.mgdl);
|
||||
mmolView.setChecked(simpleProfilePlugin.mmol);
|
||||
|
@ -138,26 +139,18 @@ public class SimpleProfileFragment extends Fragment {
|
|||
targetlowView.addTextChangedListener(textWatch);
|
||||
targethighView.addTextChangedListener(textWatch);
|
||||
|
||||
onStatusEvent(null);
|
||||
updateGUI();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
onStatusEvent(null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged e) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRStatsActivity;
|
||||
|
@ -35,7 +36,7 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SetWarnColor;
|
||||
|
||||
public class DanaRFragment extends Fragment {
|
||||
public class DanaRFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
|
||||
|
||||
private static DanaRPlugin danaRPlugin;
|
||||
|
@ -156,18 +157,6 @@ public class DanaRFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
Activity activity = getActivity();
|
||||
|
@ -204,7 +193,8 @@ public class DanaRFragment extends Fragment {
|
|||
}
|
||||
|
||||
// GUI functions
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -566,7 +566,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
||||
return cancelRealTempBasal();
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||
|
@ -36,7 +37,7 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SetWarnColor;
|
||||
|
||||
public class DanaRKoreanFragment extends Fragment {
|
||||
public class DanaRKoreanFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(DanaRKoreanFragment.class);
|
||||
|
||||
private static DanaRKoreanPlugin danaRKoreanPlugin = new DanaRKoreanPlugin();
|
||||
|
@ -154,18 +155,6 @@ public class DanaRKoreanFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
Activity activity = getActivity();
|
||||
|
@ -202,7 +191,8 @@ public class DanaRKoreanFragment extends Fragment {
|
|||
}
|
||||
|
||||
// GUI functions
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
|
|
|
@ -570,7 +570,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
||||
return cancelRealTempBasal();
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||
|
@ -36,7 +37,7 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SetWarnColor;
|
||||
|
||||
public class DanaRv2Fragment extends Fragment {
|
||||
public class DanaRv2Fragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(DanaRv2Fragment.class);
|
||||
|
||||
private static DanaRv2Plugin danaRPlugin;
|
||||
|
@ -153,18 +154,6 @@ public class DanaRv2Fragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
Activity activity = getActivity();
|
||||
|
@ -201,7 +190,8 @@ public class DanaRv2Fragment extends Fragment {
|
|||
}
|
||||
|
||||
// GUI functions
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -340,7 +340,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
if (Config.logPumpActions)
|
||||
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
||||
return cancelTempBasal();
|
||||
return cancelTempBasal(false);
|
||||
}
|
||||
result.success = true;
|
||||
result.enacted = false;
|
||||
|
@ -507,7 +507,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
if (pump.isTempBasalInProgress) {
|
||||
sExecutionService.tempBasalStop();
|
||||
|
|
|
@ -196,7 +196,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Activity;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -16,13 +15,12 @@ import com.squareup.otto.Subscribe;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||
|
||||
public class VirtualPumpFragment extends Fragment {
|
||||
public class VirtualPumpFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class);
|
||||
|
||||
TextView basaBasalRateView;
|
||||
|
@ -59,35 +57,23 @@ public class VirtualPumpFragment extends Fragment {
|
|||
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
|
||||
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventVirtualPumpUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U");
|
||||
VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getInstance();
|
||||
basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
|
@ -98,8 +84,8 @@ public class VirtualPumpFragment extends Fragment {
|
|||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
batteryView.setText(VirtualPumpPlugin.getInstance().batteryPercent + "%");
|
||||
reservoirView.setText(VirtualPumpPlugin.getInstance().reservoirInUnits + "U");
|
||||
batteryView.setText(virtualPump.batteryPercent + "%");
|
||||
reservoirView.setText(virtualPump.reservoirInUnits + "U");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -204,7 +204,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public double getBaseBasalRate() {
|
||||
return MainApp.getConfigBuilder().getProfile().getBasal();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (profile != null)
|
||||
return profile.getBasal();
|
||||
else
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -282,7 +286,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
result = cancelTempBasal();
|
||||
result = cancelTempBasal(false);
|
||||
if (!result.success)
|
||||
return result;
|
||||
}
|
||||
|
@ -333,7 +337,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
public PumpEnactResult cancelTempBasal(boolean userRequested) {
|
||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
|
|
|
@ -20,13 +20,14 @@ import java.util.Comparator;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class SmsCommunicatorFragment extends Fragment {
|
||||
public class SmsCommunicatorFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorFragment.class);
|
||||
|
||||
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
|
@ -56,25 +57,14 @@ public class SmsCommunicatorFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventSmsCommunicatorUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
private void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -272,7 +272,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " +
|
||||
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
|
||||
|
@ -506,7 +506,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||
if (pumpInterface != null) {
|
||||
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpEnactResult result = pumpInterface.cancelTempBasal();
|
||||
PumpEnactResult result = pumpInterface.cancelTempBasal(true);
|
||||
if (result.success) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
||||
if (danaRPlugin != null)
|
||||
|
@ -535,7 +535,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
suspendWaitingForConfirmation.processed = true;
|
||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
|
@ -19,6 +18,8 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.data.NonOverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||
|
@ -48,9 +49,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
public static IobTotal lastTempBasalsCalculation;
|
||||
|
||||
public static List<Treatment> treatments;
|
||||
private static OverlappingIntervals<TemporaryBasal> tempBasals = new OverlappingIntervals<>();
|
||||
private static OverlappingIntervals<ExtendedBolus> extendedBoluses = new OverlappingIntervals<>();
|
||||
private static OverlappingIntervals<TempTarget> tempTargets = new OverlappingIntervals<>();
|
||||
private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<TemporaryBasal>();
|
||||
private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<ExtendedBolus>();
|
||||
private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<TempTarget>();
|
||||
private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
||||
|
||||
private static boolean fragmentEnabled = true;
|
||||
|
@ -187,11 +188,13 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
ExtendedBolus e = extendedBoluses.get(pos);
|
||||
if (e.date > time) continue;
|
||||
IobTotal calc = e.iobCalc(time);
|
||||
total.plus(calc);
|
||||
synchronized (extendedBoluses) {
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
ExtendedBolus e = extendedBoluses.get(pos);
|
||||
if (e.date > time) continue;
|
||||
IobTotal calc = e.iobCalc(time);
|
||||
total.plus(calc);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
@ -291,20 +294,24 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
@Override
|
||||
public IobTotal getCalculationToTimeTempBasals(long time) {
|
||||
IobTotal total = new IobTotal(time);
|
||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||
TemporaryBasal t = tempBasals.get(pos);
|
||||
if (t.date > time) continue;
|
||||
IobTotal calc = t.iobCalc(time);
|
||||
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
||||
total.plus(calc);
|
||||
synchronized (tempBasals) {
|
||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||
TemporaryBasal t = tempBasals.get(pos);
|
||||
if (t.date > time) continue;
|
||||
IobTotal calc = t.iobCalc(time);
|
||||
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
||||
total.plus(calc);
|
||||
}
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
IobTotal totalExt = new IobTotal(time);
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
ExtendedBolus e = extendedBoluses.get(pos);
|
||||
if (e.date > time) continue;
|
||||
IobTotal calc = e.iobCalc(time);
|
||||
totalExt.plus(calc);
|
||||
synchronized (extendedBoluses) {
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
ExtendedBolus e = extendedBoluses.get(pos);
|
||||
if (e.date > time) continue;
|
||||
IobTotal calc = e.iobCalc(time);
|
||||
totalExt.plus(calc);
|
||||
}
|
||||
}
|
||||
// Convert to basal iob
|
||||
totalExt.basaliob = totalExt.iob;
|
||||
|
@ -347,7 +354,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() {
|
||||
public Intervals<ExtendedBolus> getExtendedBolusesFromHistory() {
|
||||
return extendedBoluses;
|
||||
}
|
||||
|
||||
|
@ -380,7 +387,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
|
||||
public Intervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
|
||||
return tempBasals;
|
||||
}
|
||||
|
||||
|
@ -419,12 +426,18 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
@Override
|
||||
public long oldestDataAvailable() {
|
||||
long oldestTime = System.currentTimeMillis();
|
||||
if (tempBasals.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, tempBasals.get(0).date);
|
||||
if (extendedBoluses.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, extendedBoluses.get(0).date);
|
||||
if (treatments.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, treatments.get(treatments.size() - 1).date);
|
||||
synchronized (tempBasals) {
|
||||
if (tempBasals.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, tempBasals.get(0).date);
|
||||
}
|
||||
synchronized (extendedBoluses) {
|
||||
if (extendedBoluses.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, extendedBoluses.get(0).date);
|
||||
}
|
||||
synchronized (treatments) {
|
||||
if (treatments.size() > 0)
|
||||
oldestTime = Math.min(oldestTime, treatments.get(treatments.size() - 1).date);
|
||||
}
|
||||
oldestTime -= 15 * 60 * 1000L; // allow 15 min before
|
||||
return oldestTime;
|
||||
}
|
||||
|
@ -442,7 +455,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() {
|
||||
public Intervals<TempTarget> getTempTargetsFromHistory() {
|
||||
return tempTargets;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,14 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
|
||||
public class TreatmentsBolusFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class);
|
||||
|
||||
RecyclerView recyclerView;
|
||||
|
@ -205,19 +206,6 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||
updateGUI();
|
||||
|
@ -228,7 +216,8 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
|||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -23,8 +23,6 @@ import com.squareup.otto.Subscribe;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
|
@ -32,13 +30,14 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
|
||||
|
||||
public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsExtendedBolusesFragment.class);
|
||||
|
||||
RecyclerView recyclerView;
|
||||
|
@ -48,9 +47,9 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
|||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ExtendedBolusesViewHolder> {
|
||||
|
||||
OverlappingIntervals<ExtendedBolus> extendedBolusList;
|
||||
Intervals<ExtendedBolus> extendedBolusList;
|
||||
|
||||
RecyclerViewAdapter(OverlappingIntervals<ExtendedBolus> extendedBolusList) {
|
||||
RecyclerViewAdapter(Intervals<ExtendedBolus> extendedBolusList) {
|
||||
this.extendedBolusList = extendedBolusList;
|
||||
}
|
||||
|
||||
|
@ -183,18 +182,6 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||
updateGUI();
|
||||
|
@ -205,7 +192,8 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
|||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && recyclerView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.db.Source;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
|
@ -40,7 +41,7 @@ import info.nightscout.utils.SP;
|
|||
* Created by mike on 13/01/17.
|
||||
*/
|
||||
|
||||
public class TreatmentsProfileSwitchFragment extends Fragment implements View.OnClickListener {
|
||||
public class TreatmentsProfileSwitchFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
@ -180,24 +181,13 @@ public class TreatmentsProfileSwitchFragment extends Fragment implements View.On
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventProfileSwitchChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -26,18 +26,18 @@ import info.nightscout.androidaps.Services.Intents;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 13/01/17.
|
||||
*/
|
||||
|
||||
public class TreatmentsTempTargetFragment extends Fragment implements View.OnClickListener {
|
||||
public class TreatmentsTempTargetFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
@ -47,10 +47,12 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
|||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> {
|
||||
|
||||
OverlappingIntervals<TempTarget> tempTargetList;
|
||||
Intervals<TempTarget> tempTargetList;
|
||||
TempTarget currentlyActiveTarget;
|
||||
|
||||
RecyclerViewAdapter(OverlappingIntervals<TempTarget> TempTargetList) {
|
||||
RecyclerViewAdapter(Intervals<TempTarget> TempTargetList) {
|
||||
this.tempTargetList = TempTargetList;
|
||||
currentlyActiveTarget = tempTargetList.getValueByInterval(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,10 +83,18 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
|||
holder.reasonLabel.setText("");
|
||||
holder.reasonColon.setText("");
|
||||
}
|
||||
if (tempTarget.isInProgress())
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||
else
|
||||
if (tempTarget.isInProgress()) {
|
||||
if(tempTarget == currentlyActiveTarget){
|
||||
// active as newest
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
|
||||
} else {
|
||||
// other's that might become active again after the latest (overlapping) is over
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||
}
|
||||
}
|
||||
else {
|
||||
holder.date.setTextColor(holder.reasonColon.getCurrentTextColor());
|
||||
}
|
||||
holder.remove.setTag(tempTarget);
|
||||
}
|
||||
|
||||
|
@ -201,24 +211,13 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -23,8 +23,6 @@ import com.squareup.otto.Subscribe;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
|
@ -32,13 +30,14 @@ import info.nightscout.androidaps.db.Source;
|
|||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
|
||||
|
||||
public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsTemporaryBasalsFragment.class);
|
||||
|
||||
RecyclerView recyclerView;
|
||||
|
@ -50,9 +49,9 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
|||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> {
|
||||
|
||||
OverlappingIntervals<TemporaryBasal> tempBasalList;
|
||||
Intervals<TemporaryBasal> tempBasalList;
|
||||
|
||||
RecyclerViewAdapter(OverlappingIntervals<TemporaryBasal> tempBasalList) {
|
||||
RecyclerViewAdapter(Intervals<TemporaryBasal> tempBasalList) {
|
||||
this.tempBasalList = tempBasalList;
|
||||
}
|
||||
|
||||
|
@ -202,18 +201,6 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||
updateGUI();
|
||||
|
@ -224,7 +211,8 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
|||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -4,8 +4,14 @@ import android.os.Handler;
|
|||
import android.os.HandlerThread;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
|
@ -15,17 +21,25 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.utils.BolusWizard;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -157,14 +171,9 @@ public class ActionStringHandler {
|
|||
rMessage = getPumpStatus();
|
||||
} else if ("loop".equals(act[1])) {
|
||||
rTitle += " LOOP";
|
||||
rMessage = getLoopStatus();
|
||||
|
||||
} else if ("targets".equals(act[1])) {
|
||||
rTitle += " TARGETS";
|
||||
rMessage = getTargetsStatus();
|
||||
} else if ("oapsresult".equals(act[1])) {
|
||||
rTitle += " OAPS RESULT";
|
||||
rMessage = getOAPSResultStatus();
|
||||
rMessage = "TARGETS:\n" + getTargetsStatus();
|
||||
rMessage += "\n\n" + getLoopStatus();
|
||||
rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();
|
||||
}
|
||||
|
||||
} else if ("wizard".equals(act[0])) {
|
||||
|
@ -180,6 +189,7 @@ public class ActionStringHandler {
|
|||
boolean useBG = Boolean.parseBoolean(act[2]);
|
||||
boolean useBolusIOB = Boolean.parseBoolean(act[3]);
|
||||
boolean useBasalIOB = Boolean.parseBoolean(act[4]);
|
||||
int percentage = Integer.parseInt(act[5]);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (profile == null) {
|
||||
|
@ -194,7 +204,7 @@ public class ActionStringHandler {
|
|||
}
|
||||
DecimalFormat format = new DecimalFormat("0.00");
|
||||
BolusWizard bolusWizard = new BolusWizard();
|
||||
bolusWizard.doCalc(profile, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, useBolusIOB, useBasalIOB, false, false);
|
||||
bolusWizard.doCalc(profile, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false);
|
||||
|
||||
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin);
|
||||
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
|
||||
|
@ -224,6 +234,9 @@ public class ActionStringHandler {
|
|||
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
|
||||
if (useBasalIOB)
|
||||
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
|
||||
if(percentage != 100){
|
||||
rMessage += "\nPercentage: " +format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
||||
}
|
||||
|
||||
lastBolusWizard = bolusWizard;
|
||||
|
||||
|
@ -256,6 +269,58 @@ public class ActionStringHandler {
|
|||
rAction = actionstring;
|
||||
}
|
||||
|
||||
} else if("tddstats".equals(act[0])){
|
||||
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface dana = (PumpInterface) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpInterface danaV2 = (PumpInterface) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = (PumpInterface) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
|
||||
|
||||
if((dana == null || dana != activePump) &&
|
||||
(danaV2 == null || danaV2 != activePump) &&
|
||||
(danaKorean == null || danaKorean != activePump)
|
||||
){
|
||||
sendError("Pump does not support TDDs!");
|
||||
return;
|
||||
} else {
|
||||
// check if DB up to date
|
||||
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||
|
||||
if(isOldData(historyList)){
|
||||
rTitle = "TDD";
|
||||
rAction = "statusmessage";
|
||||
rMessage = "OLD DATA - ";
|
||||
|
||||
//if pump is not busy: try to fetch data
|
||||
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (pump.isBusy()) {
|
||||
rMessage += MainApp.instance().getString(R.string.pumpbusy);
|
||||
} else {
|
||||
rMessage += "trying to fetch data from pump.";
|
||||
Handler handler = new Handler(handlerThread.getLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((DanaRInterface)pump).loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||
if(isOldData(historyList)){
|
||||
sendStatusmessage("TDD", "TDD: Still old data! Cannot load from pump.");
|
||||
} else {
|
||||
sendStatusmessage("TDD", generateTDDMessage(historyList, dummies));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// if up to date: prepare, send (check if CPP is activated -> add CPP stats)
|
||||
rTitle = "TDD";
|
||||
rAction = "statusmessage";
|
||||
rMessage = generateTDDMessage(historyList, dummies);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else return;
|
||||
|
||||
|
@ -266,6 +331,98 @@ public class ActionStringHandler {
|
|||
lastConfirmActionString = rAction;
|
||||
}
|
||||
|
||||
private static String generateTDDMessage(List<DanaRHistoryRecord> historyList, List<DanaRHistoryRecord> dummies) {
|
||||
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
String message = "";
|
||||
|
||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||
boolean isCPP = (cpp!= null && cpp.isEnabled(PluginBase.PROFILE));
|
||||
double refTDD = 100;
|
||||
if(isCPP) refTDD = cpp.baseBasalSum()*2;
|
||||
|
||||
int i = 0;
|
||||
double sum = 0d;
|
||||
double weighted03 = 0d;
|
||||
double weighted05 = 0d;
|
||||
double weighted07 = 0d;
|
||||
|
||||
Collections.reverse(historyList);
|
||||
for (DanaRHistoryRecord record : historyList) {
|
||||
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||
if (i == 0) {
|
||||
weighted03 = tdd;
|
||||
weighted05 = tdd;
|
||||
weighted07 = tdd;
|
||||
|
||||
} else {
|
||||
weighted07 = (weighted07 * 0.3 + tdd * 0.7);
|
||||
weighted05 = (weighted05 * 0.5 + tdd * 0.5);
|
||||
weighted03 = (weighted03 * 0.7 + tdd * 0.3);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
message += "weighted:\n";
|
||||
message += "0.3: " + DecimalFormatter.to2Decimal(weighted03) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted03/refTDD) + "%"):"") + "\n";
|
||||
message += "0.5: " + DecimalFormatter.to2Decimal(weighted05) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted05/refTDD) + "%"):"") + "\n";
|
||||
message += "0.7: " + DecimalFormatter.to2Decimal(weighted07) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted07/refTDD) + "%"):"") + "\n";
|
||||
message += "\n";
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (pump != null && pump instanceof DanaRPlugin) {
|
||||
double tdd = DanaRPump.getInstance().dailyTotalUnits;
|
||||
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%"):"") + "\n";
|
||||
message += "\n";
|
||||
}
|
||||
|
||||
//add TDDs:
|
||||
Collections.reverse(historyList);
|
||||
for (DanaRHistoryRecord record : historyList) {
|
||||
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||
message += df.format(new Date(record.recordDate)) + " " + DecimalFormatter.to2Decimal(tdd) +"U " + (isCPP?(DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%"):"") + (dummies.contains(record)?"x":"") +"\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static boolean isOldData(List<DanaRHistoryRecord> historyList) {
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).recordDate)).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24)))));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static List<DanaRHistoryRecord> getTDDList(List<DanaRHistoryRecord> returnDummies) {
|
||||
List<DanaRHistoryRecord> historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(RecordTypes.RECORD_TYPE_DAILY);
|
||||
|
||||
//only use newest 10
|
||||
historyList = historyList.subList(0, Math.min(10, historyList.size()));
|
||||
|
||||
//fill single gaps
|
||||
List<DanaRHistoryRecord> dummies = (returnDummies!=null)?returnDummies:(new LinkedList());
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
for(int i = 0; i < historyList.size()-1; i++){
|
||||
DanaRHistoryRecord elem1 = historyList.get(i);
|
||||
DanaRHistoryRecord elem2 = historyList.get(i+1);
|
||||
|
||||
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25*60*60*1000)))){
|
||||
DanaRHistoryRecord dummy = new DanaRHistoryRecord();
|
||||
dummy.recordDate = elem1.recordDate - 24*60*60*1000;
|
||||
dummy.recordDailyBasal = elem1.recordDailyBasal/2;
|
||||
dummy.recordDailyBolus = elem1.recordDailyBolus/2;
|
||||
dummies.add(dummy);
|
||||
elem1.recordDailyBasal /= 2;
|
||||
elem1.recordDailyBolus /= 2;
|
||||
}
|
||||
}
|
||||
historyList.addAll(dummies);
|
||||
Collections.sort(historyList, new Comparator<DanaRHistoryRecord>() {
|
||||
@Override
|
||||
public int compare(DanaRHistoryRecord lhs, DanaRHistoryRecord rhs) {
|
||||
return (int) (rhs.recordDate-lhs.recordDate);
|
||||
}
|
||||
});
|
||||
return historyList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static String getPumpStatus() {
|
||||
return MainApp.getConfigBuilder().shortStatus(false);
|
||||
|
@ -497,6 +654,13 @@ public class ActionStringHandler {
|
|||
lastBolusWizard = null;
|
||||
}
|
||||
|
||||
private synchronized static void sendStatusmessage(String title, String message) {
|
||||
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(title, message, "statusmessage");
|
||||
lastSentTimestamp = System.currentTimeMillis();
|
||||
lastConfirmActionString = null;
|
||||
lastBolusWizard = null;
|
||||
}
|
||||
|
||||
public synchronized static void expectNotificationAction(String message, int id) {
|
||||
String actionstring = "dismissoverviewnotification " + id;
|
||||
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring);
|
||||
|
|
|
@ -47,9 +47,14 @@ public class BolusWizard {
|
|||
|
||||
// Result
|
||||
public Double calculatedTotalInsulin = 0d;
|
||||
public Double totalBeforePercentageAdjustment = 0d;
|
||||
public Double carbsEquivalent = 0d;
|
||||
|
||||
public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
|
||||
return doCalc(specificProfile, carbs, cob, bg, correction, 100d, includeBolusIOB, includeBasalIOB, superBolus, trend);
|
||||
}
|
||||
|
||||
public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, double percentageCorrection, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
|
||||
this.specificProfile = specificProfile;
|
||||
this.carbs = carbs;
|
||||
this.bg = bg;
|
||||
|
@ -103,7 +108,13 @@ public class BolusWizard {
|
|||
}
|
||||
|
||||
// Total
|
||||
calculatedTotalInsulin = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB;
|
||||
calculatedTotalInsulin = totalBeforePercentageAdjustment = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB;
|
||||
|
||||
//percentage
|
||||
if(totalBeforePercentageAdjustment > 0){
|
||||
calculatedTotalInsulin = totalBeforePercentageAdjustment*percentageCorrection/100d;
|
||||
}
|
||||
|
||||
|
||||
if (calculatedTotalInsulin < 0) {
|
||||
carbsEquivalent = -calculatedTotalInsulin * ic;
|
||||
|
|
|
@ -49,7 +49,6 @@ public class NSUpload {
|
|||
data.put("pumpId", temporaryBasal.pumpId);
|
||||
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
||||
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
|
||||
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + temporaryBasal.absoluteRate + "u/h " + temporaryBasal.durationInMinutes + " min"); // ECOR
|
||||
if (originalExtendedAmount != null)
|
||||
data.put("originalExtendedAmount", originalExtendedAmount); // for back synchronization
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -88,7 +87,6 @@ public class NSUpload {
|
|||
data.put("pumpId", temporaryBasal.pumpId);
|
||||
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
||||
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
|
||||
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + temporaryBasal.percentRate + "% " + temporaryBasal.durationInMinutes + " min"); // ECOR
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("action", "dbAdd");
|
||||
bundle.putString("collection", "treatments");
|
||||
|
@ -111,7 +109,6 @@ public class NSUpload {
|
|||
data.put("eventType", CareportalEvent.TEMPBASAL);
|
||||
data.put("created_at", DateUtil.toISOString(time));
|
||||
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
|
||||
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalendnote)); // ECOR
|
||||
if (isFakedTempBasal)
|
||||
data.put("isFakedTempBasal", isFakedTempBasal);
|
||||
if (pumpId != 0)
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/icon_actions_cancelextbolus.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_actions_profileswitch.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_actions_refill.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_actions_startextbolus.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_actions_starttempbasal.png
Normal file
After Width: | Height: | Size: 745 B |
BIN
app/src/main/res/drawable-hdpi/icon_actions_temptarget.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_aaps_offline.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_age_battery.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_age_canula.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_age_insulin.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_age_sensor.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_announcement.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_basal_end.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_basal_start.png
Normal file
After Width: | Height: | Size: 698 B |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bgcheck.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_carbs.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_combo.png
Normal file
After Width: | Height: | Size: 771 B |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_correction.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_meal.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_snack.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_cgm_insert.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_cgm_profile.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_cgm_start.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_cgm_target.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_exercise.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_note.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_pump_battery.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_pump_canula.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_pump_cartridge.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_cp_question.png
Normal file
After Width: | Height: | Size: 1.2 KiB |