commit
0cc97388f5
144 changed files with 3576 additions and 1194 deletions
7
Steampunk_graphics_source_link.md
Normal file
7
Steampunk_graphics_source_link.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Follow this link to get the source PSD file for the Steampunk graphics. The file could not be included in the repository as it exceeds Github's 25 mb limit.
|
||||||
|
|
||||||
|
Note, the source image size is 1600x1600. The image size should be reduced to 400x400 prior to export of final PNG.
|
||||||
|
|
||||||
|
https://drive.google.com/drive/folders/1MrdgnQz3wOniDvRSMhAsqHBYb2WmE5i0
|
||||||
|
|
||||||
|
Graphics created by (Github): andrew-warrington
|
|
@ -174,6 +174,10 @@ dependencies {
|
||||||
compile 'junit:junit:4.12'
|
compile 'junit:junit:4.12'
|
||||||
testCompile 'org.json:json:20140107'
|
testCompile 'org.json:json:20140107'
|
||||||
testCompile 'org.mockito:mockito-core:2.7.22'
|
testCompile 'org.mockito:mockito-core:2.7.22'
|
||||||
|
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
|
||||||
|
testCompile 'org.powermock:powermock-module-junit4-rule-agent:1.7.3'
|
||||||
|
testCompile 'org.powermock:powermock-module-junit4-rule:1.7.3'
|
||||||
|
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
|
||||||
androidTestCompile 'org.mockito:mockito-core:2.7.22'
|
androidTestCompile 'org.mockito:mockito-core:2.7.22'
|
||||||
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
|
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
|
||||||
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
|
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
|
||||||
|
@ -188,4 +192,6 @@ dependencies {
|
||||||
compile 'com.google.code.gson:gson:2.7'
|
compile 'com.google.code.gson:gson:2.7'
|
||||||
compile 'com.google.guava:guava:20.0'
|
compile 'com.google.guava:guava:20.0'
|
||||||
|
|
||||||
|
compile 'net.danlew:android.joda:2.9.9.1'
|
||||||
|
testCompile 'joda-time:joda-time:2.9.4.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,12 +112,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recreate();
|
if(ev.recreate) {
|
||||||
try { // activity may be destroyed
|
recreate();
|
||||||
setUpTabs(true);
|
}else {
|
||||||
} catch (IllegalStateException e) {
|
try { // activity may be destroyed
|
||||||
log.error("Unhandled exception", e);
|
setUpTabs(true);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean lockScreen = BuildConfig.NSCLIENTOLNY && SP.getBoolean("lockscreen", false);
|
boolean lockScreen = BuildConfig.NSCLIENTOLNY && SP.getBoolean("lockscreen", false);
|
||||||
if (lockScreen)
|
if (lockScreen)
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
|
@ -15,6 +15,8 @@ import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.LoggingBus;
|
import com.squareup.otto.LoggingBus;
|
||||||
import com.squareup.otto.ThreadEnforcer;
|
import com.squareup.otto.ThreadEnforcer;
|
||||||
|
|
||||||
|
import net.danlew.android.joda.JodaTimeAndroid;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -96,6 +98,7 @@ public class MainApp extends Application {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Fabric.with(this, new Crashlytics());
|
Fabric.with(this, new Crashlytics());
|
||||||
Fabric.with(this, new Answers());
|
Fabric.with(this, new Answers());
|
||||||
|
JodaTimeAndroid.init(this);
|
||||||
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
||||||
log.info("Version: " + BuildConfig.VERSION_NAME);
|
log.info("Version: " + BuildConfig.VERSION_NAME);
|
||||||
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
||||||
|
@ -213,7 +216,7 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
public void stopKeepAliveService() {
|
public void stopKeepAliveService() {
|
||||||
if (keepAliveReceiver != null)
|
if (keepAliveReceiver != null)
|
||||||
keepAliveReceiver.cancelAlarm(this);
|
KeepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
public static Bus bus() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
|
@ -58,8 +59,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
if (key.equals("language")) {
|
if (key.equals("language")) {
|
||||||
String lang = sharedPreferences.getString("language", "en");
|
String lang = sharedPreferences.getString("language", "en");
|
||||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||||
recreate();
|
MainApp.bus().post(new EventRefreshGui(true));
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
//recreate() does not update language so better close settings
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
if (key.equals("short_tabtitles")) {
|
if (key.equals("short_tabtitles")) {
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
MainApp.bus().post(new EventRefreshGui());
|
||||||
|
@ -149,10 +151,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY);
|
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY);
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY);
|
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY);
|
||||||
|
|
||||||
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
|
|
||||||
addPreferencesFromResource(R.xml.pref_profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.DANAR) {
|
if (Config.DANAR) {
|
||||||
addPreferencesFromResourceIfEnabled(DanaRPlugin.getPlugin(), PluginBase.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRPlugin.getPlugin(), PluginBase.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginBase.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginBase.PUMP);
|
||||||
|
|
|
@ -96,7 +96,12 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||||
|
|
||||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||||
|
Bundle bundles = intent.getExtras();
|
||||||
|
if (bundles != null && bundles.containsKey("islocal")) {
|
||||||
|
acceptNSData = acceptNSData || bundles.getBoolean("islocal");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
|
@ -117,17 +122,15 @@ public class DataService extends IntentService {
|
||||||
handleNewDataFromDexcomG5(intent);
|
handleNewDataFromDexcomG5(intent);
|
||||||
}
|
}
|
||||||
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
||||||
// always handle SGV if NS-Client is the source
|
// always backfill SGV from NS
|
||||||
if (nsClientEnabled) {
|
handleNewDataFromNSClient(intent);
|
||||||
handleNewDataFromNSClient(intent);
|
|
||||||
}
|
|
||||||
// Objectives 0
|
// Objectives 0
|
||||||
ObjectivesPlugin.bgIsAvailableInNS = true;
|
ObjectivesPlugin.bgIsAvailableInNS = true;
|
||||||
ObjectivesPlugin.saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
|
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
|
||||||
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
||||||
handleNewDataFromNSClient(intent);
|
handleNewDataFromNSClient(intent);
|
||||||
} else if (!nsUploadOnly &&
|
} else if (acceptNSData &&
|
||||||
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
||||||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
||||||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
||||||
|
@ -301,7 +304,7 @@ public class DataService extends IntentService {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
if (ConfigBuilderPlugin.nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
|
if (ConfigBuilderPlugin.nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
|
||||||
Notification notification = new Notification(Notification.OLD_NS, MainApp.sResources.getString(R.string.unsupportednsversion), Notification.URGENT);
|
Notification notification = new Notification(Notification.OLD_NS, MainApp.sResources.getString(R.string.unsupportednsversion), Notification.NORMAL);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
} else {
|
} else {
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS));
|
MainApp.bus().post(new EventDismissNotification(Notification.OLD_NS));
|
||||||
|
|
|
@ -64,14 +64,21 @@ public class GlucoseStatus {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static GlucoseStatus getGlucoseStatusData() {
|
public static GlucoseStatus getGlucoseStatusData(){
|
||||||
|
return getGlucoseStatusData(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
|
||||||
// load 45min
|
// load 45min
|
||||||
long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
|
long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
||||||
|
|
||||||
int sizeRecords = data.size();
|
int sizeRecords = data.size();
|
||||||
if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) {
|
if (sizeRecords < 1 || (data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L && !allowOldData)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,13 @@ import java.util.TimeZone;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
@ -160,15 +164,23 @@ public class Profile {
|
||||||
for (Integer index = 0; index < array.length(); index++) {
|
for (Integer index = 0; index < array.length(); index++) {
|
||||||
try {
|
try {
|
||||||
final JSONObject o = array.getJSONObject(index);
|
final JSONObject o = array.getJSONObject(index);
|
||||||
long tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
|
long tas = 0;
|
||||||
Double value = o.getDouble("value") * multiplier;
|
try {
|
||||||
|
tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
String time = o.getString("time");
|
||||||
|
tas = getShitfTimeSecs(DateUtil.toSeconds(time));
|
||||||
|
//log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas);
|
||||||
|
}
|
||||||
|
double value = o.getDouble("value") * multiplier;
|
||||||
sparse.put(tas, value);
|
sparse.put(tas, value);
|
||||||
|
if (value == 0) {
|
||||||
|
Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
try {
|
log.error(json.toString());
|
||||||
log.error(array.getJSONObject(index).toString());
|
|
||||||
} catch (JSONException e1) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +339,35 @@ public class Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getBasal(Integer timeAsSeconds) {
|
public Double getBasal(Integer timeAsSeconds) {
|
||||||
if (basal_v == null)
|
if (basal_v == null) {
|
||||||
basal_v = convertToSparseArray(basal);
|
basal_v = convertToSparseArray(basal);
|
||||||
|
for (int index = 0; index < basal_v.size(); index++) {
|
||||||
|
long secondsFromMidnight = basal_v.keyAt(index);
|
||||||
|
if (secondsFromMidnight % 3600 != 0) {
|
||||||
|
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for minimal basal value
|
||||||
|
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
|
if (pump != null) {
|
||||||
|
PumpDescription description = pump.getPumpDescription();
|
||||||
|
for (int i = 0; i < basal_v.size(); i++) {
|
||||||
|
if (basal_v.valueAt(i) < description.basalMinimumRate) {
|
||||||
|
basal_v.setValueAt(i, description.basalMinimumRate);
|
||||||
|
MainApp.bus().post(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, MainApp.sResources.getString(R.string.minimalbasalvaluereplaced), Notification.NORMAL)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getValueToTime(basal_v, timeAsSeconds);
|
||||||
|
} else {
|
||||||
|
// if pump not available (at start)
|
||||||
|
// do not store converted array
|
||||||
|
Double value = getValueToTime(basal_v, timeAsSeconds);
|
||||||
|
basal_v = null;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
return getValueToTime(basal_v, timeAsSeconds);
|
return getValueToTime(basal_v, timeAsSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.Overview;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -9,11 +9,7 @@ import org.json.JSONObject;
|
||||||
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.data.Profile;
|
|
||||||
import info.nightscout.utils.DateUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 12.10.2016.
|
* Created by mike on 12.10.2016.
|
||||||
|
@ -22,84 +18,7 @@ import info.nightscout.utils.DateUtil;
|
||||||
public class QuickWizard {
|
public class QuickWizard {
|
||||||
private static Logger log = LoggerFactory.getLogger(QuickWizard.class);
|
private static Logger log = LoggerFactory.getLogger(QuickWizard.class);
|
||||||
|
|
||||||
public class QuickWizardEntry {
|
private JSONArray storage = new JSONArray();
|
||||||
public JSONObject storage;
|
|
||||||
public int position;
|
|
||||||
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
buttonText: "Meal",
|
|
||||||
carbs: 36,
|
|
||||||
validFrom: 8 * 60 * 60, // seconds from midnight
|
|
||||||
validTo: 9 * 60 * 60, // seconds from midnight
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public QuickWizardEntry() {
|
|
||||||
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
|
||||||
try {
|
|
||||||
storage = new JSONObject(emptyData);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
position = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QuickWizardEntry(JSONObject entry, int position) {
|
|
||||||
storage = entry;
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean isActive() {
|
|
||||||
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buttonText() {
|
|
||||||
try {
|
|
||||||
return storage.getString("buttonText");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer carbs() {
|
|
||||||
try {
|
|
||||||
return storage.getInt("carbs");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date validFromDate() {
|
|
||||||
return DateUtil.toDate(validFrom());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date validToDate() {
|
|
||||||
return DateUtil.toDate(validTo());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer validFrom() {
|
|
||||||
try {
|
|
||||||
return storage.getInt("validFrom");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer validTo() {
|
|
||||||
try {
|
|
||||||
return storage.getInt("validTo");
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONArray storage = new JSONArray();
|
|
||||||
|
|
||||||
public void setData(JSONArray newData) {
|
public void setData(JSONArray newData) {
|
||||||
storage = newData;
|
storage = newData;
|
|
@ -0,0 +1,242 @@
|
||||||
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
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.db.BgReading;
|
||||||
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.utils.BolusWizard;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 25.12.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class QuickWizardEntry {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(QuickWizardEntry.class);
|
||||||
|
|
||||||
|
public JSONObject storage;
|
||||||
|
public int position;
|
||||||
|
|
||||||
|
public static final int YES = 0;
|
||||||
|
public static final int NO = 1;
|
||||||
|
public static final int POSITIVE_ONLY = 2;
|
||||||
|
public static final int NEGATIVE_ONLY = 3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
buttonText: "Meal",
|
||||||
|
carbs: 36,
|
||||||
|
validFrom: 8 * 60 * 60, // seconds from midnight
|
||||||
|
validTo: 9 * 60 * 60, // seconds from midnight
|
||||||
|
useBG: 0,
|
||||||
|
useCOB: 0,
|
||||||
|
useBolusIOB: 0,
|
||||||
|
useBasalIOB: 0,
|
||||||
|
useTrend: 0,
|
||||||
|
useSuperBolus: 0,
|
||||||
|
useTemptarget: 0
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public QuickWizardEntry() {
|
||||||
|
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
||||||
|
try {
|
||||||
|
storage = new JSONObject(emptyData);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
position = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuickWizardEntry(JSONObject entry, int position) {
|
||||||
|
storage = entry;
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isActive() {
|
||||||
|
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BolusWizard doCalc(Profile profile, TempTarget tempTarget, BgReading lastBG) {
|
||||||
|
BolusWizard wizard = new BolusWizard();
|
||||||
|
|
||||||
|
//BG
|
||||||
|
double bg = 0;
|
||||||
|
if (lastBG != null && useBG() == YES) {
|
||||||
|
bg = lastBG.valueToUnits(profile.getUnits());
|
||||||
|
}
|
||||||
|
|
||||||
|
// COB
|
||||||
|
double cob = 0d;
|
||||||
|
AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
|
||||||
|
if (autosensData != null && useCOB() == YES) {
|
||||||
|
cob = autosensData.cob;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temp target
|
||||||
|
if (useTempTarget() == NO) {
|
||||||
|
tempTarget = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bolus IOB
|
||||||
|
boolean bolusIOB = false;
|
||||||
|
if (useBolusIOB() == YES) {
|
||||||
|
bolusIOB = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basal IOB
|
||||||
|
TreatmentsInterface treatments = MainApp.getConfigBuilder();
|
||||||
|
treatments.updateTotalIOBTempBasals();
|
||||||
|
IobTotal basalIob = treatments.getLastCalculationTempBasals().round();
|
||||||
|
boolean basalIOB = false;
|
||||||
|
if (useBasalIOB() == YES) {
|
||||||
|
basalIOB = true;
|
||||||
|
} else if (useBasalIOB() == POSITIVE_ONLY && basalIob.iob > 0) {
|
||||||
|
basalIOB = true;
|
||||||
|
} else if (useBasalIOB() == NEGATIVE_ONLY && basalIob.iob < 0) {
|
||||||
|
basalIOB = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuperBolus
|
||||||
|
boolean superBolus = false;
|
||||||
|
if (useSuperBolus() == YES && SP.getBoolean(R.string.key_usesuperbolus, false)) {
|
||||||
|
superBolus = true;
|
||||||
|
}
|
||||||
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
|
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus())
|
||||||
|
superBolus = false;
|
||||||
|
|
||||||
|
// Trend
|
||||||
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
|
boolean trend = false;
|
||||||
|
if (useTrend() == YES) {
|
||||||
|
trend = true;
|
||||||
|
} else if (useTrend() == POSITIVE_ONLY && glucoseStatus != null && glucoseStatus.short_avgdelta > 0) {
|
||||||
|
trend = true;
|
||||||
|
} else if (useTrend() == NEGATIVE_ONLY && glucoseStatus != null && glucoseStatus.short_avgdelta < 0) {
|
||||||
|
trend = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wizard.doCalc(profile, tempTarget, carbs(), cob, bg, 0d, bolusIOB, basalIOB, superBolus, trend);
|
||||||
|
return wizard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String buttonText() {
|
||||||
|
try {
|
||||||
|
return storage.getString("buttonText");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer carbs() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("carbs");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date validFromDate() {
|
||||||
|
return DateUtil.toDate(validFrom());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date validToDate() {
|
||||||
|
return DateUtil.toDate(validTo());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer validFrom() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("validFrom");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer validTo() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("validTo");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useBG() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useBG");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useCOB() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useCOB");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useBolusIOB() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useBolusIOB");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useBasalIOB() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useBasalIOB");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useTrend() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useTrend");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useSuperBolus() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useSuperBolus");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int useTempTarget() {
|
||||||
|
try {
|
||||||
|
return storage.getInt("useTempTarget");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
//log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,6 +53,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
value = sgv.getMgdl();
|
value = sgv.getMgdl();
|
||||||
raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
|
raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
|
||||||
direction = sgv.getDirection();
|
direction = sgv.getDirection();
|
||||||
|
_id = sgv.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double valueToUnits(String units) {
|
public Double valueToUnits(String units) {
|
||||||
|
|
|
@ -30,7 +30,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
||||||
|
@ -43,9 +45,13 @@ import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
|
import info.nightscout.utils.PercentageSplitter;
|
||||||
|
|
||||||
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class);
|
private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class);
|
||||||
|
@ -367,6 +373,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(BgReading bgReading) {
|
||||||
|
bgReading.date = roundDateToSec(bgReading.date);
|
||||||
|
try {
|
||||||
|
getDaoBgReadings().update(bgReading);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void scheduleBgChange() {
|
private static void scheduleBgChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -397,7 +412,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
||||||
queryBuilder.orderBy("date", false);
|
queryBuilder.orderBy("date", false);
|
||||||
queryBuilder.limit(1L);
|
queryBuilder.limit(1L);
|
||||||
queryBuilder.where().gt("value", 38);
|
queryBuilder.where().gt("value", 38).and().eq("isValid", true);
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
bgList = daoBgReadings.query(preparedQuery);
|
bgList = daoBgReadings.query(preparedQuery);
|
||||||
|
|
||||||
|
@ -435,7 +450,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||||
queryBuilder.orderBy("date", ascending);
|
queryBuilder.orderBy("date", ascending);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("date", mills).and().gt("value", 38);
|
where.ge("date", mills).and().gt("value", 38).and().eq("isValid", true);
|
||||||
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
|
bgReadings = daoBgreadings.query(preparedQuery);
|
||||||
|
return bgReadings;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<BgReading>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||||
|
try {
|
||||||
|
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
||||||
|
List<BgReading> bgReadings;
|
||||||
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.ge("date", mills);
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
bgReadings = daoBgreadings.query(preparedQuery);
|
bgReadings = daoBgreadings.query(preparedQuery);
|
||||||
return bgReadings;
|
return bgReadings;
|
||||||
|
@ -1572,6 +1604,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// look for already added percentage from NS
|
||||||
|
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
|
@ -1645,6 +1679,19 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
profileSwitch.percentage = trJson.getInt("percentage");
|
profileSwitch.percentage = trJson.getInt("percentage");
|
||||||
if (trJson.has("profileJson"))
|
if (trJson.has("profileJson"))
|
||||||
profileSwitch.profileJson = trJson.getString("profileJson");
|
profileSwitch.profileJson = trJson.getString("profileJson");
|
||||||
|
else {
|
||||||
|
ProfileStore store = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||||
|
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
||||||
|
if (profile != null) {
|
||||||
|
profileSwitch.profileJson = profile.getData().toString();
|
||||||
|
log.debug("Profile switch prefilled with JSON from local store");
|
||||||
|
} else {
|
||||||
|
Notification notification = new Notification(Notification.NO_LOCALE_PROFILE_FOUND, MainApp.sResources.getString(R.string.nolocaleprofilefound), Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
log.debug("JSON for profile switch doesn't exist. Ignoring ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (trJson.has("profilePlugin"))
|
if (trJson.has("profilePlugin"))
|
||||||
profileSwitch.profilePlugin = trJson.getString("profilePlugin");
|
profileSwitch.profilePlugin = trJson.getString("profilePlugin");
|
||||||
createOrUpdate(profileSwitch);
|
createOrUpdate(profileSwitch);
|
||||||
|
|
|
@ -4,4 +4,11 @@ package info.nightscout.androidaps.events;
|
||||||
* Created by mike on 13.06.2016.
|
* Created by mike on 13.06.2016.
|
||||||
*/
|
*/
|
||||||
public class EventRefreshGui extends Event {
|
public class EventRefreshGui extends Event {
|
||||||
|
public boolean recreate = false;
|
||||||
|
public EventRefreshGui(boolean recreate) {
|
||||||
|
this.recreate = recreate;
|
||||||
|
}
|
||||||
|
public EventRefreshGui(){
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ public interface ConstraintsInterface {
|
||||||
|
|
||||||
boolean isAMAModeEnabled();
|
boolean isAMAModeEnabled();
|
||||||
|
|
||||||
|
boolean isSMBModeEnabled();
|
||||||
|
|
||||||
Double applyBasalConstraints(Double absoluteRate);
|
Double applyBasalConstraints(Double absoluteRate);
|
||||||
|
|
||||||
Integer applyBasalConstraints(Integer percentRate);
|
Integer applyBasalConstraints(Integer percentRate);
|
||||||
|
|
|
@ -21,5 +21,5 @@ public interface InsulinInterface {
|
||||||
String getFriendlyName();
|
String getFriendlyName();
|
||||||
String getComment();
|
String getComment();
|
||||||
double getDia();
|
double getDia();
|
||||||
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia);
|
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public interface PumpInterface {
|
||||||
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||||
void stopBolusDelivering();
|
void stopBolusDelivering();
|
||||||
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew);
|
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew);
|
||||||
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
|
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew);
|
||||||
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
||||||
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
||||||
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
|
@ -33,6 +32,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.utils.SingleClickButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
|
@ -45,13 +45,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
return actionsPlugin;
|
return actionsPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button profileSwitch;
|
SingleClickButton profileSwitch;
|
||||||
Button tempTarget;
|
SingleClickButton tempTarget;
|
||||||
Button extendedBolus;
|
SingleClickButton extendedBolus;
|
||||||
Button extendedBolusCancel;
|
SingleClickButton extendedBolusCancel;
|
||||||
Button tempBasal;
|
SingleClickButton tempBasal;
|
||||||
Button tempBasalCancel;
|
SingleClickButton tempBasalCancel;
|
||||||
Button fill;
|
SingleClickButton fill;
|
||||||
|
|
||||||
public ActionsFragment() {
|
public ActionsFragment() {
|
||||||
super();
|
super();
|
||||||
|
@ -64,13 +64,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
try {
|
try {
|
||||||
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
||||||
|
|
||||||
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
profileSwitch = (SingleClickButton) view.findViewById(R.id.actions_profileswitch);
|
||||||
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
tempTarget = (SingleClickButton) view.findViewById(R.id.actions_temptarget);
|
||||||
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
extendedBolus = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus);
|
||||||
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
extendedBolusCancel = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||||
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
tempBasal = (SingleClickButton) view.findViewById(R.id.actions_settempbasal);
|
||||||
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
tempBasalCancel = (SingleClickButton) view.findViewById(R.id.actions_canceltempbasal);
|
||||||
fill = (Button) view.findViewById(R.id.actions_fill);
|
fill = (SingleClickButton) view.findViewById(R.id.actions_fill);
|
||||||
|
|
||||||
profileSwitch.setOnClickListener(this);
|
profileSwitch.setOnClickListener(this);
|
||||||
tempTarget.setOnClickListener(this);
|
tempTarget.setOnClickListener(this);
|
||||||
|
@ -127,8 +127,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1;
|
if (!pump.getPumpDescription().isSetBasalProfileCapable || !pump.isInitialized() || pump.isSuspended())
|
||||||
if (!pump.getPumpDescription().isSetBasalProfileCapable || !pump.isInitialized() || pump.isSuspended() || !allowProfileSwitch)
|
|
||||||
profileSwitch.setVisibility(View.GONE);
|
profileSwitch.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
profileSwitch.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -100,6 +100,9 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) {
|
if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) {
|
||||||
divider.setVisibility(View.GONE);
|
divider.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,10 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
|
|
||||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
setCancelable(true);
|
||||||
public void onResume() {
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
super.onResume();
|
return view;
|
||||||
if (getDialog() != null)
|
|
||||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -102,6 +102,9 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
||||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
basalTypeRadioGroup.setOnCheckedChangeListener(this);
|
basalTypeRadioGroup.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +158,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (setAsPercent) {
|
if (setAsPercent) {
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, callback);
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, true, callback);
|
||||||
} else {
|
} else {
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback);
|
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSpinner.setAdapter(adapter);
|
profileSpinner.setAdapter(adapter);
|
||||||
// set selected to actual profile
|
// set selected to actual profile
|
||||||
for (int p = 0; p < profileList.size(); p++) {
|
for (int p = 0; p < profileList.size(); p++) {
|
||||||
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName()))
|
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName(false)))
|
||||||
profileSpinner.setSelection(p);
|
profileSpinner.setSelection(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +360,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +534,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (options.eventType == R.id.careportal_combobolus) {
|
if (options.eventType == R.id.careportal_combobolus) {
|
||||||
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||||
data.put("enteredinsulin", enteredInsulin);
|
data.put("enteredinsulin", enteredInsulin);
|
||||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100);
|
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editSplit.getText()) / 100);
|
||||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
|
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
|
@ -16,9 +16,9 @@ import info.nightscout.androidaps.Config;
|
||||||
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.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
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.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;
|
||||||
|
@ -38,8 +38,8 @@ import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
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.plugins.Overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
|
@ -482,8 +482,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAMAModeEnabled() {
|
public boolean isAMAModeEnabled() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
boolean result = SP.getBoolean("openapsama_useautosens", false);
|
||||||
boolean result = preferences.getBoolean("openapsama_useautosens", false);
|
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
|
@ -494,6 +493,19 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
boolean result = true; // TODO update for SMB // SP.getBoolean("openapsama_useautosens", false);
|
||||||
|
|
||||||
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
|
for (PluginBase p : constraintsPlugins) {
|
||||||
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
|
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||||
|
result = result && constrain.isSMBModeEnabled();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
Double rateAfterConstrain = absoluteRate;
|
Double rateAfterConstrain = absoluteRate;
|
||||||
|
@ -736,6 +748,10 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
return getProfileName(System.currentTimeMillis());
|
return getProfileName(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfileName(boolean customized) {
|
||||||
|
return getProfileName(System.currentTimeMillis(), customized);
|
||||||
|
}
|
||||||
|
|
||||||
public String getProfileName(long time) {
|
public String getProfileName(long time) {
|
||||||
return getProfileName(time, true);
|
return getProfileName(time, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,15 @@ import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,14 +158,37 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
RequirementResult requirementsMet(Integer objNum) {
|
RequirementResult requirementsMet(Integer objNum) {
|
||||||
switch (objNum) {
|
switch (objNum) {
|
||||||
case 0:
|
case 0:
|
||||||
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
|
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP);
|
||||||
|
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
|
||||||
|
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
|
||||||
|
boolean hasBGData = DatabaseHelper.lastBg()!=null;
|
||||||
|
|
||||||
|
boolean apsEnabled = false;
|
||||||
|
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||||
|
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS))
|
||||||
|
apsEnabled = true;
|
||||||
|
|
||||||
|
return new RequirementResult(hasBGData&&bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
|
||||||
MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
|
MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
|
||||||
+ " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS));
|
+ "\n" + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission())
|
||||||
|
+ (isVirtualPump ? "\n" + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
|
||||||
|
+ "\n" + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
|
||||||
|
+ "\n" + MainApp.sResources.getString(R.string.hasbgdata) + ": " + yesOrNo(hasBGData)
|
||||||
|
+ "\n" + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
|
||||||
|
+ "\n" + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
|
||||||
|
);
|
||||||
case 1:
|
case 1:
|
||||||
return new RequirementResult(manualEnacts >= manualEnactsNeeded,
|
return new RequirementResult(manualEnacts >= manualEnactsNeeded,
|
||||||
MainApp.sResources.getString(R.string.objectives_manualenacts) + ": " + manualEnacts + "/" + manualEnactsNeeded);
|
MainApp.sResources.getString(R.string.objectives_manualenacts) + ": " + manualEnacts + "/" + manualEnactsNeeded);
|
||||||
case 2:
|
case 2:
|
||||||
return new RequirementResult(true, "");
|
return new RequirementResult(true, "");
|
||||||
|
case 3:
|
||||||
|
boolean closedModeEnabled = SafetyPlugin.getPlugin().isClosedModeEnabled();
|
||||||
|
return new RequirementResult(closedModeEnabled, MainApp.sResources.getString(R.string.closedmodeenabled) + ": " + yesOrNo(closedModeEnabled));
|
||||||
|
case 4:
|
||||||
|
double maxIOB = MainApp.getConfigBuilder().applyMaxIOBConstraints(1000d);
|
||||||
|
boolean maxIobSet = maxIOB > 0;
|
||||||
|
return new RequirementResult(maxIobSet, MainApp.sResources.getString(R.string.maxiobset) + ": " + yesOrNo(maxIobSet));
|
||||||
default:
|
default:
|
||||||
return new RequirementResult(true, "");
|
return new RequirementResult(true, "");
|
||||||
}
|
}
|
||||||
|
@ -212,7 +241,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
MainApp.sResources.getString(R.string.objectives_6_objective),
|
MainApp.sResources.getString(R.string.objectives_6_objective),
|
||||||
"",
|
"",
|
||||||
new Date(0),
|
new Date(0),
|
||||||
14,
|
28,
|
||||||
|
new Date(0)));
|
||||||
|
objectives.add(new Objective(7,
|
||||||
|
MainApp.sResources.getString(R.string.objectives_7_objective),
|
||||||
|
"",
|
||||||
|
new Date(0),
|
||||||
|
28,
|
||||||
new Date(0)));
|
new Date(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +295,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public boolean isLoopEnabled() {
|
public boolean isLoopEnabled() {
|
||||||
return objectives.get(1).started.getTime() > 0;
|
return objectives.get(0).started.getTime() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -278,6 +313,11 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
return objectives.get(6).started.getTime() > 0;
|
return objectives.get(6).started.getTime() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return objectives.get(7).started.getTime() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double applyMaxIOBConstraints(Double maxIob) {
|
public Double applyMaxIOBConstraints(Double maxIob) {
|
||||||
if (objectives.get(4).started.getTime() > 0 || objectives.get(2).accomplished.getTime() == 0)
|
if (objectives.get(4).started.getTime() > 0 || objectives.get(2).accomplished.getTime() == 0)
|
||||||
|
|
|
@ -116,6 +116,11 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
Double origAbsoluteRate = absoluteRate;
|
Double origAbsoluteRate = absoluteRate;
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
|
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
|
||||||
Iob result = new Iob();
|
Iob result = new Iob();
|
||||||
|
|
||||||
double scaleFactor = 3.0 / dia;
|
double scaleFactor = 3.0 / dia;
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
|
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
|
||||||
Iob result = new Iob();
|
Iob result = new Iob();
|
||||||
|
|
||||||
//Double scaleFactor = 3.0 / dia;
|
//Double scaleFactor = 3.0 / dia;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
|
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
|
||||||
Iob result = new Iob();
|
Iob result = new Iob();
|
||||||
|
|
||||||
int peak = getPeak();
|
int peak = getPeak();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.IobCobCalculator.events;
|
package info.nightscout.androidaps.plugins.IobCobCalculator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 10.06.2017.
|
* Created by mike on 10.06.2017.
|
|
@ -31,7 +31,6 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
|
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||||
|
|
||||||
|
@ -364,6 +363,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
// check if data already exists
|
// check if data already exists
|
||||||
long bgTime = bucketed_data.get(i).date;
|
long bgTime = bucketed_data.get(i).date;
|
||||||
bgTime = roundUpTime(bgTime);
|
bgTime = roundUpTime(bgTime);
|
||||||
|
if (bgTime > System.currentTimeMillis())
|
||||||
|
continue;
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
|
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
|
||||||
|
|
||||||
AutosensData existing;
|
AutosensData existing;
|
||||||
|
@ -544,6 +545,10 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
|
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
|
if (time > now) {
|
||||||
|
// data may not be calculated yet, use last data
|
||||||
|
return getLastAutosensData();
|
||||||
|
}
|
||||||
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -555,7 +560,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
if (autosensDataTable.size() < 1)
|
if (autosensDataTable.size() < 1)
|
||||||
return null;
|
return null;
|
||||||
AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1);
|
AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1);
|
||||||
if (data.time < System.currentTimeMillis() - 5 * 60 * 1000) {
|
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -259,18 +259,6 @@ public class LoopPlugin implements PluginBase {
|
||||||
if (!isEnabled(PluginBase.LOOP))
|
if (!isEnabled(PluginBase.LOOP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isSuspended()) {
|
|
||||||
log.debug(MainApp.sResources.getString(R.string.loopsuspended));
|
|
||||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pump.isSuspended()) {
|
|
||||||
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
|
|
||||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().getProfile() == null) {
|
if (MainApp.getConfigBuilder().getProfile() == null) {
|
||||||
log.debug(MainApp.sResources.getString(R.string.noprofileselected));
|
log.debug(MainApp.sResources.getString(R.string.noprofileselected));
|
||||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
|
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
|
||||||
|
@ -280,7 +268,7 @@ public class LoopPlugin implements PluginBase {
|
||||||
// Check if pump info is loaded
|
// Check if pump info is loaded
|
||||||
if (pump.getBaseBasalRate() < 0.01d) return;
|
if (pump.getBaseBasalRate() < 0.01d) return;
|
||||||
|
|
||||||
APSInterface usedAPS = MainApp.getConfigBuilder().getActiveAPS();
|
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
||||||
usedAPS.invoke(initiator);
|
usedAPS.invoke(initiator);
|
||||||
result = usedAPS.getLastAPSResult();
|
result = usedAPS.getLastAPSResult();
|
||||||
|
@ -303,6 +291,20 @@ public class LoopPlugin implements PluginBase {
|
||||||
lastRun.source = ((PluginBase) usedAPS).getName();
|
lastRun.source = ((PluginBase) usedAPS).getName();
|
||||||
lastRun.setByPump = null;
|
lastRun.setByPump = null;
|
||||||
|
|
||||||
|
NSUpload.uploadDeviceStatus();
|
||||||
|
|
||||||
|
if (isSuspended()) {
|
||||||
|
log.debug(MainApp.sResources.getString(R.string.loopsuspended));
|
||||||
|
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopsuspended)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pump.isSuspended()) {
|
||||||
|
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
|
||||||
|
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (constraintsInterface.isClosedModeEnabled()) {
|
if (constraintsInterface.isClosedModeEnabled()) {
|
||||||
if (result.changeRequested) {
|
if (result.changeRequested) {
|
||||||
final PumpEnactResult waiting = new PumpEnactResult();
|
final PumpEnactResult waiting = new PumpEnactResult();
|
||||||
|
@ -363,7 +365,6 @@ public class LoopPlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventLoopUpdateGui());
|
MainApp.bus().post(new EventLoopUpdateGui());
|
||||||
NSUpload.uploadDeviceStatus();
|
|
||||||
} finally {
|
} finally {
|
||||||
if (Config.logFunctionCalls)
|
if (Config.logFunctionCalls)
|
||||||
log.debug("invoke end");
|
log.debug("invoke end");
|
||||||
|
|
|
@ -222,4 +222,8 @@ public class NSClientInternalPlugin implements PluginBase {
|
||||||
public String url() {
|
public String url() {
|
||||||
return NSClientService.nsURL;
|
return NSClientService.nsURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasWritePermission() {
|
||||||
|
return nsClientService.hasWriteAuth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,8 @@ public class UploadQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeID(final String action, final String _id) {
|
public static void removeID(final String action, final String _id) {
|
||||||
|
if (_id == null || _id.equals(""))
|
||||||
|
return;
|
||||||
startService();
|
startService();
|
||||||
if (NSClientService.handler != null) {
|
if (NSClientService.handler != null) {
|
||||||
NSClientService.handler.post(new Runnable() {
|
NSClientService.handler.post(new Runnable() {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
|
package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.TransactionTooLargeException;
|
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -19,9 +16,7 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.ToastUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 20.02.2016.
|
* Created by mike on 20.02.2016.
|
||||||
|
@ -29,31 +24,32 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class BroadcastTreatment {
|
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(JSONObject treatment, boolean isDelta, boolean isLocalBypass) {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.getData().toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
bundle.putBoolean("islocal", isLocalBypass);
|
||||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
bundle = new Bundle();
|
bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.getData().toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
public static void handleNewTreatment(JSONArray treatments, boolean isDelta) {
|
||||||
|
|
||||||
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();
|
||||||
bundle.putString("treatments", part.toString());
|
bundle.putString("treatments", part.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
@ -63,21 +59,21 @@ public class BroadcastTreatment {
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)){
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
splitted = splitArray(treatments);
|
splitted = splitArray(treatments);
|
||||||
for (JSONArray part: splitted) {
|
for (JSONArray part : splitted) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatments", part.toString());
|
bundle.putString("treatments", part.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
|
public void handleChangedTreatment(JSONObject treatment, boolean isDelta) {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
|
@ -88,18 +84,18 @@ public class BroadcastTreatment {
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
bundle = new Bundle();
|
bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
public static void handleChangedTreatment(JSONArray treatments, boolean isDelta) {
|
||||||
|
|
||||||
List<JSONArray> splitted = splitArray(treatments);
|
List<JSONArray> splitted = splitArray(treatments);
|
||||||
for (JSONArray part : splitted) {
|
for (JSONArray part : splitted) {
|
||||||
|
@ -112,7 +108,7 @@ public class BroadcastTreatment {
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
splitted = splitArray(treatments);
|
splitted = splitArray(treatments);
|
||||||
for (JSONArray part : splitted) {
|
for (JSONArray part : splitted) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
@ -121,12 +117,12 @@ public class BroadcastTreatment {
|
||||||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
|
public static void handleRemovedTreatment(JSONObject treatment, boolean isDelta) {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
|
@ -137,18 +133,18 @@ public class BroadcastTreatment {
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
bundle = new Bundle();
|
bundle = new Bundle();
|
||||||
bundle.putString("treatment", treatment.toString());
|
bundle.putString("treatment", treatment.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
|
public static void handleRemovedTreatment(JSONArray treatments, boolean isDelta) {
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("treatments", treatments.toString());
|
bundle.putString("treatments", treatments.toString());
|
||||||
|
@ -159,14 +155,14 @@ public class BroadcastTreatment {
|
||||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
|
||||||
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
bundle = new Bundle();
|
bundle = new Bundle();
|
||||||
bundle.putString("treatments", treatments.toString());
|
bundle.putString("treatments", treatments.toString());
|
||||||
bundle.putBoolean("delta", isDelta);
|
bundle.putBoolean("delta", isDelta);
|
||||||
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
MainApp.instance().getApplicationContext().sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,5 +63,6 @@ public class NSSgv {
|
||||||
public Long getMills () { return getLongOrNull("mills"); }
|
public Long getMills () { return getLongOrNull("mills"); }
|
||||||
public String getDevice () { return getStringOrNull("device"); }
|
public String getDevice () { return getStringOrNull("device"); }
|
||||||
public String getDirection () { return getStringOrNull("direction"); }
|
public String getDirection () { return getStringOrNull("direction"); }
|
||||||
|
public String getId () { return getStringOrNull("_id"); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,14 @@ import org.json.JSONObject;
|
||||||
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.db.DbRequest;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
import info.nightscout.androidaps.db.DbRequest;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class DBAccessReceiver extends BroadcastReceiver {
|
public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
|
@ -32,14 +30,6 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
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,
|
||||||
DBAccessReceiver.class.getSimpleName());
|
DBAccessReceiver.class.getSimpleName());
|
||||||
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
|
||||||
if (!nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SP.getBoolean(R.string.key_ns_noupload, false)) {
|
|
||||||
log.debug("Upload disabled. Message dropped");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
try {
|
try {
|
||||||
Bundle bundles = intent.getExtras();
|
Bundle bundles = intent.getExtras();
|
||||||
|
@ -85,11 +75,22 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.equals("dbRemove")) {
|
if (action.equals("dbRemove")) {
|
||||||
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), _id);
|
if (shouldUpload()) {
|
||||||
UploadQueue.add(dbr);
|
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), _id);
|
||||||
|
UploadQueue.add(dbr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), data);
|
DbRequest dbr = new DbRequest(action, collection, nsclientid.toString(), data);
|
||||||
UploadQueue.add(dbr);
|
// this is not used as mongo _id but only for searching in UploadQueue database
|
||||||
|
// if record has to be removed from queue before upload
|
||||||
|
dbr._id = nsclientid.toString();
|
||||||
|
|
||||||
|
if (shouldUpload()) {
|
||||||
|
UploadQueue.add(dbr);
|
||||||
|
}
|
||||||
|
if (collection.equals("treatments")) {
|
||||||
|
genereateTreatmentOfflineBroadcast(dbr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -98,6 +99,24 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldUpload() {
|
||||||
|
NSClientInternalPlugin nsClientInternalPlugin = MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
|
||||||
|
return nsClientInternalPlugin.isEnabled(PluginBase.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void genereateTreatmentOfflineBroadcast(DbRequest request) {
|
||||||
|
if (request.action.equals("dbAdd")) {
|
||||||
|
try {
|
||||||
|
JSONObject data = new JSONObject(request.data);
|
||||||
|
data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime());
|
||||||
|
data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id
|
||||||
|
BroadcastTreatment.handleNewTreatment(data, false, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Unhadled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isAllowedCollection(String collection) {
|
private boolean isAllowedCollection(String collection) {
|
||||||
// "treatments" || "entries" || "devicestatus" || "profile" || "food"
|
// "treatments" || "entries" || "devicestatus" || "profile" || "food"
|
||||||
if (collection.equals("treatments")) return true;
|
if (collection.equals("treatments")) return true;
|
||||||
|
|
|
@ -52,15 +52,15 @@ import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastS
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastUrgentAlarm;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastUrgentAlarm;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
|
@ -114,6 +114,18 @@ public class NSClientService extends Service {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
mWakeLock.acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mWakeLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
public class LocalBinder extends Binder {
|
public class LocalBinder extends Binder {
|
||||||
public NSClientService getServiceInstance() {
|
public NSClientService getServiceInstance() {
|
||||||
return NSClientService.this;
|
return NSClientService.this;
|
||||||
|
@ -182,8 +194,6 @@ public class NSClientService extends Service {
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
dataCounter = 0;
|
dataCounter = 0;
|
||||||
|
|
||||||
NSClientService.mWakeLock.acquire();
|
|
||||||
|
|
||||||
readPreferences();
|
readPreferences();
|
||||||
|
|
||||||
if (!nsAPISecret.equals(""))
|
if (!nsAPISecret.equals(""))
|
||||||
|
@ -221,7 +231,6 @@ public class NSClientService extends Service {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Not configured"));
|
MainApp.bus().post(new EventNSClientStatus("Not configured"));
|
||||||
}
|
}
|
||||||
NSClientService.mWakeLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emitter.Listener onConnect = new Emitter.Listener() {
|
private Emitter.Listener onConnect = new Emitter.Listener() {
|
||||||
|
@ -242,6 +251,15 @@ public class NSClientService extends Service {
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (mSocket != null) {
|
if (mSocket != null) {
|
||||||
|
mSocket.off(Socket.EVENT_CONNECT);
|
||||||
|
mSocket.off(Socket.EVENT_DISCONNECT);
|
||||||
|
mSocket.off(Socket.EVENT_PING);
|
||||||
|
mSocket.off("dataUpdate");
|
||||||
|
mSocket.off("announcement");
|
||||||
|
mSocket.off("alarm");
|
||||||
|
mSocket.off("urgent_alarm");
|
||||||
|
mSocket.off("clear_alarm");
|
||||||
|
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy"));
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
hasWriteAuth = false;
|
hasWriteAuth = false;
|
||||||
|
@ -310,17 +328,17 @@ public class NSClientService extends Service {
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
private Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"level":0,
|
"level":0,
|
||||||
"title":"Announcement",
|
"title":"Announcement",
|
||||||
"message":"test",
|
"message":"test",
|
||||||
"plugin":{"name":"treatmentnotify","label":"Treatment Notifications","pluginType":"notification","enabled":true},
|
"plugin":{"name":"treatmentnotify","label":"Treatment Notifications","pluginType":"notification","enabled":true},
|
||||||
"group":"Announcement",
|
"group":"Announcement",
|
||||||
"isAnnouncement":true,
|
"isAnnouncement":true,
|
||||||
"key":"9ac46ad9a1dcda79dd87dae418fce0e7955c68da"
|
"key":"9ac46ad9a1dcda79dd87dae418fce0e7955c68da"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
JSONObject data;
|
JSONObject data;
|
||||||
|
@ -342,19 +360,19 @@ public class NSClientService extends Service {
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onAlarm = new Emitter.Listener() {
|
private Emitter.Listener onAlarm = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"level":1,
|
"level":1,
|
||||||
"title":"Warning HIGH",
|
"title":"Warning HIGH",
|
||||||
"message":"BG Now: 5 -0.2 → mmol\/L\nRaw BG: 4.8 mmol\/L Čistý\nBG 15m: 4.8 mmol\/L\nIOB: -0.02U\nCOB: 0g",
|
"message":"BG Now: 5 -0.2 → mmol\/L\nRaw BG: 4.8 mmol\/L Čistý\nBG 15m: 4.8 mmol\/L\nIOB: -0.02U\nCOB: 0g",
|
||||||
"eventName":"high",
|
"eventName":"high",
|
||||||
"plugin":{"name":"simplealarms","label":"Simple Alarms","pluginType":"notification","enabled":true},
|
"plugin":{"name":"simplealarms","label":"Simple Alarms","pluginType":"notification","enabled":true},
|
||||||
"pushoverSound":"climb",
|
"pushoverSound":"climb",
|
||||||
"debug":{"lastSGV":5,"thresholds":{"bgHigh":180,"bgTargetTop":75,"bgTargetBottom":72,"bgLow":70}},
|
"debug":{"lastSGV":5,"thresholds":{"bgHigh":180,"bgTargetTop":75,"bgTargetBottom":72,"bgLow":70}},
|
||||||
"group":"default",
|
"group":"default",
|
||||||
"key":"simplealarms_1"
|
"key":"simplealarms_1"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
if (Config.detailedLog)
|
if (Config.detailedLog)
|
||||||
|
@ -372,19 +390,19 @@ public class NSClientService extends Service {
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onUrgentAlarm = new Emitter.Listener() {
|
private Emitter.Listener onUrgentAlarm = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"level":2,
|
"level":2,
|
||||||
"title":"Urgent HIGH",
|
"title":"Urgent HIGH",
|
||||||
"message":"BG Now: 5.2 -0.1 → mmol\/L\nRaw BG: 5 mmol\/L Čistý\nBG 15m: 5 mmol\/L\nIOB: 0.00U\nCOB: 0g",
|
"message":"BG Now: 5.2 -0.1 → mmol\/L\nRaw BG: 5 mmol\/L Čistý\nBG 15m: 5 mmol\/L\nIOB: 0.00U\nCOB: 0g",
|
||||||
"eventName":"high",
|
"eventName":"high",
|
||||||
"plugin":{"name":"simplealarms","label":"Simple Alarms","pluginType":"notification","enabled":true},
|
"plugin":{"name":"simplealarms","label":"Simple Alarms","pluginType":"notification","enabled":true},
|
||||||
"pushoverSound":"persistent",
|
"pushoverSound":"persistent",
|
||||||
"debug":{"lastSGV":5.2,"thresholds":{"bgHigh":80,"bgTargetTop":75,"bgTargetBottom":72,"bgLow":70}},
|
"debug":{"lastSGV":5.2,"thresholds":{"bgHigh":80,"bgTargetTop":75,"bgTargetBottom":72,"bgLow":70}},
|
||||||
"group":"default",
|
"group":"default",
|
||||||
"key":"simplealarms_2"
|
"key":"simplealarms_2"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
JSONObject data;
|
JSONObject data;
|
||||||
|
@ -402,14 +420,14 @@ public class NSClientService extends Service {
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
private Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"clear":true,
|
"clear":true,
|
||||||
"title":"All Clear",
|
"title":"All Clear",
|
||||||
"message":"default - Urgent was ack'd",
|
"message":"default - Urgent was ack'd",
|
||||||
"group":"default"
|
"group":"default"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
JSONObject data;
|
JSONObject data;
|
||||||
|
@ -520,17 +538,17 @@ public class NSClientService extends Service {
|
||||||
updatedTreatments.put(jsonTreatment);
|
updatedTreatments.put(jsonTreatment);
|
||||||
} else if (treatment.getAction().equals("remove")) {
|
} else if (treatment.getAction().equals("remove")) {
|
||||||
if (treatment.getMills() != null && treatment.getMills() > System.currentTimeMillis() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only
|
if (treatment.getMills() != null && treatment.getMills() > System.currentTimeMillis() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only
|
||||||
removedTreatments.put(jsonTreatment);
|
removedTreatments.put(jsonTreatment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (removedTreatments.length() > 0) {
|
if (removedTreatments.length() > 0) {
|
||||||
BroadcastTreatment.handleRemovedTreatment(removedTreatments, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastTreatment.handleRemovedTreatment(removedTreatments, isDelta);
|
||||||
}
|
}
|
||||||
if (updatedTreatments.length() > 0) {
|
if (updatedTreatments.length() > 0) {
|
||||||
BroadcastTreatment.handleChangedTreatment(updatedTreatments, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastTreatment.handleChangedTreatment(updatedTreatments, isDelta);
|
||||||
}
|
}
|
||||||
if (addedTreatments.length() > 0) {
|
if (addedTreatments.length() > 0) {
|
||||||
BroadcastTreatment.handleNewTreatment(addedTreatments, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastTreatment.handleNewTreatment(addedTreatments, isDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.has("devicestatus")) {
|
if (data.has("devicestatus")) {
|
||||||
|
@ -634,9 +652,9 @@ public class NSClientService extends Service {
|
||||||
}
|
}
|
||||||
// Was that sgv more less 15 mins ago ?
|
// Was that sgv more less 15 mins ago ?
|
||||||
boolean lessThan15MinAgo = false;
|
boolean lessThan15MinAgo = false;
|
||||||
if((System.currentTimeMillis()-latestDateInReceivedData)/(60 * 1000L) < 15L )
|
if ((System.currentTimeMillis() - latestDateInReceivedData) / (60 * 1000L) < 15L)
|
||||||
lessThan15MinAgo = true;
|
lessThan15MinAgo = true;
|
||||||
if(Notification.isAlarmForStaleData() && lessThan15MinAgo){
|
if (Notification.isAlarmForStaleData() && lessThan15MinAgo) {
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.NSALARM));
|
MainApp.bus().post(new EventDismissNotification(Notification.NSALARM));
|
||||||
}
|
}
|
||||||
BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
|
@ -757,7 +775,7 @@ public class NSClientService extends Service {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mSocket == null || !mSocket.connected()) return;
|
if (mSocket == null || !mSocket.connected()) return;
|
||||||
|
|
||||||
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
|
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
|
||||||
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,9 +248,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
determineBasalResultAMA.changeRequested = false;
|
determineBasalResultAMA.changeRequested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
|
if (MainApp.getConfigBuilder().isTempBasalInProgress() && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
|
||||||
|
// going to cancel
|
||||||
|
} else if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) {
|
||||||
determineBasalResultAMA.changeRequested = false;
|
determineBasalResultAMA.changeRequested = false;
|
||||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
} else if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
||||||
determineBasalResultAMA.changeRequested = false;
|
determineBasalResultAMA.changeRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,9 +232,11 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
determineBasalResultMA.changeRequested = false;
|
determineBasalResultMA.changeRequested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
|
if (MainApp.getConfigBuilder().isTempBasalInProgress() && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
|
||||||
|
// going to cancel
|
||||||
|
} else if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) {
|
||||||
determineBasalResultMA.changeRequested = false;
|
determineBasalResultMA.changeRequested = false;
|
||||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
} else if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
||||||
determineBasalResultMA.changeRequested = false;
|
determineBasalResultMA.changeRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
|
||||||
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
|
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
|
||||||
unitsView.setText(units);
|
unitsView.setText(units);
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
@ -17,13 +16,13 @@ import org.json.JSONException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
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.QuickWizard;
|
||||||
|
import info.nightscout.androidaps.data.QuickWizardEntry;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.QuickWizard;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
|
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
@ -31,19 +30,25 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener {
|
public class EditQuickWizardDialog extends DialogFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(EditQuickWizardDialog.class);
|
private static Logger log = LoggerFactory.getLogger(EditQuickWizardDialog.class);
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry entry = new QuickWizard().newEmptyItem();
|
QuickWizardEntry entry = new QuickWizard().newEmptyItem();
|
||||||
QuickWizard quickWizard = MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard;
|
QuickWizard quickWizard = MainApp.getSpecificPlugin(OverviewPlugin.class).quickWizard;
|
||||||
|
|
||||||
EditText buttonEdit;
|
EditText buttonEdit;
|
||||||
EditText carbsEdit;
|
EditText carbsEdit;
|
||||||
Spinner fromSpinner;
|
Spinner fromSpinner;
|
||||||
Spinner toSpinner;
|
Spinner toSpinner;
|
||||||
Button okButton;
|
Spinner useBGSpinner;
|
||||||
|
Spinner useCOBSpinner;
|
||||||
|
Spinner useBolusIOBSpinner;
|
||||||
|
Spinner useBasalIOBSpinner;
|
||||||
|
Spinner useTrendSpinner;
|
||||||
|
Spinner useSuperBolusSpinner;
|
||||||
|
Spinner useTempTargetSpinner;
|
||||||
|
|
||||||
public EditQuickWizardDialog() {
|
public EditQuickWizardDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(QuickWizard.QuickWizardEntry data) {
|
public void setData(QuickWizardEntry data) {
|
||||||
entry = data;
|
entry = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +63,16 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
|
||||||
carbsEdit = (EditText) view.findViewById(R.id.overview_editquickwizard_carbs_edit);
|
carbsEdit = (EditText) view.findViewById(R.id.overview_editquickwizard_carbs_edit);
|
||||||
fromSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_from_spinner);
|
fromSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_from_spinner);
|
||||||
toSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_to_spinner);
|
toSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_to_spinner);
|
||||||
okButton = (Button) view.findViewById(R.id.overview_editquickwizard_ok_button);
|
useBGSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebg_spinner);
|
||||||
okButton.setOnClickListener(this);
|
useCOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usecob_spinner);
|
||||||
|
useBolusIOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebolusiob_spinner);
|
||||||
|
useBasalIOBSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usebasaliob_spinner);
|
||||||
|
useTrendSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usetrend_spinner);
|
||||||
|
useSuperBolusSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usesuperbolus_spinner);
|
||||||
|
useTempTargetSpinner = (Spinner) view.findViewById(R.id.overview_editquickwizard_usetemptarget_spinner);
|
||||||
|
|
||||||
|
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||||
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
|
|
||||||
int posFrom = 0;
|
int posFrom = 0;
|
||||||
int posTo = 95;
|
int posTo = 95;
|
||||||
|
@ -83,6 +96,14 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
|
||||||
fromSpinner.setSelection(posFrom);
|
fromSpinner.setSelection(posFrom);
|
||||||
toSpinner.setSelection(posTo);
|
toSpinner.setSelection(posTo);
|
||||||
|
|
||||||
|
setSelection(useBGSpinner, entry.useBG());
|
||||||
|
setSelection(useCOBSpinner, entry.useCOB());
|
||||||
|
setSelection(useBolusIOBSpinner, entry.useBolusIOB());
|
||||||
|
setSelection(useBasalIOBSpinner, entry.useBasalIOB());
|
||||||
|
setSelection(useTrendSpinner, entry.useTrend());
|
||||||
|
setSelection(useSuperBolusSpinner, entry.useSuperBolus());
|
||||||
|
setSelection(useTempTargetSpinner, entry.useTempTarget());
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +117,7 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.overview_editquickwizard_ok_button:
|
case R.id.ok:
|
||||||
if (fromSpinner.getSelectedItem() == null) return;
|
if (fromSpinner.getSelectedItem() == null) return;
|
||||||
if (toSpinner.getSelectedItem() == null) return;
|
if (toSpinner.getSelectedItem() == null) return;
|
||||||
try {
|
try {
|
||||||
|
@ -106,13 +127,64 @@ public class EditQuickWizardDialog extends DialogFragment implements View.OnClic
|
||||||
entry.storage.put("validFrom", validFromInt);
|
entry.storage.put("validFrom", validFromInt);
|
||||||
int validToInt = DateUtil.toSeconds(toSpinner.getSelectedItem().toString());
|
int validToInt = DateUtil.toSeconds(toSpinner.getSelectedItem().toString());
|
||||||
entry.storage.put("validTo", validToInt);
|
entry.storage.put("validTo", validToInt);
|
||||||
|
entry.storage.put("useBG", getSelection(useBGSpinner));
|
||||||
|
entry.storage.put("useCOB", getSelection(useCOBSpinner));
|
||||||
|
entry.storage.put("useBolusIOB", getSelection(useBolusIOBSpinner));
|
||||||
|
entry.storage.put("useBasalIOB", getSelection(useBasalIOBSpinner));
|
||||||
|
entry.storage.put("useTrend", getSelection(useTrendSpinner));
|
||||||
|
entry.storage.put("useSuperBolus", getSelection(useSuperBolusSpinner));
|
||||||
|
entry.storage.put("useTempTarget", getSelection(useTempTargetSpinner));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
quickWizard.addOrUpdate(entry);
|
quickWizard.addOrUpdate(entry);
|
||||||
dismiss();
|
dismiss();
|
||||||
MainApp.bus().post(new EventQuickWizardChange());
|
MainApp.bus().post(new EventQuickWizardChange());
|
||||||
break;
|
break;
|
||||||
|
case R.id.cancel:
|
||||||
|
dismiss();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSelection(Spinner spinner) {
|
||||||
|
String value = spinner.getSelectedItem().toString();
|
||||||
|
if (value.equals(MainApp.sResources.getString(R.string.yes)))
|
||||||
|
return QuickWizardEntry.YES;
|
||||||
|
if (value.equals(MainApp.sResources.getString(R.string.no)))
|
||||||
|
return QuickWizardEntry.NO;
|
||||||
|
if (value.equals(MainApp.sResources.getString(R.string.positiveonly)))
|
||||||
|
return QuickWizardEntry.POSITIVE_ONLY;
|
||||||
|
if (value.equals(MainApp.sResources.getString(R.string.negativeonly)))
|
||||||
|
return QuickWizardEntry.NEGATIVE_ONLY;
|
||||||
|
return QuickWizardEntry.NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSelection(Spinner spinner, int value) {
|
||||||
|
String selection;
|
||||||
|
switch (value) {
|
||||||
|
case QuickWizardEntry.YES:
|
||||||
|
selection = MainApp.sResources.getString(R.string.yes);
|
||||||
|
break;
|
||||||
|
case QuickWizardEntry.NO:
|
||||||
|
selection = MainApp.sResources.getString(R.string.no);
|
||||||
|
break;
|
||||||
|
case QuickWizardEntry.POSITIVE_ONLY:
|
||||||
|
selection = MainApp.sResources.getString(R.string.positiveonly);
|
||||||
|
break;
|
||||||
|
case QuickWizardEntry.NEGATIVE_ONLY:
|
||||||
|
selection = MainApp.sResources.getString(R.string.negativeonly);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
selection = MainApp.sResources.getString(R.string.no);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < spinner.getCount(); i++) {
|
||||||
|
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(selection)) {
|
||||||
|
spinner.setSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
|
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
|
@ -102,7 +104,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
Integer calculatedCarbs = 0;
|
Integer calculatedCarbs = 0;
|
||||||
Double calculatedTotalInsulin = 0d;
|
Double calculatedTotalInsulin = 0d;
|
||||||
JSONObject boluscalcJSON;
|
JSONObject boluscalcJSON;
|
||||||
boolean cobAvailable = false;
|
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
@ -138,25 +139,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventOpenAPSUpdateGui e) {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
|
|
||||||
cobLayout.setVisibility(View.VISIBLE);
|
|
||||||
cobAvailable = true;
|
|
||||||
} else {
|
|
||||||
cobLayout.setVisibility(View.GONE);
|
|
||||||
cobAvailable = false;
|
|
||||||
}
|
|
||||||
calculateInsulin();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBG e) {
|
public void onStatusEvent(final EventNewBG e) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
|
@ -251,6 +233,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||||
initDialog();
|
initDialog();
|
||||||
|
|
||||||
|
setCancelable(true);
|
||||||
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +328,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
}
|
}
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 120, true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -438,14 +422,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
||||||
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
||||||
|
|
||||||
// COB only if AMA is selected
|
|
||||||
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
|
|
||||||
cobLayout.setVisibility(View.VISIBLE);
|
|
||||||
cobAvailable = true;
|
|
||||||
} else {
|
|
||||||
cobLayout.setVisibility(View.GONE);
|
|
||||||
cobAvailable = false;
|
|
||||||
}
|
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,13 +458,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
// COB
|
// COB
|
||||||
Double c_cob = 0d;
|
Double c_cob = 0d;
|
||||||
if (cobAvailable && cobCheckbox.isChecked()) {
|
if (cobCheckbox.isChecked()) {
|
||||||
if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
|
AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
|
||||||
try {
|
|
||||||
c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB"));
|
if(autosensData != null) {
|
||||||
} catch (JSONException e) {
|
c_cob = autosensData.cob;
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +504,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U");
|
bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U");
|
||||||
|
|
||||||
// COB
|
// COB
|
||||||
if (cobAvailable && cobCheckbox.isChecked()) {
|
if (cobCheckbox.isChecked()) {
|
||||||
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
|
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
|
||||||
cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U");
|
cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -52,7 +53,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -61,6 +61,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.data.QuickWizardEntry;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
@ -78,6 +79,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
|
@ -97,6 +99,7 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
||||||
|
@ -112,9 +115,10 @@ import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.OKDialog;
|
import info.nightscout.utils.OKDialog;
|
||||||
import info.nightscout.utils.Profiler;
|
import info.nightscout.utils.Profiler;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
import info.nightscout.utils.SingleClickButton;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, View.OnLongClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||||
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
|
@ -155,11 +159,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
LinearLayout acceptTempLayout;
|
LinearLayout acceptTempLayout;
|
||||||
Button treatmentButton;
|
SingleClickButton treatmentButton;
|
||||||
Button wizardButton;
|
SingleClickButton wizardButton;
|
||||||
Button calibrationButton;
|
SingleClickButton calibrationButton;
|
||||||
Button acceptTempButton;
|
SingleClickButton acceptTempButton;
|
||||||
Button quickWizardButton;
|
SingleClickButton quickWizardButton;
|
||||||
|
|
||||||
CheckBox lockScreen;
|
CheckBox lockScreen;
|
||||||
|
|
||||||
|
@ -175,6 +179,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Handler sLoopHandler = new Handler();
|
Handler sLoopHandler = new Handler();
|
||||||
Runnable sRefreshLoop = null;
|
Runnable sRefreshLoop = null;
|
||||||
|
|
||||||
|
final Object updateSync = new Object();
|
||||||
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledUpdate = null;
|
private static ScheduledFuture<?> scheduledUpdate = null;
|
||||||
|
|
||||||
|
@ -243,16 +249,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||||
|
|
||||||
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
treatmentButton = (SingleClickButton) view.findViewById(R.id.overview_treatmentbutton);
|
||||||
treatmentButton.setOnClickListener(this);
|
treatmentButton.setOnClickListener(this);
|
||||||
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
wizardButton = (SingleClickButton) view.findViewById(R.id.overview_wizardbutton);
|
||||||
wizardButton.setOnClickListener(this);
|
wizardButton.setOnClickListener(this);
|
||||||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
acceptTempButton = (SingleClickButton) view.findViewById(R.id.overview_accepttempbutton);
|
||||||
if (acceptTempButton != null)
|
if (acceptTempButton != null)
|
||||||
acceptTempButton.setOnClickListener(this);
|
acceptTempButton.setOnClickListener(this);
|
||||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
quickWizardButton = (SingleClickButton) view.findViewById(R.id.overview_quickwizardbutton);
|
||||||
quickWizardButton.setOnClickListener(this);
|
quickWizardButton.setOnClickListener(this);
|
||||||
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
|
quickWizardButton.setOnLongClickListener(this);
|
||||||
|
calibrationButton = (SingleClickButton) view.findViewById(R.id.overview_calibrationbutton);
|
||||||
if (calibrationButton != null)
|
if (calibrationButton != null)
|
||||||
calibrationButton.setOnClickListener(this);
|
calibrationButton.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -319,6 +326,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return view;
|
return view;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Crashlytics.logException(e);
|
Crashlytics.logException(e);
|
||||||
|
log.debug("Runtime Exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -330,6 +338,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
if (v == apsModeView) {
|
if (v == apsModeView) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
|
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
if (activeloop == null)
|
if (activeloop == null)
|
||||||
return;
|
return;
|
||||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
|
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
|
||||||
|
@ -340,7 +349,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
|
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
|
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
|
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
|
if (pumpDescription.tempDurationStep <= 30)
|
||||||
|
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
|
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
|
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
|
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
|
||||||
|
@ -479,7 +489,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
||||||
activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
|
activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 30, true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 30, true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -492,7 +502,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
||||||
activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
|
activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 60, true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 60, true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -505,7 +515,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
||||||
activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 2 * 60, true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 2 * 60, true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -518,7 +528,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
||||||
activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 3 * 60, true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 3 * 60, true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -573,6 +583,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.overview_quickwizardbutton:
|
||||||
|
Intent i = new Intent(v.getContext(), QuickWizardListActivity.class);
|
||||||
|
startActivity(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void onClickAcceptTemp() {
|
private void onClickAcceptTemp() {
|
||||||
if (ConfigBuilderPlugin.getActiveLoop() != null) {
|
if (ConfigBuilderPlugin.getActiveLoop() != null) {
|
||||||
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
|
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
|
||||||
|
@ -616,11 +637,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null) {
|
if (quickWizardEntry != null && actualBg != null) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
BolusWizard wizard = new BolusWizard();
|
final BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, actualBg);
|
||||||
wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
|
|
||||||
|
|
||||||
final JSONObject boluscalcJSON = new JSONObject();
|
final JSONObject boluscalcJSON = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
@ -679,6 +699,26 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
accepted = true;
|
accepted = true;
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
|
if (wizard.superBolus) {
|
||||||
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
|
if (activeloop != null) {
|
||||||
|
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
|
}
|
||||||
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!result.success) {
|
||||||
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
|
i.putExtra("status", result.comment);
|
||||||
|
i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
MainApp.instance().startActivity(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
|
@ -864,9 +904,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
public void updateGUI(String from) {
|
public void updateGUI(final String from) {
|
||||||
log.debug("updateGUI entered from: " + from);
|
log.debug("updateGUI entered from: " + from);
|
||||||
Date updateGUIStart = new Date();
|
final Date updateGUIStart = new Date();
|
||||||
|
|
||||||
if (getActivity() == null)
|
if (getActivity() == null)
|
||||||
return;
|
return;
|
||||||
|
@ -888,7 +928,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
BgReading actualBG = DatabaseHelper.actualBg();
|
BgReading actualBG = DatabaseHelper.actualBg();
|
||||||
BgReading lastBG = DatabaseHelper.lastBg();
|
BgReading lastBG = DatabaseHelper.lastBg();
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
@ -900,8 +940,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lowLine = SP.getDouble("low_mark", 0d);
|
double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
|
||||||
double highLine = SP.getDouble("high_mark", 0d);
|
double highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units));
|
||||||
|
|
||||||
|
if (lowLineSetting < 1)
|
||||||
|
lowLineSetting = Profile.fromMgdlToUnits(76d, units);
|
||||||
|
if (highLineSetting < 1)
|
||||||
|
highLineSetting = Profile.fromMgdlToUnits(180d, units);
|
||||||
|
|
||||||
|
final double lowLine = lowLineSetting;
|
||||||
|
final double highLine = highLineSetting;
|
||||||
|
|
||||||
//Start with updating the BG as it is unaffected by loop.
|
//Start with updating the BG as it is unaffected by loop.
|
||||||
// **** BG value ****
|
// **** BG value ****
|
||||||
|
@ -1083,12 +1131,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setLongClickable(true);
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, lastBG);
|
||||||
wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false);
|
|
||||||
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
||||||
quickWizardButton.setText(text);
|
quickWizardButton.setText(text);
|
||||||
if (wizard.calculatedTotalInsulin <= 0)
|
if (wizard.calculatedTotalInsulin <= 0)
|
||||||
|
@ -1106,16 +1153,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (lowLine < 1) {
|
|
||||||
lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
|
||||||
}
|
|
||||||
if (highLine < 1) {
|
|
||||||
highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
|
|
||||||
}
|
|
||||||
|
|
||||||
// **** BG value ****
|
// **** BG value ****
|
||||||
if (lastBG == null) { //left this here as it seems you want to exit at this point if it is null...
|
if (lastBG == null) { //left this here as it seems you want to exit at this point if it is null...
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer flag = bgView.getPaintFlags();
|
Integer flag = bgView.getPaintFlags();
|
||||||
|
@ -1162,13 +1201,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// cob
|
// cob
|
||||||
if (cobView != null) { // view must not exists
|
if (cobView != null) { // view must not exists
|
||||||
String cobText = "";
|
String cobText = "";
|
||||||
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
|
AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
|
||||||
if (autosensData != null)
|
if (autosensData != null)
|
||||||
cobText = (int) autosensData.cob + " g";
|
cobText = (int) autosensData.cob + " g";
|
||||||
cobView.setText(cobText);
|
cobView.setText(cobText);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
|
final boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
|
||||||
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
|
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
|
||||||
showPredictionView.setVisibility(View.VISIBLE);
|
showPredictionView.setVisibility(View.VISIBLE);
|
||||||
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
|
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
|
||||||
|
@ -1212,105 +1251,121 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
|
|
||||||
// allign to hours
|
new Thread(new Runnable() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
@Override
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
public void run() {
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
// allign to hours
|
||||||
calendar.set(Calendar.SECOND, 0);
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
calendar.add(Calendar.HOUR, 1);
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.add(Calendar.HOUR, 1);
|
||||||
|
|
||||||
int hoursToFetch;
|
int hoursToFetch;
|
||||||
long toTime;
|
final long toTime;
|
||||||
long fromTime;
|
final long fromTime;
|
||||||
long endTime;
|
final long endTime;
|
||||||
if (showPrediction) {
|
if (showPrediction) {
|
||||||
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
|
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
|
||||||
predHours = Math.min(2, predHours);
|
predHours = Math.min(2, predHours);
|
||||||
predHours = Math.max(0, predHours);
|
predHours = Math.max(0, predHours);
|
||||||
hoursToFetch = rangeToDisplay - predHours;
|
hoursToFetch = rangeToDisplay - predHours;
|
||||||
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
||||||
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
||||||
endTime = toTime + predHours * 60 * 60 * 1000L;
|
endTime = toTime + predHours * 60 * 60 * 1000L;
|
||||||
} else {
|
} else {
|
||||||
hoursToFetch = rangeToDisplay;
|
hoursToFetch = rangeToDisplay;
|
||||||
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
||||||
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
||||||
endTime = toTime;
|
endTime = toTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
|
||||||
// 2nd graph
|
// ------------------ 1st graph
|
||||||
// remove old data
|
Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
|
||||||
iobGraph.getSeries().clear();
|
|
||||||
|
|
||||||
GraphData secondGraphData = new GraphData();
|
final GraphData graphData = new GraphData(bgGraph);
|
||||||
|
|
||||||
boolean useIobForScale = false;
|
// **** In range Area ****
|
||||||
boolean useCobForScale = false;
|
graphData.addInRangeArea(fromTime, endTime, lowLine, highLine);
|
||||||
boolean useDevForScale = false;
|
|
||||||
boolean useRatioForScale = false;
|
|
||||||
|
|
||||||
if (showIobView.isChecked()) {
|
// **** BG ****
|
||||||
useIobForScale = true;
|
if (showPrediction)
|
||||||
} else if (showCobView.isChecked()) {
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, (DetermineBasalResultAMA) finalLastRun.constraintsProcessed);
|
||||||
useCobForScale = true;
|
else
|
||||||
} else if (showDeviationsView.isChecked()) {
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
||||||
useDevForScale = true;
|
|
||||||
} else if (showRatiosView.isChecked()) {
|
|
||||||
useRatioForScale = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showIobView.isChecked())
|
// set manual x bounds to have nice steps
|
||||||
secondGraphData.addIob(iobGraph, fromTime, now, useIobForScale, 1d);
|
graphData.formatAxis(fromTime, endTime);
|
||||||
if (showCobView.isChecked())
|
|
||||||
secondGraphData.addCob(iobGraph, fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d);
|
|
||||||
if (showDeviationsView.isChecked())
|
|
||||||
secondGraphData.addDeviations(iobGraph, fromTime, now, useDevForScale, 1d);
|
|
||||||
if (showRatiosView.isChecked())
|
|
||||||
secondGraphData.addRatio(iobGraph, fromTime, now, useRatioForScale, 1d);
|
|
||||||
|
|
||||||
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
|
// Treatments
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
graphData.addTreatments(fromTime, endTime);
|
||||||
} else {
|
|
||||||
iobGraph.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove old data from graph
|
// add basal data
|
||||||
bgGraph.getSeries().clear();
|
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
|
||||||
|
graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d);
|
||||||
|
}
|
||||||
|
|
||||||
GraphData graphData = new GraphData();
|
// **** NOW line ****
|
||||||
|
graphData.addNowLine(now);
|
||||||
|
|
||||||
// **** In range Area ****
|
// ------------------ 2nd graph
|
||||||
graphData.addInRangeArea(bgGraph, fromTime, endTime, lowLine, highLine);
|
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
|
||||||
|
|
||||||
// **** BG ****
|
final GraphData secondGraphData = new GraphData(iobGraph);
|
||||||
if (showPrediction)
|
|
||||||
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, (DetermineBasalResultAMA) finalLastRun.constraintsProcessed);
|
|
||||||
else
|
|
||||||
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, null);
|
|
||||||
|
|
||||||
// set manual x bounds to have nice steps
|
boolean useIobForScale = false;
|
||||||
graphData.formatAxis(bgGraph, fromTime, endTime);
|
boolean useCobForScale = false;
|
||||||
secondGraphData.formatAxis(iobGraph, fromTime, endTime);
|
boolean useDevForScale = false;
|
||||||
|
boolean useRatioForScale = false;
|
||||||
|
|
||||||
// Treatments
|
if (showIobView.isChecked()) {
|
||||||
graphData.addTreatments(bgGraph, fromTime, endTime);
|
useIobForScale = true;
|
||||||
|
} else if (showCobView.isChecked()) {
|
||||||
|
useCobForScale = true;
|
||||||
|
} else if (showDeviationsView.isChecked()) {
|
||||||
|
useDevForScale = true;
|
||||||
|
} else if (showRatiosView.isChecked()) {
|
||||||
|
useRatioForScale = true;
|
||||||
|
}
|
||||||
|
|
||||||
// add basal data
|
if (showIobView.isChecked())
|
||||||
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
|
secondGraphData.addIob(fromTime, now, useIobForScale, 1d);
|
||||||
graphData.addBasals(bgGraph, fromTime, now, lowLine / graphData.maxY / 1.2d);
|
if (showCobView.isChecked())
|
||||||
}
|
secondGraphData.addCob(fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d);
|
||||||
|
if (showDeviationsView.isChecked())
|
||||||
|
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
|
||||||
|
if (showRatiosView.isChecked())
|
||||||
|
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
|
||||||
|
|
||||||
// **** NOW line ****
|
// **** NOW line ****
|
||||||
graphData.addNowLine(bgGraph, now);
|
// set manual x bounds to have nice steps
|
||||||
secondGraphData.addNowLine(iobGraph, now);
|
secondGraphData.formatAxis(fromTime, endTime);
|
||||||
|
secondGraphData.addNowLine(now);
|
||||||
|
|
||||||
// finaly enforce drawing of graphs
|
// do GUI update
|
||||||
bgGraph.onDataChanged(false, false);
|
FragmentActivity activity = getActivity();
|
||||||
iobGraph.onDataChanged(false, false);
|
if (activity != null) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
|
||||||
|
iobGraph.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
iobGraph.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
// finally enforce drawing of graphs
|
||||||
|
graphData.performUpdate();
|
||||||
|
secondGraphData.performUpdate();
|
||||||
|
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
Profiler.log(log, from, updateGUIStart);
|
Profiler.log(log, from, updateGUIStart);
|
||||||
}
|
}
|
||||||
|
@ -1396,6 +1451,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateNotifications() {
|
void updateNotifications() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
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.QuickWizard;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.Overview.activities;
|
package info.nightscout.androidaps.plugins.Overview.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
@ -15,13 +15,11 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
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.QuickWizard;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.QuickWizard;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
|
import info.nightscout.androidaps.plugins.Overview.events.EventQuickWizardChange;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -153,6 +151,7 @@ public class QuickWizardListActivity extends AppCompatActivity implements View.O
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventQuickWizardChange ev) {
|
public void onStatusEvent(final EventQuickWizardChange ev) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
|
@ -27,7 +27,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
|
@ -45,15 +45,18 @@ import info.nightscout.utils.Round;
|
||||||
|
|
||||||
public class GraphData {
|
public class GraphData {
|
||||||
|
|
||||||
public GraphData() {
|
private GraphView graph;
|
||||||
units = MainApp.getConfigBuilder().getProfileUnits();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double maxY = 0;
|
public double maxY = 0;
|
||||||
private List<BgReading> bgReadingsArray;
|
private List<BgReading> bgReadingsArray;
|
||||||
private String units;
|
private String units;
|
||||||
|
private List<Series> series = new ArrayList<>();
|
||||||
|
|
||||||
public void addBgReadings(GraphView bgGraph, long fromTime, long toTime, double lowLine, double highLine, DetermineBasalResultAMA amaResult) {
|
public GraphData(GraphView graph) {
|
||||||
|
units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
|
this.graph = graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, DetermineBasalResultAMA amaResult) {
|
||||||
double maxBgValue = 0d;
|
double maxBgValue = 0d;
|
||||||
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
||||||
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
||||||
|
@ -81,20 +84,18 @@ public class GraphData {
|
||||||
DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
|
DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
|
||||||
bg = bgListArray.toArray(bg);
|
bg = bgListArray.toArray(bg);
|
||||||
|
|
||||||
if (bg.length > 0) {
|
|
||||||
addSeriesWithoutInvalidate(bgGraph, new PointsWithLabelGraphSeries<>(bg));
|
|
||||||
}
|
|
||||||
|
|
||||||
maxY = maxBgValue;
|
maxY = maxBgValue;
|
||||||
// set manual y bounds to have nice steps
|
// set manual y bounds to have nice steps
|
||||||
bgGraph.getViewport().setMaxY(maxY);
|
graph.getViewport().setMaxY(maxY);
|
||||||
bgGraph.getViewport().setMinY(0);
|
graph.getViewport().setMinY(0);
|
||||||
bgGraph.getViewport().setYAxisBoundsManual(true);
|
graph.getViewport().setYAxisBoundsManual(true);
|
||||||
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfVertLines);
|
graph.getGridLabelRenderer().setNumVerticalLabels(numOfVertLines);
|
||||||
|
|
||||||
|
addSeries(new PointsWithLabelGraphSeries<>(bg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInRangeArea(GraphView bgGraph, long fromTime, long toTime, double lowLine, double highLine) {
|
public void addInRangeArea(long fromTime, long toTime, double lowLine, double highLine) {
|
||||||
AreaGraphSeries<DoubleDataPoint> inRangeAreaSeries;
|
AreaGraphSeries<DoubleDataPoint> inRangeAreaSeries;
|
||||||
|
|
||||||
DoubleDataPoint[] inRangeAreaDataPoints = new DoubleDataPoint[]{
|
DoubleDataPoint[] inRangeAreaDataPoints = new DoubleDataPoint[]{
|
||||||
|
@ -102,14 +103,15 @@ public class GraphData {
|
||||||
new DoubleDataPoint(toTime, lowLine, highLine)
|
new DoubleDataPoint(toTime, lowLine, highLine)
|
||||||
};
|
};
|
||||||
inRangeAreaSeries = new AreaGraphSeries<>(inRangeAreaDataPoints);
|
inRangeAreaSeries = new AreaGraphSeries<>(inRangeAreaDataPoints);
|
||||||
addSeriesWithoutInvalidate(bgGraph, inRangeAreaSeries);
|
|
||||||
inRangeAreaSeries.setColor(0);
|
inRangeAreaSeries.setColor(0);
|
||||||
inRangeAreaSeries.setDrawBackground(true);
|
inRangeAreaSeries.setDrawBackground(true);
|
||||||
inRangeAreaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground));
|
inRangeAreaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground));
|
||||||
|
|
||||||
|
addSeries(inRangeAreaSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addBasals(GraphView bgGraph, long fromTime, long toTime, double scale) {
|
public void addBasals(long fromTime, long toTime, double scale) {
|
||||||
LineGraphSeries<ScaledDataPoint> basalsLineSeries;
|
LineGraphSeries<ScaledDataPoint> basalsLineSeries;
|
||||||
LineGraphSeries<ScaledDataPoint> absoluteBasalsLineSeries;
|
LineGraphSeries<ScaledDataPoint> absoluteBasalsLineSeries;
|
||||||
LineGraphSeries<ScaledDataPoint> baseBasalsSeries;
|
LineGraphSeries<ScaledDataPoint> baseBasalsSeries;
|
||||||
|
@ -194,7 +196,7 @@ public class GraphData {
|
||||||
basalsLineSeries = new LineGraphSeries<>(basalLine);
|
basalsLineSeries = new LineGraphSeries<>(basalLine);
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity*2);
|
paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2);
|
||||||
paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
|
paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
|
||||||
paint.setColor(MainApp.sResources.getColor(R.color.basal));
|
paint.setColor(MainApp.sResources.getColor(R.color.basal));
|
||||||
basalsLineSeries.setCustomPaint(paint);
|
basalsLineSeries.setCustomPaint(paint);
|
||||||
|
@ -204,19 +206,19 @@ public class GraphData {
|
||||||
absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine);
|
absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine);
|
||||||
Paint absolutePaint = new Paint();
|
Paint absolutePaint = new Paint();
|
||||||
absolutePaint.setStyle(Paint.Style.STROKE);
|
absolutePaint.setStyle(Paint.Style.STROKE);
|
||||||
absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity*2);
|
absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2);
|
||||||
absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal));
|
absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal));
|
||||||
absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
|
absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
|
||||||
|
|
||||||
basalScale.setMultiplier(maxY * scale / maxBasalValueFound);
|
basalScale.setMultiplier(maxY * scale / maxBasalValueFound);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(bgGraph, baseBasalsSeries);
|
addSeries(baseBasalsSeries);
|
||||||
addSeriesWithoutInvalidate(bgGraph, tempBasalsSeries);
|
addSeries(tempBasalsSeries);
|
||||||
addSeriesWithoutInvalidate(bgGraph, basalsLineSeries);
|
addSeries(basalsLineSeries);
|
||||||
addSeriesWithoutInvalidate(bgGraph, absoluteBasalsLineSeries);
|
addSeries(absoluteBasalsLineSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTreatments(GraphView bgGraph, long fromTime, long endTime) {
|
public void addTreatments(long fromTime, long endTime) {
|
||||||
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
||||||
|
|
||||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
||||||
|
@ -262,9 +264,7 @@ public class GraphData {
|
||||||
|
|
||||||
DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
|
DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
|
||||||
treatmentsArray = filteredTreatments.toArray(treatmentsArray);
|
treatmentsArray = filteredTreatments.toArray(treatmentsArray);
|
||||||
if (treatmentsArray.length > 0) {
|
addSeries(new PointsWithLabelGraphSeries<>(treatmentsArray));
|
||||||
addSeriesWithoutInvalidate(bgGraph, new PointsWithLabelGraphSeries<>(treatmentsArray));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double getNearestBg(long date) {
|
double getNearestBg(long date) {
|
||||||
|
@ -279,7 +279,7 @@ public class GraphData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addIob(GraphView graph, long fromTime, long toTime, boolean useForScale, double scale) {
|
public void addIob(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||||
FixedLineGraphSeries<ScaledDataPoint> iobSeries;
|
FixedLineGraphSeries<ScaledDataPoint> iobSeries;
|
||||||
List<ScaledDataPoint> iobArray = new ArrayList<>();
|
List<ScaledDataPoint> iobArray = new ArrayList<>();
|
||||||
Double maxIobValueFound = 0d;
|
Double maxIobValueFound = 0d;
|
||||||
|
@ -310,11 +310,11 @@ public class GraphData {
|
||||||
|
|
||||||
iobScale.setMultiplier(maxY * scale / maxIobValueFound);
|
iobScale.setMultiplier(maxY * scale / maxIobValueFound);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(graph, iobSeries);
|
addSeries(iobSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addCob(GraphView graph, long fromTime, long toTime, boolean useForScale, double scale) {
|
public void addCob(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||||
FixedLineGraphSeries<ScaledDataPoint> cobSeries;
|
FixedLineGraphSeries<ScaledDataPoint> cobSeries;
|
||||||
List<ScaledDataPoint> cobArray = new ArrayList<>();
|
List<ScaledDataPoint> cobArray = new ArrayList<>();
|
||||||
Double maxCobValueFound = 0d;
|
Double maxCobValueFound = 0d;
|
||||||
|
@ -349,11 +349,11 @@ public class GraphData {
|
||||||
|
|
||||||
cobScale.setMultiplier(maxY * scale / maxCobValueFound);
|
cobScale.setMultiplier(maxY * scale / maxCobValueFound);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(graph, cobSeries);
|
addSeries(cobSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addDeviations(GraphView graph, long fromTime, long toTime, boolean useForScale, double scale) {
|
public void addDeviations(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||||
class DeviationDataPoint extends ScaledDataPoint {
|
class DeviationDataPoint extends ScaledDataPoint {
|
||||||
public int color;
|
public int color;
|
||||||
|
|
||||||
|
@ -396,11 +396,11 @@ public class GraphData {
|
||||||
|
|
||||||
devScale.setMultiplier(maxY * scale / maxDevValueFound);
|
devScale.setMultiplier(maxY * scale / maxDevValueFound);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(graph, devSeries);
|
addSeries(devSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addRatio(GraphView graph, long fromTime, long toTime, boolean useForScale, double scale) {
|
public void addRatio(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||||
LineGraphSeries<DataPoint> ratioSeries;
|
LineGraphSeries<DataPoint> ratioSeries;
|
||||||
List<DataPoint> ratioArray = new ArrayList<>();
|
List<DataPoint> ratioArray = new ArrayList<>();
|
||||||
Double maxRatioValueFound = 0d;
|
Double maxRatioValueFound = 0d;
|
||||||
|
@ -426,11 +426,11 @@ public class GraphData {
|
||||||
|
|
||||||
ratioScale.setMultiplier(maxY * scale / maxRatioValueFound);
|
ratioScale.setMultiplier(maxY * scale / maxRatioValueFound);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(graph, ratioSeries);
|
addSeries(ratioSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addNowLine(GraphView graph, long now) {
|
public void addNowLine(long now) {
|
||||||
LineGraphSeries<DataPoint> seriesNow;
|
LineGraphSeries<DataPoint> seriesNow;
|
||||||
DataPoint[] nowPoints = new DataPoint[]{
|
DataPoint[] nowPoints = new DataPoint[]{
|
||||||
new DataPoint(now, 0),
|
new DataPoint(now, 0),
|
||||||
|
@ -447,10 +447,10 @@ public class GraphData {
|
||||||
paint.setColor(Color.WHITE);
|
paint.setColor(Color.WHITE);
|
||||||
seriesNow.setCustomPaint(paint);
|
seriesNow.setCustomPaint(paint);
|
||||||
|
|
||||||
addSeriesWithoutInvalidate(graph, seriesNow);
|
addSeries(seriesNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void formatAxis(GraphView graph, long fromTime, long endTime) {
|
public void formatAxis(long fromTime, long endTime) {
|
||||||
graph.getViewport().setMaxX(endTime);
|
graph.getViewport().setMaxX(endTime);
|
||||||
graph.getViewport().setMinX(fromTime);
|
graph.getViewport().setMinX(fromTime);
|
||||||
graph.getViewport().setXAxisBoundsManual(true);
|
graph.getViewport().setXAxisBoundsManual(true);
|
||||||
|
@ -458,11 +458,23 @@ public class GraphData {
|
||||||
graph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
graph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSeriesWithoutInvalidate(GraphView bgGraph, Series s) {
|
private void addSeries(Series s) {
|
||||||
if (!s.isEmpty()) {
|
series.add(s);
|
||||||
s.onGraphViewAttached(bgGraph);
|
|
||||||
bgGraph.getSeries().add(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void performUpdate() {
|
||||||
|
// clear old data
|
||||||
|
graph.getSeries().clear();
|
||||||
|
|
||||||
|
// add precalculated series
|
||||||
|
for (Series s: series) {
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
s.onGraphViewAttached(graph);
|
||||||
|
graph.getSeries().add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw it
|
||||||
|
graph.onDataChanged(false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ public class Notification {
|
||||||
public static final int PUMP_UNREACHABLE = 26;
|
public static final int PUMP_UNREACHABLE = 26;
|
||||||
public static final int BG_READINGS_MISSED = 27;
|
public static final int BG_READINGS_MISSED = 27;
|
||||||
public static final int UNSUPPORTED_FIRMWARE = 28;
|
public static final int UNSUPPORTED_FIRMWARE = 28;
|
||||||
|
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
|
||||||
|
public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30;
|
||||||
|
public static final int ZERO_VALUE_IN_PROFILE = 31;
|
||||||
|
public static final int NO_LOCALE_PROFILE_FOUND = 32;
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
public Date date;
|
public Date date;
|
||||||
|
|
|
@ -162,9 +162,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
baseic[i] = SP.getDouble(SETTINGS_PREFIX + "baseic" + i, baseic[i]);
|
baseic[i] = SP.getDouble(SETTINGS_PREFIX + "baseic" + i, baseic[i]);
|
||||||
baseisf[i] = SP.getDouble(SETTINGS_PREFIX + "baseisf" + i, baseisf[i]);
|
baseisf[i] = SP.getDouble(SETTINGS_PREFIX + "baseisf" + i, baseisf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
createConvertedProfile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String externallySetParameters(int timeshift, int percentage) {
|
public String externallySetParameters(int timeshift, int percentage) {
|
||||||
|
@ -182,9 +179,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
if (timeshift < 0 || timeshift > 23) {
|
if (timeshift < 0 || timeshift > 23) {
|
||||||
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||||
}
|
}
|
||||||
if (!SP.getBoolean("syncprofiletopump", false)) {
|
|
||||||
msg += MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
|
||||||
}
|
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
if (profile == null || profile.getBasal() == null) {
|
if (profile == null || profile.getBasal() == null) {
|
||||||
|
@ -350,6 +344,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfileStore getProfile() {
|
public ProfileStore getProfile() {
|
||||||
|
if (convertedProfile == null)
|
||||||
|
createConvertedProfile();
|
||||||
|
|
||||||
performLimitCheck();
|
performLimitCheck();
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
@ -361,6 +358,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
|
if (convertedProfile == null)
|
||||||
|
createConvertedProfile();
|
||||||
|
|
||||||
performLimitCheck();
|
performLimitCheck();
|
||||||
return convertedProfileName;
|
return convertedProfileName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.text.DecimalFormat;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
|
@ -84,15 +85,17 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
|
|
||||||
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
||||||
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
||||||
diaView.setParams(localProfilePlugin.dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
diaView.setParams(localProfilePlugin.dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
||||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.1d, new DecimalFormat("0.0"), save);
|
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.1d, new DecimalFormat("0.0"), save);
|
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, 0.01d, new DecimalFormat("0.00"), save);
|
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
||||||
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 0.1d, new DecimalFormat("0.0"), save);
|
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
|
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
|
||||||
|
|
||||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||||
|
|
|
@ -178,7 +178,6 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
} catch (JSONException ignored) {
|
} catch (JSONException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createConvertedProfile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -244,6 +243,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfileStore getProfile() {
|
public ProfileStore getProfile() {
|
||||||
|
if (convertedProfile == null)
|
||||||
|
createConvertedProfile();
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +255,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
|
if (convertedProfile == null)
|
||||||
|
createConvertedProfile();
|
||||||
return DecimalFormatter.to2Decimal(convertedProfile.getDefaultProfile().percentageBasalSum()) + "U ";
|
return DecimalFormatter.to2Decimal(convertedProfile.getDefaultProfile().percentageBasalSum()) + "U ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,19 +120,17 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
profile = new ProfileStore(newProfile.getData());
|
profile = new ProfileStore(newProfile.getData());
|
||||||
storeNSProfile();
|
storeNSProfile();
|
||||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||||
if (SP.getBoolean("syncprofiletopump", false)) {
|
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
||||||
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
if (result.enacted) {
|
||||||
if (result.enacted) {
|
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void storeNSProfile() {
|
private static void storeNSProfile() {
|
||||||
|
|
|
@ -13,9 +13,9 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
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.ProfileStore;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
|
|
||||||
public static SimpleProfilePlugin getPlugin() {
|
public static SimpleProfilePlugin getPlugin() {
|
||||||
if (simpleProfilePlugin == null)
|
if (simpleProfilePlugin == null)
|
||||||
simpleProfilePlugin = new SimpleProfilePlugin();
|
simpleProfilePlugin = new SimpleProfilePlugin();
|
||||||
return simpleProfilePlugin;
|
return simpleProfilePlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,6 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
basal = SP.getDouble("SimpleProfile" + "basal", 1d);
|
basal = SP.getDouble("SimpleProfile" + "basal", 1d);
|
||||||
targetLow = SP.getDouble("SimpleProfile" + "targetlow", 80d);
|
targetLow = SP.getDouble("SimpleProfile" + "targetlow", 80d);
|
||||||
targetHigh = SP.getDouble("SimpleProfile" + "targethigh", 120d);
|
targetHigh = SP.getDouble("SimpleProfile" + "targethigh", 120d);
|
||||||
createConvertedProfile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -211,6 +210,8 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfileStore getProfile() {
|
public ProfileStore getProfile() {
|
||||||
|
if (convertedProfile == null)
|
||||||
|
createConvertedProfile();
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
// Convert duration from minutes to hours
|
// Convert duration from minutes to hours
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
||||||
return setTempBasalPercent(percentRate, durationInMinutes);
|
return setTempBasalPercent(percentRate, durationInMinutes, false);
|
||||||
}
|
}
|
||||||
if (doExtendedTemp) {
|
if (doExtendedTemp) {
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
|
@ -499,7 +499,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
||||||
|
@ -514,7 +514,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -785,6 +785,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PointlessBooleanExpression")
|
@SuppressWarnings("PointlessBooleanExpression")
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
|
|
|
@ -436,7 +436,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
// Convert duration from minutes to hours
|
// Convert duration from minutes to hours
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
||||||
return setTempBasalPercent(percentRate, durationInMinutes);
|
return setTempBasalPercent(percentRate, durationInMinutes, false);
|
||||||
}
|
}
|
||||||
if (doExtendedTemp) {
|
if (doExtendedTemp) {
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
|
@ -501,7 +501,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
||||||
|
@ -516,7 +516,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent && enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -787,6 +787,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PointlessBooleanExpression")
|
@SuppressWarnings("PointlessBooleanExpression")
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
|
|
|
@ -289,6 +289,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
double origAbsoluteRate = absoluteRate;
|
double origAbsoluteRate = absoluteRate;
|
||||||
|
@ -400,6 +405,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
} else {
|
} else {
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||||
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.comment = "OK";
|
result.comment = "OK";
|
||||||
|
@ -580,7 +587,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
||||||
|
@ -595,7 +602,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
|
|
@ -7,8 +7,10 @@ import android.bluetooth.le.BluetoothLeScanner;
|
||||||
import android.bluetooth.le.ScanCallback;
|
import android.bluetooth.le.ScanCallback;
|
||||||
import android.bluetooth.le.ScanResult;
|
import android.bluetooth.le.ScanResult;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -31,7 +33,6 @@ import info.nightscout.utils.SP;
|
||||||
public class BLEScanActivity extends AppCompatActivity {
|
public class BLEScanActivity extends AppCompatActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(BLEScanActivity.class);
|
private static Logger log = LoggerFactory.getLogger(BLEScanActivity.class);
|
||||||
|
|
||||||
private Context mContext = null;
|
|
||||||
|
|
||||||
private ListView listView = null;
|
private ListView listView = null;
|
||||||
private ListAdapter mListAdapter = null;
|
private ListAdapter mListAdapter = null;
|
||||||
|
@ -53,26 +54,20 @@ public class BLEScanActivity extends AppCompatActivity {
|
||||||
listView.setEmptyView(findViewById(R.id.danars_blescanner_nodevice));
|
listView.setEmptyView(findViewById(R.id.danars_blescanner_nodevice));
|
||||||
listView.setAdapter(mListAdapter);
|
listView.setAdapter(mListAdapter);
|
||||||
|
|
||||||
initView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initView() {
|
|
||||||
mContext = getApplicationContext();
|
|
||||||
|
|
||||||
BluetoothManager bluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
|
|
||||||
mBluetoothAdapter = bluetoothManager.getAdapter();
|
|
||||||
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
|
||||||
|
|
||||||
// MIKE: test mBluetoothLeScanner for null (bt disabled)
|
|
||||||
|
|
||||||
mListAdapter.notifyDataSetChanged();
|
mListAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
||||||
|
|
||||||
|
if (mBluetoothLeScanner == null) {
|
||||||
|
mBluetoothAdapter.enable();
|
||||||
|
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
||||||
|
}
|
||||||
startScan();
|
startScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +133,7 @@ public class BLEScanActivity extends AppCompatActivity {
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
v = View.inflate(mContext, R.layout.danars_blescanner_item, null);
|
v = View.inflate(getApplicationContext(), R.layout.danars_blescanner_item, null);
|
||||||
holder = new ViewHolder(v);
|
holder = new ViewHolder(v);
|
||||||
v.setTag(holder);
|
v.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,6 +162,7 @@ public class BLEScanActivity extends AppCompatActivity {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SP.putString(R.string.key_danars_address, item.device.getAddress());
|
SP.putString(R.string.key_danars_address, item.device.getAddress());
|
||||||
SP.putString(R.string.key_danars_name, mName.getText().toString());
|
SP.putString(R.string.key_danars_name, mName.getText().toString());
|
||||||
|
item.device.createBond();
|
||||||
MainApp.bus().post(new EventDanaRSDeviceChange());
|
MainApp.bus().post(new EventDanaRSDeviceChange());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
super.dismiss();
|
super.dismissAllowingStateLoss();
|
||||||
if (helperActivity != null) {
|
if (helperActivity != null) {
|
||||||
helperActivity.finish();
|
helperActivity.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.09.2017.
|
* Created by mike on 05.09.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EventDanaRSDeviceChange {
|
public class EventDanaRSDeviceChange extends Event {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 01.09.2017.
|
* Created by mike on 01.09.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EventDanaRSPacket {
|
public class EventDanaRSPacket extends Event{
|
||||||
public EventDanaRSPacket(DanaRS_Packet data) {
|
public EventDanaRSPacket(DanaRS_Packet data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
package info.nightscout.androidaps.plugins.PumpDanaRS.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 01.09.2017.
|
* Created by mike on 01.09.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EventDanaRSPairingSuccess {
|
public class EventDanaRSPairingSuccess extends Event{
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,10 @@ public class DanaRSService extends Service {
|
||||||
while (!msg.done && bleComm.isConnected()) {
|
while (!msg.done && bleComm.isConnected()) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
|
if (DanaRS_Packet_APS_History_Events.lastEventTimeLoaded != 0)
|
||||||
|
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
|
||||||
|
else
|
||||||
|
lastHistoryFetched = 0;
|
||||||
log.debug("Events loaded");
|
log.debug("Events loaded");
|
||||||
return new PumpEnactResult().success(true);
|
return new PumpEnactResult().success(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
} else {
|
} else {
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||||
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.comment = "OK";
|
result.comment = "OK";
|
||||||
|
@ -437,7 +439,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
percent = configBuilderPlugin.applyBasalConstraints(percent);
|
||||||
|
@ -452,7 +454,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -730,6 +732,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSMBModeEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PointlessBooleanExpression")
|
@SuppressWarnings("PointlessBooleanExpression")
|
||||||
@Override
|
@Override
|
||||||
public Double applyBasalConstraints(Double absoluteRate) {
|
public Double applyBasalConstraints(Double absoluteRate) {
|
||||||
|
|
|
@ -527,7 +527,10 @@ public class DanaRv2ExecutionService extends Service {
|
||||||
waitMsec(100);
|
waitMsec(100);
|
||||||
}
|
}
|
||||||
waitMsec(200);
|
waitMsec(200);
|
||||||
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
|
if (MsgHistoryEvents_v2.lastEventTimeLoaded != 0)
|
||||||
|
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
|
||||||
|
else
|
||||||
|
lastHistoryFetched = 0;
|
||||||
return new PumpEnactResult().success(true);
|
return new PumpEnactResult().success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = MainApp.instance().getString(R.string.pumperror);
|
result.comment = MainApp.instance().getString(R.string.pumperror);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpVirtual;
|
package info.nightscout.androidaps.plugins.PumpVirtual;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -16,6 +14,7 @@ import info.nightscout.androidaps.Config;
|
||||||
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.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
@ -24,8 +23,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
|
@ -65,6 +65,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VirtualPumpPlugin plugin = null;
|
private static VirtualPumpPlugin plugin = null;
|
||||||
|
|
||||||
public static VirtualPumpPlugin getPlugin() {
|
public static VirtualPumpPlugin getPlugin() {
|
||||||
loadFakingStatus();
|
loadFakingStatus();
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -219,12 +220,14 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -304,7 +307,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||||
|
@ -401,8 +404,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus() {
|
public JSONObject getJSONStatus() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
||||||
if (!preferences.getBoolean("virtualpump_uploadstatus", false)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
JSONObject pump = new JSONObject();
|
JSONObject pump = new JSONObject();
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
package info.nightscout.androidaps.plugins.SourceDexcomG5;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
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.data.Profile;
|
||||||
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.NSUpload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 16.10.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BGSourceFragment extends SubscriberFragment {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(BGSourceFragment.class);
|
||||||
|
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
|
Profile profile;
|
||||||
|
|
||||||
|
final long MILLS_TO_THE_PAST = 12 * 60 * 60 * 1000L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.bgsource_fragment, container, false);
|
||||||
|
|
||||||
|
recyclerView = (RecyclerView) view.findViewById(R.id.bgsource_recyclerview);
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false));
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
profile = ConfigBuilderPlugin.getActiveProfileInterface().getProfile().getDefaultProfile();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void onStatusEvent(final EventNewBG ev) {
|
||||||
|
updateGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateGUI() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null)
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
recyclerView.swapAdapter(new BGSourceFragment.RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false)), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.BgReadingsViewHolder> {
|
||||||
|
|
||||||
|
List<BgReading> bgReadings;
|
||||||
|
|
||||||
|
RecyclerViewAdapter(List<BgReading> bgReadings) {
|
||||||
|
this.bgReadings = bgReadings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BgReadingsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.bgsource_item, viewGroup, false);
|
||||||
|
return new BgReadingsViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(BgReadingsViewHolder holder, int position) {
|
||||||
|
BgReading bgReading = bgReadings.get(position);
|
||||||
|
holder.ns.setVisibility(NSUpload.isIdValid(bgReading._id) ? View.VISIBLE : View.GONE);
|
||||||
|
holder.invalid.setVisibility(!bgReading.isValid ? View.VISIBLE : View.GONE);
|
||||||
|
holder.date.setText(DateUtil.dateAndTimeString(bgReading.date));
|
||||||
|
holder.value.setText(bgReading.valueToUnitsToString(profile.getUnits()));
|
||||||
|
holder.direction.setText(bgReading.directionToSymbol());
|
||||||
|
holder.remove.setTag(bgReading);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return bgReadings.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
class BgReadingsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
TextView date;
|
||||||
|
TextView value;
|
||||||
|
TextView direction;
|
||||||
|
TextView invalid;
|
||||||
|
TextView ns;
|
||||||
|
TextView remove;
|
||||||
|
|
||||||
|
BgReadingsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
date = (TextView) itemView.findViewById(R.id.bgsource_date);
|
||||||
|
value = (TextView) itemView.findViewById(R.id.bgsource_value);
|
||||||
|
direction = (TextView) itemView.findViewById(R.id.bgsource_direction);
|
||||||
|
invalid = (TextView) itemView.findViewById(R.id.invalid_sign);
|
||||||
|
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
||||||
|
remove = (TextView) itemView.findViewById(R.id.bgsource_remove);
|
||||||
|
remove.setOnClickListener(this);
|
||||||
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final BgReading bgReading = (BgReading) v.getTag();
|
||||||
|
switch (v.getId()) {
|
||||||
|
|
||||||
|
case R.id.bgsource_remove:
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits()));
|
||||||
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
/* final String _id = bgReading._id;
|
||||||
|
if (NSUpload.isIdValid(_id)) {
|
||||||
|
NSUpload.removeFoodFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
bgReading.isValid = false;
|
||||||
|
MainApp.getDbHelper().update(bgReading);
|
||||||
|
updateGUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||||
|
builder.show();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||||
private boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static SourceDexcomG5Plugin plugin = null;
|
private static SourceDexcomG5Plugin plugin = null;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return null;
|
return BGSourceFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +50,7 @@ public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInTabs(int type) {
|
public boolean isVisibleInTabs(int type) {
|
||||||
return false;
|
return Config.G5UPLOADER || type == BGSOURCE && fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +60,7 @@ public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFragment() {
|
public boolean hasFragment() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,7 +75,7 @@ public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,12 +4,14 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
private boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static SourceGlimpPlugin plugin = null;
|
private static SourceGlimpPlugin plugin = null;
|
||||||
|
|
||||||
|
@ -21,7 +23,7 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return null;
|
return BGSourceFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +49,7 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInTabs(int type) {
|
public boolean isVisibleInTabs(int type) {
|
||||||
return false;
|
return type == BGSOURCE && fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +59,7 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFragment() {
|
public boolean hasFragment() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +74,7 @@ public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,12 +4,14 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
private boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static SourceMM640gPlugin plugin = null;
|
private static SourceMM640gPlugin plugin = null;
|
||||||
|
|
||||||
|
@ -21,7 +23,7 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return null;
|
return BGSourceFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +49,7 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInTabs(int type) {
|
public boolean isVisibleInTabs(int type) {
|
||||||
return false;
|
return type == BGSOURCE && fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +59,7 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFragment() {
|
public boolean hasFragment() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +74,7 @@ public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,12 +5,14 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
private boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static SourceNSClientPlugin plugin = null;
|
private static SourceNSClientPlugin plugin = null;
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return null;
|
return BGSourceFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +34,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.nsclient);
|
return MainApp.instance().getString(R.string.nsclientbg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +51,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInTabs(int type) {
|
public boolean isVisibleInTabs(int type) {
|
||||||
return false;
|
return type == BGSOURCE && fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +61,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFragment() {
|
public boolean hasFragment() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,7 +76,7 @@ public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,12 +4,16 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static SourceXdripPlugin plugin = null;
|
private static SourceXdripPlugin plugin = null;
|
||||||
|
|
||||||
public static SourceXdripPlugin getPlugin() {
|
public static SourceXdripPlugin getPlugin() {
|
||||||
|
@ -20,11 +24,9 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return null;
|
return BGSourceFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fragmentEnabled = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return PluginBase.BGSOURCE;
|
return PluginBase.BGSOURCE;
|
||||||
|
@ -48,7 +50,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInTabs(int type) {
|
public boolean isVisibleInTabs(int type) {
|
||||||
return false;
|
return type == BGSOURCE && fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +60,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFragment() {
|
public boolean hasFragment() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,6 +75,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
|
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -82,7 +83,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
|
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
|
||||||
holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
||||||
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(t._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
|
||||||
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
|
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
|
||||||
if (iob.iobContrib != 0)
|
if (iob.iobContrib != 0)
|
||||||
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||||
|
@ -146,8 +147,10 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
treatment.isValid = false;
|
treatment.isValid = false;
|
||||||
MainApp.getDbHelper().update(treatment);
|
MainApp.getDbHelper().update(treatment);
|
||||||
} else {
|
} else {
|
||||||
if (_id != null && !_id.equals("")) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(treatment);
|
MainApp.getDbHelper().delete(treatment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
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;
|
||||||
|
@ -63,7 +64,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
public void onBindViewHolder(ExtendedBolusesViewHolder holder, int position) {
|
public void onBindViewHolder(ExtendedBolusesViewHolder holder, int position) {
|
||||||
ExtendedBolus extendedBolus = extendedBolusList.getReversed(position);
|
ExtendedBolus extendedBolus = extendedBolusList.getReversed(position);
|
||||||
holder.ph.setVisibility(extendedBolus.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(extendedBolus.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(extendedBolus._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(extendedBolus._id) ? View.VISIBLE : View.GONE);
|
||||||
if (extendedBolus.isEndingEvent()) {
|
if (extendedBolus.isEndingEvent()) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date));
|
holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date));
|
||||||
holder.duration.setText(MainApp.sResources.getString(R.string.cancel));
|
holder.duration.setText(MainApp.sResources.getString(R.string.cancel));
|
||||||
|
@ -148,8 +149,10 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = extendedBolus._id;
|
final String _id = extendedBolus._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(extendedBolus);
|
MainApp.getDbHelper().delete(extendedBolus);
|
||||||
Answers.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus"));
|
Answers.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus"));
|
||||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
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;
|
||||||
|
@ -66,7 +67,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
if (profile == null) return;
|
if (profile == null) return;
|
||||||
ProfileSwitch profileSwitch = profileSwitchList.getReversed(position);
|
ProfileSwitch profileSwitch = profileSwitchList.getReversed(position);
|
||||||
holder.ph.setVisibility(profileSwitch.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(profileSwitch.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(profileSwitch._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(profileSwitch._id) ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
holder.date.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
||||||
if (!profileSwitch.isEndingEvent()) {
|
if (!profileSwitch.isEndingEvent()) {
|
||||||
|
@ -131,8 +132,10 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = profileSwitch._id;
|
final String _id = profileSwitch._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(profileSwitch);
|
MainApp.getDbHelper().delete(profileSwitch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
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;
|
||||||
|
@ -67,7 +68,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
TempTarget tempTarget = tempTargetList.getReversed(position);
|
TempTarget tempTarget = tempTargetList.getReversed(position);
|
||||||
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(tempTarget._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE);
|
||||||
if (!tempTarget.isEndingEvent()) {
|
if (!tempTarget.isEndingEvent()) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTarget.originalEnd()));
|
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTarget.originalEnd()));
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
|
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
|
||||||
|
@ -149,8 +150,10 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = tempTarget._id;
|
final String _id = tempTarget._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(tempTarget);
|
MainApp.getDbHelper().delete(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
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;
|
||||||
|
@ -65,7 +66,7 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
public void onBindViewHolder(TempBasalsViewHolder holder, int position) {
|
public void onBindViewHolder(TempBasalsViewHolder holder, int position) {
|
||||||
TemporaryBasal tempBasal = tempBasalList.getReversed(position);
|
TemporaryBasal tempBasal = tempBasalList.getReversed(position);
|
||||||
holder.ph.setVisibility(tempBasal.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(tempBasal.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(tempBasal._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(tempBasal._id) ? View.VISIBLE : View.GONE);
|
||||||
if (tempBasal.isEndingEvent()) {
|
if (tempBasal.isEndingEvent()) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempBasal.date));
|
holder.date.setText(DateUtil.dateAndTimeString(tempBasal.date));
|
||||||
holder.duration.setText(MainApp.sResources.getString(R.string.cancel));
|
holder.duration.setText(MainApp.sResources.getString(R.string.cancel));
|
||||||
|
@ -165,8 +166,10 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = tempBasal._id;
|
final String _id = tempBasal._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(tempBasal);
|
MainApp.getDbHelper().delete(tempBasal);
|
||||||
Answers.getInstance().logCustom(new CustomEvent("RemoveTempBasal"));
|
Answers.getInstance().logCustom(new CustomEvent("RemoveTempBasal"));
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
|
@ -268,13 +269,15 @@ public class ActionStringHandler {
|
||||||
} else if ("tddstats".equals(act[0])) {
|
} else if ("tddstats".equals(act[0])) {
|
||||||
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
|
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||||
|
|
||||||
|
|
||||||
if ((dana == null || dana != activePump) &&
|
if ((dana == null || dana != activePump) &&
|
||||||
(danaV2 == null || danaV2 != activePump) &&
|
(danaV2 == null || danaV2 != activePump) &&
|
||||||
(danaKorean == null || danaKorean != activePump)
|
(danaKorean == null || danaKorean != activePump) &&
|
||||||
|
(danaRS == null || danaRS != activePump)
|
||||||
) {
|
) {
|
||||||
sendError("Pump does not support TDDs!");
|
sendError("Pump does not support TDDs!");
|
||||||
return;
|
return;
|
||||||
|
@ -579,9 +582,6 @@ public class ActionStringHandler {
|
||||||
if (timeshift < 0 || timeshift > 23) {
|
if (timeshift < 0 || timeshift > 23) {
|
||||||
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||||
}
|
}
|
||||||
if (!SP.getBoolean("syncprofiletopump", false)) {
|
|
||||||
msg += MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
|
||||||
}
|
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
if (profile == null || profile.getBasal() == null) {
|
if (profile == null || profile.getBasal() == null) {
|
||||||
|
|
|
@ -215,6 +215,8 @@ public class WearPlugin implements PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||||
|
if(ev.result == null) return;
|
||||||
|
|
||||||
String status;
|
String status;
|
||||||
if(ev.result.success){
|
if(ev.result.success){
|
||||||
status = MainApp.sResources.getString(R.string.success);
|
status = MainApp.sResources.getString(R.string.success);
|
||||||
|
|
|
@ -243,6 +243,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
|
|
||||||
DataMap dataMap = new DataMap();
|
DataMap dataMap = new DataMap();
|
||||||
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
|
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
|
||||||
|
dataMap.putString("glucoseUnits", units);
|
||||||
dataMap.putLong("timestamp", lastBG.date);
|
dataMap.putLong("timestamp", lastBG.date);
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
dataMap.putString("slopeArrow", "");
|
dataMap.putString("slopeArrow", "");
|
||||||
|
@ -253,7 +254,6 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
|
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
|
||||||
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
|
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMap.putLong("sgvLevel", sgvLevel);
|
dataMap.putLong("sgvLevel", sgvLevel);
|
||||||
dataMap.putDouble("sgvDouble", lastBG.value);
|
dataMap.putDouble("sgvDouble", lastBG.value);
|
||||||
dataMap.putDouble("high", highLine);
|
dataMap.putDouble("high", highLine);
|
||||||
|
@ -316,7 +316,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
if (last_bg == null) return;
|
if (last_bg == null) return;
|
||||||
|
|
||||||
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
|
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(true);
|
||||||
|
|
||||||
if (!graph_bgs.isEmpty()) {
|
if (!graph_bgs.isEmpty()) {
|
||||||
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
|
||||||
|
@ -533,7 +533,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
String iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||||
String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
String iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||||
String cobString = generateCOBString();
|
String cobString = generateCOBString();
|
||||||
String tempBasal = generateBasalString(treatmentsInterface);
|
String currentBasal = generateBasalString(treatmentsInterface);
|
||||||
|
|
||||||
//bgi
|
//bgi
|
||||||
String bgiString = "";
|
String bgiString = "";
|
||||||
|
@ -543,7 +543,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
|
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
|
||||||
}
|
}
|
||||||
|
|
||||||
String status = generateStatusString(profile, tempBasal,iobSum, iobDetail, bgiString);
|
String status = generateStatusString(profile, currentBasal,iobSum, iobDetail, bgiString);
|
||||||
|
|
||||||
//batteries
|
//batteries
|
||||||
int phoneBattery = getBatteryLevel(getApplicationContext());
|
int phoneBattery = getBatteryLevel(getApplicationContext());
|
||||||
|
@ -567,7 +567,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
dataMapRequest.getDataMap().putString("iobDetail", iobDetail);
|
dataMapRequest.getDataMap().putString("iobDetail", iobDetail);
|
||||||
dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false));
|
dataMapRequest.getDataMap().putBoolean("detailedIob", mPrefs.getBoolean("wear_detailediob", false));
|
||||||
dataMapRequest.getDataMap().putString("cob", cobString);
|
dataMapRequest.getDataMap().putString("cob", cobString);
|
||||||
dataMapRequest.getDataMap().putString("tempBasal", tempBasal);
|
dataMapRequest.getDataMap().putString("currentBasal", currentBasal);
|
||||||
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
|
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
|
||||||
dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
|
dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
|
||||||
dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus);
|
dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus);
|
||||||
|
@ -598,7 +598,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String generateStatusString(Profile profile, String tempBasal, String iobSum, String iobDetail, String bgiString) {
|
private String generateStatusString(Profile profile, String currentBasal, String iobSum, String iobDetail, String bgiString) {
|
||||||
|
|
||||||
String status = "";
|
String status = "";
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
iobString = iobSum + "U";
|
iobString = iobSum + "U";
|
||||||
}
|
}
|
||||||
|
|
||||||
status += tempBasal + " " + iobString;
|
status += currentBasal + " " + iobString;
|
||||||
|
|
||||||
//add BGI if shown, otherwise return
|
//add BGI if shown, otherwise return
|
||||||
if (mPrefs.getBoolean("wear_showbgi", false)) {
|
if (mPrefs.getBoolean("wear_showbgi", false)) {
|
||||||
|
@ -636,10 +636,16 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
@NonNull
|
@NonNull
|
||||||
private String generateBasalString(TreatmentsInterface treatmentsInterface) {
|
private String generateBasalString(TreatmentsInterface treatmentsInterface) {
|
||||||
|
|
||||||
String basalStringResult = "-.--U/h";
|
String basalStringResult;
|
||||||
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
basalStringResult = activeTemp.toStringShort();
|
basalStringResult = activeTemp.toStringShort();
|
||||||
|
} else {
|
||||||
|
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false)) {
|
||||||
|
basalStringResult = "100%";
|
||||||
|
} else {
|
||||||
|
basalStringResult = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return basalStringResult;
|
return basalStringResult;
|
||||||
}
|
}
|
||||||
|
@ -648,7 +654,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
private String generateCOBString() {
|
private String generateCOBString() {
|
||||||
|
|
||||||
String cobStringResult = "--";
|
String cobStringResult = "--";
|
||||||
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
|
AutosensData autosensData = IobCobCalculatorPlugin.getLastAutosensData();
|
||||||
if (autosensData != null) {
|
if (autosensData != null) {
|
||||||
cobStringResult = (int) autosensData.cob + "g";
|
cobStringResult = (int) autosensData.cob + "g";
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class CommandQueue {
|
||||||
|
|
||||||
// After new command added to the queue
|
// After new command added to the queue
|
||||||
// start thread again if not already running
|
// start thread again if not already running
|
||||||
private void notifyAboutNewCommand() {
|
private synchronized void notifyAboutNewCommand() {
|
||||||
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
||||||
thread = new QueueThread(this);
|
thread = new QueueThread(this);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -153,6 +153,10 @@ public class CommandQueue {
|
||||||
// remove all unfinished boluses
|
// remove all unfinished boluses
|
||||||
removeAll(Command.CommandType.BOLUS);
|
removeAll(Command.CommandType.BOLUS);
|
||||||
|
|
||||||
|
// apply constraints
|
||||||
|
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
|
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
|
||||||
|
|
||||||
// add new command to queue
|
// add new command to queue
|
||||||
add(new CommandBolus(detailedBolusInfo, callback));
|
add(new CommandBolus(detailedBolusInfo, callback));
|
||||||
|
|
||||||
|
@ -162,12 +166,8 @@ public class CommandQueue {
|
||||||
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
||||||
|
|
||||||
// Bring up bolus progress dialog
|
// Bring up bolus progress dialog
|
||||||
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
|
|
||||||
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
|
|
||||||
|
|
||||||
BolusProgressDialog bolusProgressDialog = null;
|
|
||||||
if (detailedBolusInfo.context != null) {
|
if (detailedBolusInfo.context != null) {
|
||||||
bolusProgressDialog = new BolusProgressDialog();
|
BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
|
||||||
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
|
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
|
||||||
bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress");
|
bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress");
|
||||||
} else {
|
} else {
|
||||||
|
@ -203,7 +203,7 @@ public class CommandQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean tempBasalPercent(int percent, int durationInMinutes, Callback callback) {
|
public boolean tempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
|
||||||
if (isRunning(Command.CommandType.TEMPBASAL)) {
|
if (isRunning(Command.CommandType.TEMPBASAL)) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(executingNowError()).run();
|
callback.result(executingNowError()).run();
|
||||||
|
@ -216,7 +216,7 @@ public class CommandQueue {
|
||||||
Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent);
|
Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent);
|
||||||
|
|
||||||
// add new command to queue
|
// add new command to queue
|
||||||
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, callback));
|
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, enforceNew, callback));
|
||||||
|
|
||||||
notifyAboutNewCommand();
|
notifyAboutNewCommand();
|
||||||
|
|
||||||
|
@ -326,14 +326,14 @@ public class CommandQueue {
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean readStatus(String reason, Callback callback) {
|
public boolean readStatus(String reason, Callback callback) {
|
||||||
if (isRunning(Command.CommandType.READSTATUS)) {
|
//if (isRunning(Command.CommandType.READSTATUS)) {
|
||||||
if (callback != null)
|
// if (callback != null)
|
||||||
callback.result(executingNowError()).run();
|
// callback.result(executingNowError()).run();
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// remove all unfinished
|
// remove all unfinished
|
||||||
removeAll(Command.CommandType.READSTATUS);
|
//removeAll(Command.CommandType.READSTATUS);
|
||||||
|
|
||||||
// add new command to queue
|
// add new command to queue
|
||||||
add(new CommandReadStatus(reason, callback));
|
add(new CommandReadStatus(reason, callback));
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class QueueThread extends Thread {
|
||||||
CommandQueue queue;
|
CommandQueue queue;
|
||||||
|
|
||||||
private long connectionStartTime = 0;
|
private long connectionStartTime = 0;
|
||||||
|
private long lastCommandTime = 0;
|
||||||
private boolean connectLogged = false;
|
private boolean connectLogged = false;
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
@ -45,7 +46,7 @@ public class QueueThread extends Thread {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
connectionStartTime = System.currentTimeMillis();
|
connectionStartTime = lastCommandTime = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -59,7 +60,7 @@ public class QueueThread extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
|
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
|
||||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
|
||||||
log.debug("QUEUE: timed out");
|
log.debug("QUEUE: timed out");
|
||||||
pump.stopConnecting();
|
pump.stopConnecting();
|
||||||
|
@ -79,7 +80,7 @@ public class QueueThread extends Thread {
|
||||||
mBluetoothAdapter.enable();
|
mBluetoothAdapter.enable();
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
//start over again once after watchdog barked
|
//start over again once after watchdog barked
|
||||||
connectionStartTime = System.currentTimeMillis();
|
connectionStartTime = lastCommandTime = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
queue.clear();
|
queue.clear();
|
||||||
return;
|
return;
|
||||||
|
@ -107,17 +108,24 @@ public class QueueThread extends Thread {
|
||||||
queue.performing().execute();
|
queue.performing().execute();
|
||||||
queue.resetPerforming();
|
queue.resetPerforming();
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
|
lastCommandTime = System.currentTimeMillis();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue.size() == 0 && queue.performing() == null) {
|
if (queue.size() == 0 && queue.performing() == null) {
|
||||||
log.debug("QUEUE: queue empty. disconnect");
|
long secondsFromLastCommand = (System.currentTimeMillis() - lastCommandTime) / 1000;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
if (secondsFromLastCommand >= 5) {
|
||||||
pump.disconnect("Queue empty");
|
log.debug("QUEUE: queue empty. disconnect");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return;
|
pump.disconnect("Queue empty");
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
log.debug("QUEUE: waiting for disconnect");
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.queue.commands;
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.LocalAlertUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.11.2017.
|
* Created by mike on 09.11.2017.
|
||||||
|
@ -20,6 +20,7 @@ public class CommandReadStatus extends Command {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
ConfigBuilderPlugin.getActivePump().getPumpStatus();
|
ConfigBuilderPlugin.getActivePump().getPumpStatus();
|
||||||
|
LocalAlertUtils.notifyPumpStatusRead();
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(null).run();
|
callback.result(null).run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,19 @@ public class CommandTempBasalPercent extends Command {
|
||||||
|
|
||||||
int durationInMinutes;
|
int durationInMinutes;
|
||||||
int percent;
|
int percent;
|
||||||
|
boolean enforceNew;
|
||||||
|
|
||||||
public CommandTempBasalPercent(int percent, int durationInMinutes, Callback callback) {
|
public CommandTempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
|
||||||
commandType = CommandType.TEMPBASAL;
|
commandType = CommandType.TEMPBASAL;
|
||||||
this.percent = percent;
|
this.percent = percent;
|
||||||
this.durationInMinutes = durationInMinutes;
|
this.durationInMinutes = durationInMinutes;
|
||||||
|
this.enforceNew = enforceNew;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes);
|
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, enforceNew);
|
||||||
if (Config.logCongigBuilderActions)
|
if (Config.logCongigBuilderActions)
|
||||||
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
|
|
|
@ -16,61 +16,39 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.utils.LocalAlertUtils;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class KeepAliveReceiver extends BroadcastReceiver {
|
public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
|
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
|
||||||
public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L;
|
public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L;
|
||||||
|
|
||||||
// TODO consider moving this into an Alarms plugin that works offline and can be configured
|
public static void cancelAlarm(Context context) {
|
||||||
// (e.g. override silent mode at night only)
|
Intent intent = new Intent(context, KeepAliveReceiver.class);
|
||||||
|
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||||
private static int missedReadingsThreshold() {
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
return SP.getInt(MainApp.sResources.getString(R.string.key_missed_bg_readings_threshold), 30) * 60 * 1000;
|
alarmManager.cancel(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int pumpUnreachableThreshold() {
|
|
||||||
return SP.getInt(MainApp.sResources.getString(R.string.key_pump_unreachable_threshold), 30) * 60 * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent rIntent) {
|
public void onReceive(Context context, Intent rIntent) {
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "");
|
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "");
|
||||||
wl.acquire();
|
wl.acquire();
|
||||||
|
|
||||||
shortenSnoozeInterval();
|
LocalAlertUtils.shortenSnoozeInterval();
|
||||||
checkBg();
|
LocalAlertUtils.checkStaleBGAlert();
|
||||||
checkPump();
|
checkPump();
|
||||||
|
|
||||||
log.debug("KeepAlive received");
|
log.debug("KeepAlive received");
|
||||||
wl.release();
|
wl.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBg() {
|
|
||||||
BgReading bgReading = DatabaseHelper.lastBg();
|
|
||||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_missed_bg_readings_alert), false)
|
|
||||||
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis()
|
|
||||||
&& SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
|
|
||||||
Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.sResources.getString(R.string.missed_bg_readings), Notification.URGENT);
|
|
||||||
n.soundId = R.raw.alarm;
|
|
||||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkPump() {
|
private void checkPump() {
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
@ -79,18 +57,9 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
boolean isStatusOutdated = lastConnection.getTime() + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis();
|
boolean isStatusOutdated = lastConnection.getTime() + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis();
|
||||||
boolean isBasalOutdated = Math.abs(profile.getBasal() - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep;
|
boolean isBasalOutdated = Math.abs(profile.getBasal() - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep;
|
||||||
|
|
||||||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
LocalAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated);
|
||||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis();
|
|
||||||
|
|
||||||
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
if (!pump.isThisProfileSet(profile)) {
|
||||||
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !ConfigBuilderPlugin.getActiveLoop().isDisconnected()) {
|
|
||||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
|
||||||
n.soundId = R.raw.alarm;
|
|
||||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) {
|
|
||||||
MainApp.getConfigBuilder().getCommandQueue().setProfile(profile, null);
|
MainApp.getConfigBuilder().getCommandQueue().setProfile(profile, null);
|
||||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||||
MainApp.getConfigBuilder().getCommandQueue().readStatus("KeepAlive. Status outdated.", null);
|
MainApp.getConfigBuilder().getCommandQueue().readStatus("KeepAlive. Status outdated.", null);
|
||||||
|
@ -103,8 +72,8 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
//called by MainApp at first app start
|
//called by MainApp at first app start
|
||||||
public void setAlarm(Context context) {
|
public void setAlarm(Context context) {
|
||||||
|
|
||||||
shortenSnoozeInterval();
|
LocalAlertUtils.shortenSnoozeInterval();
|
||||||
presnoozeAlarms();
|
LocalAlertUtils.presnoozeAlarms();
|
||||||
|
|
||||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
Intent i = new Intent(context, KeepAliveReceiver.class);
|
Intent i = new Intent(context, KeepAliveReceiver.class);
|
||||||
|
@ -117,33 +86,4 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), Constants.keepAliveMsecs, pi);
|
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), Constants.keepAliveMsecs, pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Presnoozes the alarms with 5 minutes if no snooze exists.
|
|
||||||
* Call only at startup!
|
|
||||||
*/
|
|
||||||
public void presnoozeAlarms() {
|
|
||||||
if (SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
|
|
||||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + 5 * 60 * 1000);
|
|
||||||
}
|
|
||||||
if (SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis()) {
|
|
||||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + 5 * 60 * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancelAlarm(Context context) {
|
|
||||||
Intent intent = new Intent(context, KeepAliveReceiver.class);
|
|
||||||
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
|
|
||||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
|
||||||
alarmManager.cancel(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void shortenSnoozeInterval() {
|
|
||||||
//shortens alarm times in case of setting changes or future data
|
|
||||||
long nextMissedReadingsAlarm = SP.getLong("nextMissedReadingsAlarm", 0L);
|
|
||||||
nextMissedReadingsAlarm = Math.min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm);
|
|
||||||
SP.putLong("nextMissedReadingsAlarm", nextMissedReadingsAlarm);
|
|
||||||
|
|
||||||
long nextPumpDisconnectedAlarm = SP.getLong("nextPumpDisconnectedAlarm", 0L);
|
|
||||||
nextPumpDisconnectedAlarm = Math.min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm);
|
|
||||||
SP.putLong("nextPumpDisconnectedAlarm", nextPumpDisconnectedAlarm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,12 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +26,8 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TabPageAdapter.class);
|
||||||
|
|
||||||
public TabPageAdapter(FragmentManager fm, Context context) {
|
public TabPageAdapter(FragmentManager fm, Context context) {
|
||||||
super(fm);
|
super(fm);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -40,6 +46,8 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
||||||
super.finishUpdate(container);
|
super.finishUpdate(container);
|
||||||
} catch (NullPointerException nullPointerException){
|
} catch (NullPointerException nullPointerException){
|
||||||
System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate");
|
System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate");
|
||||||
|
} catch (IllegalStateException e){
|
||||||
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
|
||||||
public class BolusWizard {
|
public class BolusWizard {
|
||||||
// Inputs
|
// Inputs
|
||||||
Profile specificProfile = null;
|
private Profile specificProfile = null;
|
||||||
TempTarget tempTarget;
|
private TempTarget tempTarget;
|
||||||
public Integer carbs = 0;
|
public Integer carbs = 0;
|
||||||
Double bg = 0d;
|
private Double bg = 0d;
|
||||||
Double correction;
|
private Double correction;
|
||||||
Boolean includeBolusIOB = true;
|
private Boolean includeBolusIOB = true;
|
||||||
Boolean includeBasalIOB = true;
|
private Boolean includeBasalIOB = true;
|
||||||
Boolean superBolus = false;
|
public Boolean superBolus = false;
|
||||||
Boolean trend = false;
|
private Boolean trend = false;
|
||||||
|
|
||||||
// Intermediate
|
// Intermediate
|
||||||
public Double sens = 0d;
|
public Double sens = 0d;
|
||||||
|
@ -71,7 +71,9 @@ public class BolusWizard {
|
||||||
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits());
|
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits());
|
||||||
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits());
|
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits());
|
||||||
}
|
}
|
||||||
if (bg <= targetBGLow) {
|
if (bg >= targetBGLow && bg <= targetBGHigh) {
|
||||||
|
bgDiff = 0d;
|
||||||
|
} else if (bg <= targetBGLow) {
|
||||||
bgDiff = bg - targetBGLow;
|
bgDiff = bg - targetBGLow;
|
||||||
} else {
|
} else {
|
||||||
bgDiff = bg - targetBGHigh;
|
bgDiff = bg - targetBGHigh;
|
||||||
|
|
|
@ -2,10 +2,12 @@ package info.nightscout.utils;
|
||||||
|
|
||||||
import android.support.v4.util.LongSparseArray;
|
import android.support.v4.util.LongSparseArray;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.SparseIntArray;
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -27,9 +29,7 @@ public class DateUtil {
|
||||||
/**
|
/**
|
||||||
* The date format in iso.
|
* The date format in iso.
|
||||||
*/
|
*/
|
||||||
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ";
|
private static String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||||
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
|
|
||||||
private static String FORMAT_DATE_ISO_MSEC_UTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes in an ISO date string of the following format:
|
* Takes in an ISO date string of the following format:
|
||||||
|
@ -41,33 +41,10 @@ public class DateUtil {
|
||||||
*/
|
*/
|
||||||
public static Date fromISODateString(String isoDateString)
|
public static Date fromISODateString(String isoDateString)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
SimpleDateFormat f = new SimpleDateFormat(FORMAT_DATE_ISO, Locale.getDefault());
|
|
||||||
Date date;
|
|
||||||
|
|
||||||
f.setTimeZone(TimeZone.getTimeZone("UTC"));
|
DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser();
|
||||||
try {
|
DateTime dateTime = DateTime.parse(isoDateString, parser);
|
||||||
date = f.parse(isoDateString);
|
return dateTime.toDate();
|
||||||
return date;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC, Locale.getDefault());
|
|
||||||
f.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
try {
|
|
||||||
date = f.parse(isoDateString);
|
|
||||||
return date;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC_UTC, Locale.getDefault());
|
|
||||||
f.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
try {
|
|
||||||
date = f.parse(isoDateString);
|
|
||||||
return date;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ParseException("Unparseable date: " + isoDateString, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +56,7 @@ public class DateUtil {
|
||||||
* @return the iso-formatted date string
|
* @return the iso-formatted date string
|
||||||
*/
|
*/
|
||||||
public static String toISOString(Date date, String format, TimeZone tz) {
|
public static String toISOString(Date date, String format, TimeZone tz) {
|
||||||
if (format == null) format = FORMAT_DATE_ISO;
|
if (format == null) format = FORMAT_DATE_ISO_OUT;
|
||||||
if (tz == null) tz = TimeZone.getDefault();
|
if (tz == null) tz = TimeZone.getDefault();
|
||||||
DateFormat f = new SimpleDateFormat(format, Locale.getDefault());
|
DateFormat f = new SimpleDateFormat(format, Locale.getDefault());
|
||||||
f.setTimeZone(tz);
|
f.setTimeZone(tz);
|
||||||
|
@ -87,21 +64,18 @@ public class DateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toISOString(Date date) {
|
public static String toISOString(Date date) {
|
||||||
return toISOString(date, FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC"));
|
return toISOString(date, FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toISOString(long date) {
|
public static String toISOString(long date) {
|
||||||
return toISOString(new Date(date), FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC"));
|
return toISOString(new Date(date), FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date toDate(Integer seconds) {
|
public static Date toDate(Integer seconds) {
|
||||||
Calendar calendar = new GregorianCalendar();
|
Calendar calendar = new GregorianCalendar();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, seconds / 60 / 60);
|
calendar.set(Calendar.HOUR_OF_DAY, seconds / 60 / 60);
|
||||||
String a = calendar.getTime().toString();
|
|
||||||
calendar.set(Calendar.MINUTE, (seconds / 60) % 60);
|
calendar.set(Calendar.MINUTE, (seconds / 60) % 60);
|
||||||
String b = calendar.getTime().toString();
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.set(Calendar.SECOND, 0);
|
||||||
String c = calendar.getTime().toString();
|
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
96
app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
Normal file
96
app/src/main/java/info/nightscout/utils/LocalAlertUtils.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package info.nightscout.utils;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 17/12/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LocalAlertUtils {
|
||||||
|
public static int missedReadingsThreshold() {
|
||||||
|
return SP.getInt(MainApp.sResources.getString(R.string.key_missed_bg_readings_threshold), 30) * 60 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int pumpUnreachableThreshold() {
|
||||||
|
return SP.getInt(MainApp.sResources.getString(R.string.key_pump_unreachable_threshold), 30) * 60 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkPumpUnreachableAlarm(Date lastConnection, boolean isStatusOutdated) {
|
||||||
|
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||||
|
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
||||||
|
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !ConfigBuilderPlugin.getActiveLoop().isDisconnected()) {
|
||||||
|
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||||
|
n.soundId = R.raw.alarm;
|
||||||
|
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
||||||
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Presnoozes the alarms with 5 minutes if no snooze exists.
|
||||||
|
* Call only at startup!
|
||||||
|
*/
|
||||||
|
public static void presnoozeAlarms() {
|
||||||
|
if (SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
|
||||||
|
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + 5 * 60 * 1000);
|
||||||
|
}
|
||||||
|
if (SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis()) {
|
||||||
|
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + 5 * 60 * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void shortenSnoozeInterval() {
|
||||||
|
//shortens alarm times in case of setting changes or future data
|
||||||
|
long nextMissedReadingsAlarm = SP.getLong("nextMissedReadingsAlarm", 0L);
|
||||||
|
nextMissedReadingsAlarm = Math.min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm);
|
||||||
|
SP.putLong("nextMissedReadingsAlarm", nextMissedReadingsAlarm);
|
||||||
|
|
||||||
|
long nextPumpDisconnectedAlarm = SP.getLong("nextPumpDisconnectedAlarm", 0L);
|
||||||
|
nextPumpDisconnectedAlarm = Math.min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm);
|
||||||
|
SP.putLong("nextPumpDisconnectedAlarm", nextPumpDisconnectedAlarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notifyPumpStatusRead(){
|
||||||
|
//TODO: persist the actual time the pump is read and simplify the whole logic when to alarm
|
||||||
|
|
||||||
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
if (pump != null && profile != null && profile.getBasal() != null) {
|
||||||
|
Date lastConnection = pump.lastDataTime();
|
||||||
|
long earliestAlarmTime = lastConnection.getTime() + pumpUnreachableThreshold();
|
||||||
|
if (SP.getLong("nextPumpDisconnectedAlarm", 0l) < earliestAlarmTime) {
|
||||||
|
SP.putLong("nextPumpDisconnectedAlarm", earliestAlarmTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkStaleBGAlert() {
|
||||||
|
BgReading bgReading = DatabaseHelper.lastBg();
|
||||||
|
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_missed_bg_readings_alert), false)
|
||||||
|
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis()
|
||||||
|
&& SP.getLong("nextMissedReadingsAlarm", 0l) < System.currentTimeMillis()) {
|
||||||
|
Notification n = new Notification(Notification.BG_READINGS_MISSED, MainApp.sResources.getString(R.string.missed_bg_readings), Notification.URGENT);
|
||||||
|
n.soundId = R.raw.alarm;
|
||||||
|
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
||||||
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -493,4 +493,11 @@ public class NSUpload {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isIdValid(String _id) {
|
||||||
|
if (_id == null)
|
||||||
|
return false;
|
||||||
|
if (_id.length() == 24)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 22.12.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PercentageSplitter {
|
||||||
|
public static String pureName(String name) {
|
||||||
|
String newName = name;
|
||||||
|
String s = "(.*)\\((\\d+)\\%\\)";
|
||||||
|
Pattern r = Pattern.compile(s);
|
||||||
|
Matcher m = r.matcher(name);
|
||||||
|
if (m.find()) {
|
||||||
|
newName = m.group(1);
|
||||||
|
}
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package info.nightscout.utils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 22.12.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SingleClickButton extends android.support.v7.widget.AppCompatButton implements View.OnClickListener {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(SingleClickButton.class);
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
OnClickListener listener = null;
|
||||||
|
|
||||||
|
public SingleClickButton(Context context) {
|
||||||
|
super(context);
|
||||||
|
this.context = context;
|
||||||
|
super.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleClickButton(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
this.context = context;
|
||||||
|
super.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleClickButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
this.context = context;
|
||||||
|
super.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnClickListener(@Nullable OnClickListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(final View v) {
|
||||||
|
setEnabled(false);
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
SystemClock.sleep(3000);
|
||||||
|
Activity activity = (Activity) context;
|
||||||
|
if (activity != null)
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setEnabled(true);
|
||||||
|
log.debug("Button enabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
if (listener != null)
|
||||||
|
listener.onClick(v);
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,8 @@ public class TimeListEdit {
|
||||||
private JSONArray data1;
|
private JSONArray data1;
|
||||||
private JSONArray data2;
|
private JSONArray data2;
|
||||||
private double step;
|
private double step;
|
||||||
|
private double min;
|
||||||
|
private double max;
|
||||||
private NumberFormat formatter;
|
private NumberFormat formatter;
|
||||||
private Runnable save;
|
private Runnable save;
|
||||||
private LinearLayout layout;
|
private LinearLayout layout;
|
||||||
|
@ -59,7 +61,7 @@ public class TimeListEdit {
|
||||||
private int inflatedUntil = -1;
|
private int inflatedUntil = -1;
|
||||||
|
|
||||||
|
|
||||||
public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double step, NumberFormat formatter, Runnable save) {
|
public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double min, double max, double step, NumberFormat formatter, Runnable save) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.resLayoutId = resLayoutId;
|
this.resLayoutId = resLayoutId;
|
||||||
|
@ -67,6 +69,8 @@ public class TimeListEdit {
|
||||||
this.data1 = data1;
|
this.data1 = data1;
|
||||||
this.data2 = data2;
|
this.data2 = data2;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
this.save = save;
|
this.save = save;
|
||||||
buildView();
|
buildView();
|
||||||
|
@ -239,8 +243,8 @@ public class TimeListEdit {
|
||||||
if (i == 0) next = ONEHOURINSECONDS;
|
if (i == 0) next = ONEHOURINSECONDS;
|
||||||
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
|
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
|
||||||
|
|
||||||
editText1.setParams(value1(i), 0.1d, 100d, step, formatter, false);
|
editText1.setParams(value1(i), min, max, step, formatter, false);
|
||||||
editText2.setParams(value2(i), 0.1d, 100d, step, formatter, false);
|
editText2.setParams(value2(i), min, max, step, formatter, false);
|
||||||
|
|
||||||
if (data2 == null) {
|
if (data2 == null) {
|
||||||
editText2.setVisibility(View.GONE);
|
editText2.setVisibility(View.GONE);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_profileswitch"
|
android:id="@+id/actions_profileswitch"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
android:drawableTop="@drawable/icon_actions_profileswitch"
|
android:drawableTop="@drawable/icon_actions_profileswitch"
|
||||||
android:text="@string/careportal_profileswitch" />
|
android:text="@string/careportal_profileswitch" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_temptarget"
|
android:id="@+id/actions_temptarget"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
android:drawableTop="@drawable/icon_actions_temptarget"
|
android:drawableTop="@drawable/icon_actions_temptarget"
|
||||||
android:text="@string/careportal_temporarytarget" />
|
android:text="@string/careportal_temporarytarget" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_settempbasal"
|
android:id="@+id/actions_settempbasal"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
android:drawableTop="@drawable/icon_actions_starttempbasal"
|
android:drawableTop="@drawable/icon_actions_starttempbasal"
|
||||||
android:text="@string/overview_tempbasal_button" />
|
android:text="@string/overview_tempbasal_button" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_canceltempbasal"
|
android:id="@+id/actions_canceltempbasal"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
android:drawableTop="@drawable/icon_cancelbasal"
|
android:drawableTop="@drawable/icon_cancelbasal"
|
||||||
android:text="Cancel temp basal" />
|
android:text="Cancel temp basal" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_extendedbolus"
|
android:id="@+id/actions_extendedbolus"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
android:drawableTop="@drawable/icon_actions_startextbolus"
|
android:drawableTop="@drawable/icon_actions_startextbolus"
|
||||||
android:text="@string/overview_extendedbolus_button" />
|
android:text="@string/overview_extendedbolus_button" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_extendedbolus_cancel"
|
android:id="@+id/actions_extendedbolus_cancel"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
android:drawableTop="@drawable/icon_actions_cancelextbolus"
|
android:drawableTop="@drawable/icon_actions_cancelextbolus"
|
||||||
android:text="@string/overview_extendedbolus_cancel_button" />
|
android:text="@string/overview_extendedbolus_cancel_button" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/actions_fill"
|
android:id="@+id/actions_fill"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
22
app/src/main/res/layout/bgsource_fragment.xml
Normal file
22
app/src/main/res/layout/bgsource_fragment.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/bgsource_recyclerview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
78
app/src/main/res/layout/bgsource_item.xml
Normal file
78
app/src/main/res/layout/bgsource_item.xml
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/bgsource_cardview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
card_view:cardBackgroundColor="@color/cardColorBackground"
|
||||||
|
card_view:cardCornerRadius="6dp"
|
||||||
|
card_view:cardUseCompatPadding="true"
|
||||||
|
card_view:contentPadding="6dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bgsource_date"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="16:55"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bgsource_value"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:text="Name"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bgsource_direction"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:text="-" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ns_sign"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:text="NS"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
android:textColor="@color/colorSetTempButton" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/invalid_sign"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:text="@string/invalid"
|
||||||
|
android:textColor="@android:color/holo_red_light" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bgsource_remove"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:text="@string/overview_quickwizard_item_remove_button"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
android:textColor="@android:color/holo_orange_light" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
|
@ -51,7 +51,7 @@
|
||||||
android:padding="10dip"
|
android:padding="10dip"
|
||||||
app:columnCount="3">
|
app:columnCount="3">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_bgcheck"
|
android:id="@+id/careportal_bgcheck"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="0" />
|
app:layout_row="0" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_exercise"
|
android:id="@+id/careportal_exercise"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="0" />
|
app:layout_row="0" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_temporarytarget"
|
android:id="@+id/careportal_temporarytarget"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
android:padding="10dip"
|
android:padding="10dip"
|
||||||
app:columnCount="3">
|
app:columnCount="3">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_snackbolus"
|
android:id="@+id/careportal_snackbolus"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_mealbolus"
|
android:id="@+id/careportal_mealbolus"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_correctionbolus"
|
android:id="@+id/careportal_correctionbolus"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_carbscorrection"
|
android:id="@+id/careportal_carbscorrection"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -167,7 +167,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="2" />
|
app:layout_row="2" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_combobolus"
|
android:id="@+id/careportal_combobolus"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="2" />
|
app:layout_row="2" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_tempbasalstart"
|
android:id="@+id/careportal_tempbasalstart"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="2" />
|
app:layout_row="2" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_tempbasalend"
|
android:id="@+id/careportal_tempbasalend"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -225,7 +225,7 @@
|
||||||
android:padding="10dip"
|
android:padding="10dip"
|
||||||
app:columnCount="3">
|
app:columnCount="3">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_cgmsensorstart"
|
android:id="@+id/careportal_cgmsensorstart"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -240,7 +240,7 @@
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_cgmsensorinsert"
|
android:id="@+id/careportal_cgmsensorinsert"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -255,7 +255,7 @@
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_openapsoffline"
|
android:id="@+id/careportal_openapsoffline"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -270,7 +270,7 @@
|
||||||
app:layout_row="1" />
|
app:layout_row="1" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_announcement"
|
android:id="@+id/careportal_announcement"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="4" />
|
app:layout_row="4" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_question"
|
android:id="@+id/careportal_question"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -298,7 +298,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="4" />
|
app:layout_row="4" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_note"
|
android:id="@+id/careportal_note"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -328,7 +328,7 @@
|
||||||
android:padding="10dip"
|
android:padding="10dip"
|
||||||
app:columnCount="3">
|
app:columnCount="3">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_pumpsitechange"
|
android:id="@+id/careportal_pumpsitechange"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -342,7 +342,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="0" />
|
app:layout_row="0" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_insulincartridgechange"
|
android:id="@+id/careportal_insulincartridgechange"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -356,7 +356,7 @@
|
||||||
app:layout_gravity="fill"
|
app:layout_gravity="fill"
|
||||||
app:layout_row="0" />
|
app:layout_row="0" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_profileswitch"
|
android:id="@+id/careportal_profileswitch"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
app:layout_row="0" />
|
app:layout_row="0" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/careportal_pumpbatterychange"
|
android:id="@+id/careportal_pumpbatterychange"
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -4,70 +4,157 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog">
|
tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.EditQuickWizardDialog">
|
||||||
|
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:layout_margin="15dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@string/overview_editquickwizard_buttontext"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="text"
|
|
||||||
android:ems="10"
|
|
||||||
android:id="@+id/overview_editquickwizard_button_edit" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@string/overview_editquickwizard_carbs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:ems="10"
|
|
||||||
android:id="@+id/overview_editquickwizard_carbs_edit" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@string/overview_editquickwizard_valid"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Spinner
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/overview_editquickwizard_from_spinner"
|
android:text="@string/overview_editquickwizard_buttontext"
|
||||||
android:layout_weight="1" />
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
<Spinner
|
<EditText
|
||||||
|
android:id="@+id/overview_editquickwizard_button_edit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/overview_editquickwizard_to_spinner"
|
android:ems="10"
|
||||||
android:layout_weight="1" />
|
android:inputType="text" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_carbs"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/overview_editquickwizard_carbs_edit"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="numberDecimal" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_valid"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_from_spinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_to_spinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usebg"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usebg_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseBGArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usebolusiob"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usebolusiob_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseBolusIOBArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usebasaliob"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usebasaliob_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseBasalOBArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usecob"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usecob_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseCOBArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usetrend"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usetrend_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseTrendArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_editquickwizard_usesuperbolus_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usesuperbolus"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usesuperbolus_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseSuperBolusArray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/overview_editquickwizard_usetemptarget"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_editquickwizard_usetemptarget_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:entries="@array/quickWizardUseTempTargetArray" />
|
||||||
|
|
||||||
|
<include layout="@layout/mdtp_done_button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
</ScrollView>
|
||||||
android:text="@string/ok"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/overview_editquickwizard_ok_button"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -381,7 +381,7 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_accepttempbutton"
|
android:id="@+id/overview_accepttempbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -398,7 +398,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_treatmentbutton"
|
android:id="@+id/overview_treatmentbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -413,7 +413,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_wizardbutton"
|
android:id="@+id/overview_wizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -428,7 +428,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_calibrationbutton"
|
android:id="@+id/overview_calibrationbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -443,7 +443,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_quickwizardbutton"
|
android:id="@+id/overview_quickwizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
|
|
@ -593,7 +593,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_treatmentbutton"
|
android:id="@+id/overview_treatmentbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -607,7 +607,7 @@
|
||||||
android:textColor="@color/colorTreatmentButton"
|
android:textColor="@color/colorTreatmentButton"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_wizardbutton"
|
android:id="@+id/overview_wizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -622,7 +622,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_quickwizardbutton"
|
android:id="@+id/overview_quickwizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
|
|
@ -691,7 +691,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_treatmentbutton"
|
android:id="@+id/overview_treatmentbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -705,7 +705,7 @@
|
||||||
android:textColor="@color/colorTreatmentButton"
|
android:textColor="@color/colorTreatmentButton"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_wizardbutton"
|
android:id="@+id/overview_wizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -720,7 +720,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_calibrationbutton"
|
android:id="@+id/overview_calibrationbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
@ -735,7 +735,7 @@
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<info.nightscout.utils.SingleClickButton
|
||||||
android:id="@+id/overview_quickwizardbutton"
|
android:id="@+id/overview_quickwizardbutton"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue