cleanup
This commit is contained in:
parent
30c530a109
commit
1b132fd589
5 changed files with 35 additions and 45 deletions
app/src/main
java/info/nightscout/androidaps/plugins
res/xml
core/src/main/res/values
|
@ -103,9 +103,6 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
|
|
||||||
private long lastBgTriggeredRun = 0;
|
private long lastBgTriggeredRun = 0;
|
||||||
|
|
||||||
private long loopSuspendedTill; // end of manual loop suspend
|
|
||||||
private boolean isSuperBolus;
|
|
||||||
private boolean isDisconnected;
|
|
||||||
|
|
||||||
private long carbsSuggestionsSuspendedUntil = 0;
|
private long carbsSuggestionsSuspendedUntil = 0;
|
||||||
private int prevCarbsreq = 0;
|
private int prevCarbsreq = 0;
|
||||||
|
@ -173,9 +170,6 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
this.nsUpload = nsUpload;
|
this.nsUpload = nsUpload;
|
||||||
this.hardLimits = hardLimits;
|
this.hardLimits = hardLimits;
|
||||||
|
|
||||||
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
|
||||||
isSuperBolus = sp.getBoolean("isSuperBolus", false);
|
|
||||||
isDisconnected = sp.getBoolean("isDisconnected", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -240,33 +234,25 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suspendTo(long endTime) {
|
public void suspendTo(long endTime) {
|
||||||
loopSuspendedTill = endTime;
|
sp.putLong("loopSuspendedTill", endTime);
|
||||||
isSuperBolus = false;
|
sp.putBoolean("isSuperBolus", false);
|
||||||
isDisconnected = false;
|
sp.putBoolean("isDisconnected", false);
|
||||||
sp.putLong("loopSuspendedTill", loopSuspendedTill);
|
|
||||||
sp.putBoolean("isSuperBolus", isSuperBolus);
|
|
||||||
sp.putBoolean("isDisconnected", isDisconnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void superBolusTo(long endTime) {
|
public void superBolusTo(long endTime) {
|
||||||
loopSuspendedTill = endTime;
|
sp.putLong("loopSuspendedTill", endTime);
|
||||||
isSuperBolus = true;
|
sp.putBoolean("isSuperBolus", true);
|
||||||
isDisconnected = false;
|
sp.putBoolean("isDisconnected", false);
|
||||||
sp.putLong("loopSuspendedTill", loopSuspendedTill);
|
|
||||||
sp.putBoolean("isSuperBolus", isSuperBolus);
|
|
||||||
sp.putBoolean("isDisconnected", isDisconnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnectTo(long endTime) {
|
private void disconnectTo(long endTime) {
|
||||||
loopSuspendedTill = endTime;
|
sp.putLong("loopSuspendedTill", endTime);
|
||||||
isSuperBolus = false;
|
sp.putBoolean("isSuperBolus", false);
|
||||||
isDisconnected = true;
|
sp.putBoolean("isDisconnected", true);
|
||||||
sp.putLong("loopSuspendedTill", loopSuspendedTill);
|
|
||||||
sp.putBoolean("isSuperBolus", isSuperBolus);
|
|
||||||
sp.putBoolean("isDisconnected", isDisconnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int minutesToEndOfSuspend() {
|
public int minutesToEndOfSuspend() {
|
||||||
|
long loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
if (loopSuspendedTill == 0)
|
if (loopSuspendedTill == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -282,6 +268,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
|
long loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
if (loopSuspendedTill == 0)
|
if (loopSuspendedTill == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -311,6 +298,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuperBolus() {
|
public boolean isSuperBolus() {
|
||||||
|
long loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
if (loopSuspendedTill == 0)
|
if (loopSuspendedTill == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -321,10 +309,11 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isSuperBolus;
|
return sp.getBoolean("isSuperBolus", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisconnected() {
|
public boolean isDisconnected() {
|
||||||
|
long loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
if (loopSuspendedTill == 0)
|
if (loopSuspendedTill == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -334,7 +323,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
suspendTo(0L);
|
suspendTo(0L);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isDisconnected;
|
return sp.getBoolean("isDisconnected", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean treatmentTimethreshold(int duartionMinutes) {
|
public boolean treatmentTimethreshold(int duartionMinutes) {
|
||||||
|
@ -362,7 +351,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PumpInterface pump = activePlugin.getActivePump();
|
final PumpInterface pump = activePlugin.getActivePump();
|
||||||
APSResult result = null;
|
APSResult apsResult = null;
|
||||||
|
|
||||||
if (!isEnabled(PluginType.LOOP))
|
if (!isEnabled(PluginType.LOOP))
|
||||||
return;
|
return;
|
||||||
|
@ -381,23 +370,23 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
APSInterface usedAPS = activePlugin.getActiveAPS();
|
APSInterface usedAPS = activePlugin.getActiveAPS();
|
||||||
if (((PluginBase) usedAPS).isEnabled(PluginType.APS)) {
|
if (((PluginBase) usedAPS).isEnabled(PluginType.APS)) {
|
||||||
usedAPS.invoke(initiator, tempBasalFallback);
|
usedAPS.invoke(initiator, tempBasalFallback);
|
||||||
result = usedAPS.getLastAPSResult();
|
apsResult = usedAPS.getLastAPSResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have any result
|
// Check if we have any result
|
||||||
if (result == null) {
|
if (apsResult == null) {
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for pumps using % basals
|
// Prepare for pumps using % basals
|
||||||
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
|
||||||
result.setUsePercent(true);
|
apsResult.setUsePercent(true);
|
||||||
}
|
}
|
||||||
result.setPercent((int) (result.getRate() / profile.getBasal() * 100));
|
apsResult.setPercent((int) (apsResult.getRate() / profile.getBasal() * 100));
|
||||||
|
|
||||||
// check rate for constraints
|
// check rate for constraints
|
||||||
final APSResult resultAfterConstraints = result.newAndClone(injector);
|
final APSResult resultAfterConstraints = apsResult.newAndClone(injector);
|
||||||
resultAfterConstraints.setRateConstraint(new Constraint<>(resultAfterConstraints.getRate()));
|
resultAfterConstraints.setRateConstraint(new Constraint<>(resultAfterConstraints.getRate()));
|
||||||
resultAfterConstraints.setRate(constraintChecker.applyBasalConstraints(resultAfterConstraints.getRateConstraint(), profile).value());
|
resultAfterConstraints.setRate(constraintChecker.applyBasalConstraints(resultAfterConstraints.getRateConstraint(), profile).value());
|
||||||
|
|
||||||
|
@ -419,7 +408,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastRun == null) lastRun = new LastRun();
|
if (lastRun == null) lastRun = new LastRun();
|
||||||
lastRun.setRequest(result);
|
lastRun.setRequest(apsResult);
|
||||||
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
||||||
lastRun.setLastAPSRun(DateUtil.now());
|
lastRun.setLastAPSRun(DateUtil.now());
|
||||||
lastRun.setSource(((PluginBase) usedAPS).getName());
|
lastRun.setSource(((PluginBase) usedAPS).getName());
|
||||||
|
@ -572,7 +561,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
.setPriority(Notification.IMPORTANCE_HIGH)
|
.setPriority(Notification.IMPORTANCE_HIGH)
|
||||||
.setCategory(Notification.CATEGORY_ALARM)
|
.setCategory(Notification.CATEGORY_ALARM)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
if (sp.getBoolean("wearcontrol", false)) {
|
if (sp.getBoolean(R.string.key_wear_control, false)) {
|
||||||
builder.setLocalOnly(true);
|
builder.setLocalOnly(true);
|
||||||
}
|
}
|
||||||
presentSuggestion(builder);
|
presentSuggestion(builder);
|
||||||
|
|
|
@ -76,7 +76,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
// TODO Adrian use RxBus instead of Lazy + cross dependency
|
// TODO Adrian use RxBus instead of Lazy + cross dependency
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun handleInitiate(actionString: String) {
|
fun handleInitiate(actionString: String) {
|
||||||
if (!sp.getBoolean("wearcontrol", false)) return
|
if (!sp.getBoolean(R.string.key_wear_control, false)) return
|
||||||
lastBolusWizard = null
|
lastBolusWizard = null
|
||||||
var rTitle = "CONFIRM" //TODO: i18n
|
var rTitle = "CONFIRM" //TODO: i18n
|
||||||
var rMessage = ""
|
var rMessage = ""
|
||||||
|
@ -459,7 +459,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun handleConfirmation(actionString: String) {
|
fun handleConfirmation(actionString: String) {
|
||||||
if (!sp.getBoolean("wearcontrol", false)) return
|
if (!sp.getBoolean(R.string.key_wear_control, false)) return
|
||||||
//Guard from old or duplicate confirmations
|
//Guard from old or duplicate confirmations
|
||||||
if (lastConfirmActionString == null) return
|
if (lastConfirmActionString == null) return
|
||||||
if (lastConfirmActionString != actionString) return
|
if (lastConfirmActionString != actionString) return
|
||||||
|
|
|
@ -743,12 +743,12 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
private void sendPreferences() {
|
private void sendPreferences() {
|
||||||
if (googleApiClient != null && googleApiClient.isConnected()) {
|
if (googleApiClient != null && googleApiClient.isConnected()) {
|
||||||
|
|
||||||
boolean wearcontrol = sp.getBoolean("wearcontrol", false);
|
boolean wearcontrol = sp.getBoolean(R.string.key_wear_control, false);
|
||||||
|
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
||||||
dataMapRequest.getDataMap().putBoolean("wearcontrol", wearcontrol);
|
dataMapRequest.getDataMap().putBoolean(resourceHelper.gs(R.string.key_wear_control), wearcontrol);
|
||||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,18 +8,18 @@
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="wearcontrol"
|
android:key="@string/key_wear_control"
|
||||||
android:summary="@string/wearcontrol_summary"
|
android:summary="@string/wearcontrol_summary"
|
||||||
android:title="@string/wearcontrol_title" />
|
android:title="@string/wearcontrol_title" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:summary="@string/wear_wizard_settings_summary"
|
android:summary="@string/wear_wizard_settings_summary"
|
||||||
android:title="@string/wear_wizard_settings">
|
android:title="@string/wear_wizard_settings">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:key="@string/key_wearwizard_bg"
|
android:key="@string/key_wearwizard_bg"
|
||||||
android:title="@string/treatments_wizard_bg_label" />
|
android:title="@string/treatments_wizard_bg_label" />
|
||||||
|
|
||||||
|
@ -31,25 +31,25 @@
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:key="@string/key_wearwizard_trend"
|
android:key="@string/key_wearwizard_trend"
|
||||||
android:title="@string/treatments_wizard_bgtrend_label" />
|
android:title="@string/treatments_wizard_bgtrend_label" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:key="@string/key_wearwizard_cob"
|
android:key="@string/key_wearwizard_cob"
|
||||||
android:title="@string/treatments_wizard_cob_label" />
|
android:title="@string/treatments_wizard_cob_label" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:key="@string/key_wearwizard_bolusiob"
|
android:key="@string/key_wearwizard_bolusiob"
|
||||||
android:title="@string/treatments_wizard_bolusiob_label" />
|
android:title="@string/treatments_wizard_bolusiob_label" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:dependency="wearcontrol"
|
android:dependency="@string/key_wear_control"
|
||||||
android:key="@string/key_wearwizard_basaliob"
|
android:key="@string/key_wearwizard_basaliob"
|
||||||
android:title="@string/treatments_wizard_basaliob_label" />
|
android:title="@string/treatments_wizard_basaliob_label" />
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
||||||
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
||||||
<string name="key_quickwizard" translatable="false">QuickWizard</string>
|
<string name="key_quickwizard" translatable="false">QuickWizard</string>
|
||||||
|
<string name="key_wear_control" translatable="false">wearcontrol</string>
|
||||||
|
|
||||||
<!-- General-->
|
<!-- General-->
|
||||||
<string name="refresh">Refresh</string>
|
<string name="refresh">Refresh</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue