Merge branch 'dev' into on-resume-update-gui

This commit is contained in:
AdrianLxM 2017-07-20 00:17:32 +02:00 committed by GitHub
commit 03ad898562
37 changed files with 1075 additions and 818 deletions

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -1,99 +1,43 @@
package info.nightscout.androidaps.data; package info.nightscout.androidaps.data;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import java.util.ArrayList; import android.support.annotation.Nullable;
import java.util.List;
import info.nightscout.androidaps.interfaces.Interval; 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 for (int index = rawData.size()-1; index > 0; index--) { //begin with newest
Interval cur = rawData.valueAt(index);
public OverlappingIntervals reset() { if (cur.isEndingEvent()){
rawData = new LongSparseArray<>(); needToCut = true;
return this; cutTime = cur.start();
} } else {
//event that is no EndingEvent might need to be stopped by an ending event
public void add(T newInterval) { if(needToCut&&cur.end() > cutTime){
rawData.put(newInterval.start(), newInterval); cur.cutEndTo(cutTime);
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);
} }
} }
} }
@Nullable @Nullable
public Interval getValueByInterval(long time) { public synchronized T getValueByInterval(long time) {
int index = binarySearch(time); for (int index = rawData.size()-1; index > 0; index--) { //begin with newest
if (index >= 0) return rawData.valueAt(index); T cur = rawData.valueAt(index);
if (cur.match(time)){
return cur;
}
}
return null; 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);
}
}

View file

@ -19,24 +19,24 @@ public class ProfileIntervals<T extends Interval> {
private LongSparseArray<T> rawData = new LongSparseArray<>(); // oldest at index 0 private LongSparseArray<T> rawData = new LongSparseArray<>(); // oldest at index 0
public ProfileIntervals reset() { public synchronized ProfileIntervals reset() {
rawData = new LongSparseArray<>(); rawData = new LongSparseArray<>();
return this; return this;
} }
public void add(T newInterval) { public synchronized void add(T newInterval) {
rawData.put(newInterval.start(), newInterval); rawData.put(newInterval.start(), newInterval);
merge(); merge();
} }
public void add(List<T> list) { public synchronized void add(List<T> list) {
for (T interval : list) { for (T interval : list) {
rawData.put(interval.start(), interval); rawData.put(interval.start(), interval);
} }
merge(); merge();
} }
private void merge() { private synchronized void merge() {
for (int index = 0; index < rawData.size() - 1; index++) { for (int index = 0; index < rawData.size() - 1; index++) {
Interval i = rawData.valueAt(index); Interval i = rawData.valueAt(index);
long startOfNewer = rawData.valueAt(index + 1).start(); long startOfNewer = rawData.valueAt(index + 1).start();
@ -47,27 +47,27 @@ public class ProfileIntervals<T extends Interval> {
} }
@Nullable @Nullable
public Interval getValueToTime(long time) { public synchronized Interval getValueToTime(long time) {
int index = binarySearch(time); int index = binarySearch(time);
if (index >= 0) return rawData.valueAt(index); if (index >= 0) return rawData.valueAt(index);
return null; return null;
} }
public List<T> getList() { public synchronized List<T> getList() {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
for (int i = 0; i < rawData.size(); i++) for (int i = 0; i < rawData.size(); i++)
list.add(rawData.valueAt(i)); list.add(rawData.valueAt(i));
return list; return list;
} }
public List<T> getReversedList() { public synchronized List<T> getReversedList() {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
for (int i = rawData.size() -1; i>=0; i--) for (int i = rawData.size() -1; i>=0; i--)
list.add(rawData.valueAt(i)); list.add(rawData.valueAt(i));
return list; return list;
} }
private int binarySearch(long value) { private synchronized int binarySearch(long value) {
if (rawData.size() == 0) if (rawData.size() == 0)
return -1; return -1;
int lo = 0; int lo = 0;
@ -95,15 +95,15 @@ public class ProfileIntervals<T extends Interval> {
return -1; // value not present return -1; // value not present
} }
public int size() { public synchronized int size() {
return rawData.size(); return rawData.size();
} }
public T get(int index) { public synchronized T get(int index) {
return rawData.valueAt(index); return rawData.valueAt(index);
} }
public T getReversed(int index) { public synchronized T getReversed(int index) {
return rawData.valueAt(size() - 1 - index); return rawData.valueAt(size() - 1 - index);
} }
} }

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Intervals;
import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.data.ProfileIntervals;
/** /**
@ -42,18 +42,18 @@ public interface TreatmentsInterface {
TemporaryBasal getTempBasalFromHistory(long time); TemporaryBasal getTempBasalFromHistory(long time);
double getTempBasalAbsoluteRateHistory(); double getTempBasalAbsoluteRateHistory();
double getTempBasalRemainingMinutesFromHistory(); double getTempBasalRemainingMinutesFromHistory();
OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory(); Intervals<TemporaryBasal> getTemporaryBasalsFromHistory();
boolean isInHistoryExtendedBoluslInProgress(); boolean isInHistoryExtendedBoluslInProgress();
ExtendedBolus getExtendedBolusFromHistory(long time); ExtendedBolus getExtendedBolusFromHistory(long time);
OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory(); Intervals<ExtendedBolus> getExtendedBolusesFromHistory();
boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus); boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus);
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo); boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo);
TempTarget getTempTargetFromHistory(long time); TempTarget getTempTargetFromHistory(long time);
OverlappingIntervals<TempTarget> getTempTargetsFromHistory(); Intervals<TempTarget> getTempTargetsFromHistory();
ProfileSwitch getProfileSwitchFromHistory(long time); ProfileSwitch getProfileSwitchFromHistory(long time);
ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory(); ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory();

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; 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.Profile;
import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
@ -827,7 +827,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
@Override @Override
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() { public Intervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
return activeTreatments.getTemporaryBasalsFromHistory(); return activeTreatments.getTemporaryBasalsFromHistory();
} }
@ -874,7 +874,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
@Override @Override
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() { public Intervals<ExtendedBolus> getExtendedBolusesFromHistory() {
return activeTreatments.getExtendedBolusesFromHistory(); return activeTreatments.getExtendedBolusesFromHistory();
} }
@ -896,7 +896,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
@Override @Override
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() { public Intervals<TempTarget> getTempTargetsFromHistory() {
return activeTreatments.getTempTargetsFromHistory(); return activeTreatments.getTempTargetsFromHistory();
} }

View file

@ -12,6 +12,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 11.06.2017. * Created by mike on 11.06.2017.
@ -21,6 +22,7 @@ public class BroadcastAckAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) { public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt("level", originalAlarm.getLevel()); bundle.putInt("level", originalAlarm.getLevel());
bundle.putString("group", originalAlarm.getGroup()); bundle.putString("group", originalAlarm.getGroup());
@ -29,9 +31,6 @@ public class BroadcastAckAlarm {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("ACKALARM " + x.size() + " receivers");
} }
} }

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -20,14 +21,14 @@ public class BroadcastAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class);
public static void handleAlarm(JSONObject alarm, Context context) { public static void handleAlarm(JSONObject alarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", alarm.toString()); bundle.putString("data", alarm.toString());
Intent intent = new Intent(Intents.ACTION_ALARM); Intent intent = new Intent(Intents.ACTION_ALARM);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("ALARM " + x.size() + " receivers");
} }
} }

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -21,14 +22,14 @@ public class BroadcastAnnouncement {
private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class); private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class);
public static void handleAnnouncement(JSONObject announcement, Context context) { public static void handleAnnouncement(JSONObject announcement, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", announcement.toString()); bundle.putString("data", announcement.toString());
Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT); Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("ANNOUNCEMENT " + x.size() + " receivers");
} }
} }

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastCals {
private static Logger log = LoggerFactory.getLogger(BroadcastCals.class); private static Logger log = LoggerFactory.getLogger(BroadcastCals.class);
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) { public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("cals", cals.toString()); bundle.putString("cals", cals.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -27,8 +31,5 @@ public class BroadcastCals {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("CAL " + x.size() + " receivers");
} }
} }

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -20,14 +21,14 @@ public class BroadcastClearAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class);
public static void handleClearAlarm(JSONObject clearalarm, Context context) { public static void handleClearAlarm(JSONObject clearalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", clearalarm.toString()); bundle.putString("data", clearalarm.toString());
Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM); Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("CLEARALARM " + x.size() + " receivers");
} }
} }

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
public class BroadcastDeviceStatus { public class BroadcastDeviceStatus {
@ -26,11 +27,13 @@ public class BroadcastDeviceStatus {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("DEVICESTATUS " + x.size() + " receivers");
} }
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses); List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part: splitted) { for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -40,9 +43,6 @@ public class BroadcastDeviceStatus {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("DEVICESTATUS " + part.length() + " records " + x.size() + " receivers");
} }
} }
} }

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -20,6 +21,9 @@ public class BroadcastMbgs {
private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class); private static Logger log = LoggerFactory.getLogger(BroadcastMbgs.class);
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) { public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("mbgs", mbgs.toString()); bundle.putString("mbgs", mbgs.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -27,8 +31,5 @@ public class BroadcastMbgs {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("MBG " + x.size() + " receivers");
} }
} }

View file

@ -12,6 +12,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP;
/** /**
@ -21,6 +22,9 @@ public class BroadcastProfile {
private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class); private static Logger log = LoggerFactory.getLogger(BroadcastProfile.class);
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) { public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("profile", profile.getData().toString()); bundle.putString("profile", profile.getData().toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -28,9 +32,6 @@ public class BroadcastProfile {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("PROFILE " + x.size() + " receivers");
} }
} }

View file

@ -6,12 +6,16 @@ import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 28.02.2016. * Created by mike on 28.02.2016.
*/ */
public class BroadcastQueueStatus { public class BroadcastQueueStatus {
public static void handleNewStatus(int size, Context context) { public static void handleNewStatus(int size, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"sendQueue"); "sendQueue");

View file

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 22.02.2016. * Created by mike on 22.02.2016.
@ -21,6 +22,9 @@ public class BroadcastSgvs {
private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class); private static Logger log = LoggerFactory.getLogger(BroadcastSgvs.class);
public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) { public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("sgv", sgv.toString()); bundle.putString("sgv", sgv.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -28,9 +32,6 @@ public class BroadcastSgvs {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("SGV " + x.size() + " receivers");
} }
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) { public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
@ -41,9 +42,6 @@ public class BroadcastSgvs {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("SGV " + x.size() + " receivers");
} }
} }

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 24.02.2016. * Created by mike on 24.02.2016.
@ -23,6 +24,9 @@ public class BroadcastStatus {
private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class); private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class);
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
try { try {
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName); bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
@ -38,8 +42,5 @@ public class BroadcastStatus {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("STATUS: " + x.size() + " receivers");
} }
} }

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.TransactionTooLargeException;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -16,6 +17,7 @@ import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 20.02.2016. * Created by mike on 20.02.2016.
@ -24,6 +26,9 @@ public class BroadcastTreatment {
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class); private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) { public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.getData().toString()); bundle.putString("treatment", treatment.getData().toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -31,12 +36,12 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("TREAT_ADD " + treatment.getEventType() + " " + x.size() + " receivers");
} }
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) { public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = splitArray(treatments); List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part: splitted) { for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -46,13 +51,13 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("TREAT_ADD " + part.length() + " " + x.size() + " receivers");
} }
} }
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) { public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString()); bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -60,15 +65,12 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
try {
log.debug("TREAT_CHANGE " + treatment.getString("_id") + " " + x.size() + " receivers");
} catch (JSONException e) {
}
} }
public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) { public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = splitArray(treatments); List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part: splitted) { for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -78,13 +80,13 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("TREAT_CHANGE " + part.length() + " " + x.size() + " receivers");
} }
} }
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) { public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString()); bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -92,15 +94,12 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
try {
log.debug("TREAT_REMOVE " + treatment.getString("_id") + " " + x.size() + " receivers");
} catch (JSONException e) {
}
} }
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) { public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatments", treatments.toString()); bundle.putString("treatments", treatments.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
@ -108,9 +107,6 @@ public class BroadcastTreatment {
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("TREAT_REMOVE " + treatments.length() + " treatments " + x.size() + " receivers");
} }

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 26.06.2016. * Created by mike on 26.06.2016.
@ -20,14 +21,14 @@ public class BroadcastUrgentAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class);
public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) { public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", urgentalarm.toString()); bundle.putString("data", urgentalarm.toString());
Intent intent = new Intent(Intents.ACTION_URGENT_ALARM); Intent intent = new Intent(Intents.ACTION_URGENT_ALARM);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("URGENTALARM " + x.size() + " receivers");
} }
} }

View file

@ -8,7 +8,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config; 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.Iob;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.MealData; 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.OverlappingIntervals;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.data.ProfileIntervals;
@ -48,9 +49,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public static IobTotal lastTempBasalsCalculation; public static IobTotal lastTempBasalsCalculation;
public static List<Treatment> treatments; public static List<Treatment> treatments;
private static OverlappingIntervals<TemporaryBasal> tempBasals = new OverlappingIntervals<>(); private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<TemporaryBasal>();
private static OverlappingIntervals<ExtendedBolus> extendedBoluses = new OverlappingIntervals<>(); private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<ExtendedBolus>();
private static OverlappingIntervals<TempTarget> tempTargets = new OverlappingIntervals<>(); private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<TempTarget>();
private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>(); private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
private static boolean fragmentEnabled = true; private static boolean fragmentEnabled = true;
@ -347,7 +348,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
} }
@Override @Override
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() { public Intervals<ExtendedBolus> getExtendedBolusesFromHistory() {
return extendedBoluses; return extendedBoluses;
} }
@ -380,7 +381,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
} }
@Override @Override
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() { public Intervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
return tempBasals; return tempBasals;
} }
@ -442,7 +443,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
} }
@Override @Override
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() { public Intervals<TempTarget> getTempTargetsFromHistory() {
return tempTargets; return tempTargets;
} }

View file

@ -23,8 +23,6 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
@ -36,7 +34,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Intervals;
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment { public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
@ -49,9 +47,9 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ExtendedBolusesViewHolder> { 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; this.extendedBolusList = extendedBolusList;
} }

View file

@ -30,7 +30,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Intervals;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
@ -47,10 +47,12 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> { 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; this.tempTargetList = TempTargetList;
currentlyActiveTarget = tempTargetList.getValueByInterval(System.currentTimeMillis());
} }
@Override @Override
@ -81,10 +83,18 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
holder.reasonLabel.setText(""); holder.reasonLabel.setText("");
holder.reasonColon.setText(""); holder.reasonColon.setText("");
} }
if (tempTarget.isInProgress()) if (tempTarget.isInProgress()) {
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); if(tempTarget == currentlyActiveTarget){
else // 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.date.setTextColor(holder.reasonColon.getCurrentTextColor());
}
holder.remove.setTag(tempTarget); holder.remove.setTag(tempTarget);
} }

View file

@ -23,8 +23,6 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
@ -36,7 +34,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Intervals;
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment { public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
@ -51,9 +49,9 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> { 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; this.tempBasalList = tempBasalList;
} }

View file

@ -4,8 +4,14 @@ import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; 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.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.DanaRInterface;
import info.nightscout.androidaps.interfaces.PluginBase; 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.Actions.dialogs.FillDialog;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin; 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.BolusWizard;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -157,14 +171,9 @@ public class ActionStringHandler {
rMessage = getPumpStatus(); rMessage = getPumpStatus();
} else if ("loop".equals(act[1])) { } else if ("loop".equals(act[1])) {
rTitle += " LOOP"; rTitle += " LOOP";
rMessage = getLoopStatus(); rMessage = "TARGETS:\n" + getTargetsStatus();
rMessage += "\n\n" + getLoopStatus();
} else if ("targets".equals(act[1])) { rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();;
rTitle += " TARGETS";
rMessage = getTargetsStatus();
} else if ("oapsresult".equals(act[1])) {
rTitle += " OAPS RESULT";
rMessage = getOAPSResultStatus();
} }
} else if ("wizard".equals(act[0])) { } else if ("wizard".equals(act[0])) {
@ -256,6 +265,58 @@ public class ActionStringHandler {
rAction = actionstring; 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; else return;
@ -266,6 +327,98 @@ public class ActionStringHandler {
lastConfirmActionString = rAction; 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 @NonNull
private static String getPumpStatus() { private static String getPumpStatus() {
return MainApp.getConfigBuilder().shortStatus(false); return MainApp.getConfigBuilder().shortStatus(false);
@ -506,6 +659,13 @@ public class ActionStringHandler {
lastBolusWizard = null; 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) { public synchronized static void expectNotificationAction(String message, int id) {
String actionstring = "dismissoverviewnotification " + id; String actionstring = "dismissoverviewnotification " + id;
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring); WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring);

View file

@ -5,7 +5,6 @@
tools:context="info.nightscout.androidaps.plugins.Loop.LoopFragment"> tools:context="info.nightscout.androidaps.plugins.Loop.LoopFragment">
<ScrollView <ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">

View file

@ -6,12 +6,11 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:layout_marginTop="10dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout

View file

@ -6,12 +6,11 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:layout_marginTop="10dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout

File diff suppressed because it is too large Load diff

View file

@ -580,6 +580,7 @@
<string name="superbolus">Superbolus</string> <string name="superbolus">Superbolus</string>
<string name="ns_logappstartedevent">Log app start to NS</string> <string name="ns_logappstartedevent">Log app start to NS</string>
<string name="key_ns_logappstartedevent" translatable="false">ns_logappstartedevent</string> <string name="key_ns_logappstartedevent" translatable="false">ns_logappstartedevent</string>
<string name="key_ns_localbroadcasts" translatable="false">nsclient_localbroadcasts</string>
<string name="restartingapp">Exiting application to apply settings.</string> <string name="restartingapp">Exiting application to apply settings.</string>
<string name="danarv2pump">DanaRv2</string> <string name="danarv2pump">DanaRv2</string>
<string name="configbuilder_insulin">Insulin</string> <string name="configbuilder_insulin">Insulin</string>
@ -685,4 +686,6 @@
<string name="cpp_valuesnotstored">Values not stored!</string> <string name="cpp_valuesnotstored">Values not stored!</string>
<string name="wear_overviewnotifications">Overview Notifications</string> <string name="wear_overviewnotifications">Overview Notifications</string>
<string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string> <string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string>
<string name="ns_localbroadcasts">Enable loacal broadcasts to other apps (like xDrip).</string>
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
</resources> </resources>

View file

@ -27,6 +27,13 @@
android:key="@string/key_ns_logappstartedevent" android:key="@string/key_ns_logappstartedevent"
android:title="@string/ns_logappstartedevent" /> android:title="@string/ns_logappstartedevent" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:title="@string/ns_localbroadcasts_title"
android:summary="@string/ns_localbroadcasts"/>
<PreferenceScreen android:title="@string/ns_alarmoptions"> <PreferenceScreen android:title="@string/ns_alarmoptions">
<SwitchPreference <SwitchPreference

View file

@ -50,7 +50,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
isMGDL = sp.getBoolean("units_mgdl", true); isMGDL = sp.getBoolean("units_mgdl", true);
isSingleTarget = sp.getBoolean("singletarget", false); isSingleTarget = sp.getBoolean("singletarget", true);
} }

View file

@ -14,7 +14,7 @@ public class FillMenuActivity extends MenuListActivity {
@Override @Override
protected String[] getElements() { protected String[] getElements() {
return new String[] { return new String[]{
"Preset 1", "Preset 1",
"Preset 2", "Preset 2",
"Preset 3", "Preset 3",
@ -23,23 +23,17 @@ public class FillMenuActivity extends MenuListActivity {
} }
@Override @Override
protected void doAction(int position) { protected void doAction(String action) {
switch (position) { if ("Preset 1".equals(action)) {
case 0: ListenerService.initiateAction(this, "fillpreset 1");
ListenerService.initiateAction(this, "fillpreset 1"); } else if ("Preset 2".equals(action)) {
break; ListenerService.initiateAction(this, "fillpreset 2");
case 1: } else if ("Preset 3".equals(action)) {
ListenerService.initiateAction(this, "fillpreset 2"); ListenerService.initiateAction(this, "fillpreset 3");
break; } else if ("Free amount".equals(action)) {
case 2: Intent intent = new Intent(this, FillActivity.class);
ListenerService.initiateAction(this, "fillpreset 3"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
break; this.startActivity(intent);
case 3:
Intent intent = new Intent(this, FillActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
} }
} }
} }

View file

@ -5,6 +5,8 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import java.util.Vector;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.AAPSPreferences; import info.nightscout.androidaps.interaction.AAPSPreferences;
@ -39,74 +41,50 @@ public class MainMenuActivity extends MenuListActivity {
boolean showPrimeFill = sp.getBoolean("primefill", false); boolean showPrimeFill = sp.getBoolean("primefill", false);
return new String[] { boolean showWizard = sp.getBoolean("showWizard", true);
"TempT",
"Bolus", Vector<String> menuitems = new Vector<String>();
"Wizard", menuitems.add("TempT");
"Settings", menuitems.add("Bolus");
"Re-Sync", if(showWizard) menuitems.add("Wizard");
"Status", menuitems.add("Settings");
showPrimeFill?"Prime/Fill":""}; menuitems.add("Status");
if (showPrimeFill) menuitems.add("Prime/Fill");
return menuitems.toArray(new String[menuitems.size()]);
} }
@Override @Override
protected void doAction(int position) { protected void doAction(String action) {
Intent intent; Intent intent;
if(!BuildConfig.WEAR_CONTROL) { if ("Settings".equals(action)) {
switch (position) { intent = new Intent(this, AAPSPreferences.class);
case 0: intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent = new Intent(this, AAPSPreferences.class); this.startActivity(intent);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else if ("Re-Sync".equals(action)) {
this.startActivity(intent); ListenerService.requestData(this);
break; } else if ("TempT".equals(action)) {
case 1: intent = new Intent(this, TempTargetActivity.class);
ListenerService.requestData(this); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
break; this.startActivity(intent);
} } else if ("Bolus".equals(action)) {
return; intent = new Intent(this, BolusActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
} else if ("Wizard".equals(action)) {
intent = new Intent(this, WizardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
} else if ("Status".equals(action)) {
intent = new Intent(this, StatusMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
} else if ("Prime/Fill".equals(action)) {
intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
} }
switch (position) {
case 0:
intent = new Intent(this, TempTargetActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 1:
intent = new Intent(this, BolusActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 2:
intent = new Intent(this, WizardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 3:
intent = new Intent(this, AAPSPreferences.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 4:
ListenerService.requestData(this);
break;
case 5:
intent = new Intent(this, StatusMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 6:
boolean showPrimeFill = sp.getBoolean("primefill", false);
if(showPrimeFill) {
intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
break;
}
} }
} }

View file

@ -1,53 +0,0 @@
package info.nightscout.androidaps.interaction.menus;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.AAPSPreferences;
import info.nightscout.androidaps.interaction.actions.BolusActivity;
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
import info.nightscout.androidaps.interaction.actions.WizardActivity;
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
/**
* Created by adrian on 09/02/17.
*/
public class MainMenuRestrictedActivity extends MenuListActivity {
SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
sp = PreferenceManager.getDefaultSharedPreferences(this);
super.onCreate(savedInstanceState);
ListenerService.requestData(this);
}
@Override
protected String[] getElements() {
return new String[] {
"Settings",
"Re-Sync"};
}
@Override
protected void doAction(int position) {
Intent intent;
switch (position) {
case 0:
intent = new Intent(this, AAPSPreferences.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 1:
ListenerService.requestData(this);
break;
}
}
}

View file

@ -14,32 +14,22 @@ public class StatusMenuActivity extends MenuListActivity {
return new String[] { return new String[] {
"Pump", "Pump",
"Loop", "Loop",
"Targets",
"CPP", "CPP",
"OAPS Result"}; "TDD"};
} }
@Override @Override
protected void doAction(int position) { protected void doAction(String action) {
switch (position) { if ("Pump".equals(action)) {
ListenerService.initiateAction(this, "status pump");
case 0: } else if ("Loop".equals(action)) {
ListenerService.initiateAction(this, "status pump"); ListenerService.initiateAction(this, "status loop");
break; } else if ("CPP".equals(action)) {
case 1: ListenerService.initiateAction(this, "opencpp");
ListenerService.initiateAction(this, "status loop"); } else if ("TDD".equals(action)) {
break; ListenerService.initiateAction(this, "tddstats");
case 2:
ListenerService.initiateAction(this, "status targets");
break;
case 3:
ListenerService.initiateAction(this, "opencpp");
break;
case 4:
ListenerService.initiateAction(this, "status oapsresult");
break;
} }
} }
} }

View file

@ -22,7 +22,7 @@ public abstract class MenuListActivity extends Activity
protected abstract String[] getElements(); protected abstract String[] getElements();
protected abstract void doAction(int position); protected abstract void doAction(String position);
@Override @Override
protected void onPause(){ protected void onPause(){
@ -50,7 +50,7 @@ public abstract class MenuListActivity extends Activity
// WearableListView click listener // WearableListView click listener
@Override @Override
public void onClick(WearableListView.ViewHolder v) { public void onClick(WearableListView.ViewHolder v) {
Integer tag = (Integer) v.itemView.getTag(); String tag = (String) v.itemView.getTag();
doAction(tag); doAction(tag);
//ActionsDefinitions.doAction(v.getAdapterPosition(), this); //ActionsDefinitions.doAction(v.getAdapterPosition(), this);
finish(); finish();
@ -105,7 +105,7 @@ public abstract class MenuListActivity extends Activity
// replace text contents // replace text contents
view.setText(mDataset[position]); view.setText(mDataset[position]);
// replace list item's metadata // replace list item's metadata
holder.itemView.setTag(position); holder.itemView.setTag(mDataset[position]);
} }
// Return the size of your dataset // Return the size of your dataset

View file

@ -121,6 +121,13 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/> app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="showWizard"
android:summary="Wizard from watch possible"
android:title="Wizard in Menu"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="primefill" android:key="primefill"
@ -129,7 +136,7 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/> app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="true"
android:key="singletarget" android:key="singletarget"
android:summary="Single temp-target instead of a range." android:summary="Single temp-target instead of a range."
android:title="Single Target" android:title="Single Target"