Merge branch 'dev' into lp-edit
This commit is contained in:
commit
5c6e598cd6
12
.travis.yml
12
.travis.yml
|
@ -18,7 +18,17 @@ before_install:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Unit Test
|
# Unit Test
|
||||||
- ./gradlew -Pcoverage test jacocoTestReport
|
- ./gradlew -Pcoverage testFullDebugUnitTest jacocoTestFullDebugUnitTestReport
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
||||||
|
before_cache:
|
||||||
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.gradle/caches/
|
||||||
|
- $HOME/.gradle/wrapper/
|
||||||
|
- $HOME/.android/build-cache
|
|
@ -15,8 +15,7 @@ apply plugin: "jacoco-android"
|
||||||
apply plugin: 'com.jakewharton.butterknife'
|
apply plugin: 'com.jakewharton.butterknife'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
supportLibraryVersion = "27.0.2"
|
supportLibraryVersion = "27.1.0"
|
||||||
sdkBuildVersion = "27.0.3"
|
|
||||||
ormLiteVersion = "4.46"
|
ormLiteVersion = "4.46"
|
||||||
powermockVersion = "1.7.3"
|
powermockVersion = "1.7.3"
|
||||||
dexmakerVersion = "1.2"
|
dexmakerVersion = "1.2"
|
||||||
|
@ -57,15 +56,14 @@ tasks.matching {it instanceof Test}.all {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 27
|
||||||
buildToolsVersion "${sdkBuildVersion}"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.androidaps"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion 25
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
version "1.60c-dev"
|
version "1.60d-dev"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -78,7 +76,7 @@ android {
|
||||||
// TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0
|
// TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0
|
||||||
// has been upgraded (requiring significant code changes), which currently fails release
|
// has been upgraded (requiring significant code changes), which currently fails release
|
||||||
// build with a deprecation warning
|
// build with a deprecation warning
|
||||||
// abortOnError false
|
abortOnError false
|
||||||
// (disabled entirely to avoid reports on the error, which would still be displayed
|
// (disabled entirely to avoid reports on the error, which would still be displayed
|
||||||
// and it's easy to overlook that it's ignored)
|
// and it's easy to overlook that it's ignored)
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
|
@ -183,7 +181,7 @@ dependencies {
|
||||||
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") {
|
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") {
|
||||||
transitive = true;
|
transitive = true;
|
||||||
}
|
}
|
||||||
libs 'MilosKozak:danars-support-lib:master@zip'
|
libs "MilosKozak:danars-support-lib:master@zip"
|
||||||
|
|
||||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
||||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
||||||
|
|
Binary file not shown.
|
@ -32,7 +32,6 @@ public class Config {
|
||||||
public static final boolean logPumpComm = true;
|
public static final boolean logPumpComm = true;
|
||||||
public static final boolean logPrefsChange = true;
|
public static final boolean logPrefsChange = true;
|
||||||
public static final boolean logConfigBuilder = true;
|
public static final boolean logConfigBuilder = true;
|
||||||
public static final boolean logConstraintsChanges = true;
|
|
||||||
public static final boolean logNSUpload = true;
|
public static final boolean logNSUpload = true;
|
||||||
public static final boolean logPumpActions = true;
|
public static final boolean logPumpActions = true;
|
||||||
public static final boolean logCongigBuilderActions = true;
|
public static final boolean logCongigBuilderActions = true;
|
||||||
|
@ -43,6 +42,4 @@ public class Config {
|
||||||
public static final boolean logDanaBTComm = true;
|
public static final boolean logDanaBTComm = true;
|
||||||
public static boolean logDanaMessageDetail = true;
|
public static boolean logDanaMessageDetail = true;
|
||||||
public static final boolean logDanaSerialEngine = true;
|
public static final boolean logDanaSerialEngine = true;
|
||||||
|
|
||||||
public static final boolean enableComboBetaFeatures = false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@ public class Constants {
|
||||||
|
|
||||||
// Temp targets
|
// Temp targets
|
||||||
public static final int defaultActivityTTDuration = 90; // min
|
public static final int defaultActivityTTDuration = 90; // min
|
||||||
public static final double defaultActivityTTmgdl = 90d;
|
public static final double defaultActivityTTmgdl = 140d;
|
||||||
public static final double defaultActivityTTmmol = 8d;
|
public static final double defaultActivityTTmmol = 8d;
|
||||||
public static final int defaultEatingSoonTTDuration = 45; // min
|
public static final int defaultEatingSoonTTDuration = 45; // min
|
||||||
public static final double defaultEatingSoonTTmgdl = 140d;
|
public static final double defaultEatingSoonTTmgdl = 90d;
|
||||||
public static final double defaultEatingSoonTTmmol = 5d;
|
public static final double defaultEatingSoonTTmmol = 5d;
|
||||||
public static final int defaultHypoTTDuration = 30; // min
|
public static final int defaultHypoTTDuration = 30; // min
|
||||||
public static final double defaultHypoTTmgdl = 120d;
|
public static final double defaultHypoTTmgdl = 120d;
|
||||||
|
|
|
@ -48,6 +48,7 @@ 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.Food.FoodPlugin;
|
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.tabs.SlidingTabLayout;
|
import info.nightscout.androidaps.tabs.SlidingTabLayout;
|
||||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||||
import info.nightscout.utils.ImportExportPrefs;
|
import info.nightscout.utils.ImportExportPrefs;
|
||||||
|
@ -378,7 +379,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
MainApp.getDbHelper().resetDatabases();
|
MainApp.getDbHelper().resetDatabases();
|
||||||
// should be handled by Plugin-Interface and
|
// should be handled by Plugin-Interface and
|
||||||
// additional service interface and plugin registry
|
// additional service interface and plugin registry
|
||||||
MainApp.getSpecificPlugin(FoodPlugin.class).getService().resetFood();
|
FoodPlugin.getPlugin().getService().resetFood();
|
||||||
|
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create()
|
.create()
|
||||||
|
@ -403,7 +405,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
else
|
else
|
||||||
builder.setIcon(R.mipmap.blueowl);
|
builder.setIcon(R.mipmap.blueowl);
|
||||||
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
||||||
message += MainApp.sResources.getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName;
|
message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n";
|
||||||
|
message += getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName;
|
||||||
if (MainApp.engineeringMode)
|
if (MainApp.engineeringMode)
|
||||||
message += "\n" + MainApp.gs(R.string.engineering_mode_enabled);
|
message += "\n" + MainApp.gs(R.string.engineering_mode_enabled);
|
||||||
message += getString(R.string.about_link_urls);
|
message += getString(R.string.about_link_urls);
|
||||||
|
|
|
@ -212,11 +212,6 @@ public class MainApp extends Application {
|
||||||
startKeepAliveService();
|
startKeepAliveService();
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEngineeringModeOrRelease()) {
|
|
||||||
Notification n = new Notification(Notification.TOAST_ALARM, gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL);
|
|
||||||
bus().post(new EventNewNotification(n));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerLocalBroadcastReceiver() {
|
private void registerLocalBroadcastReceiver() {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.data.ProfileStore;
|
||||||
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.events.EventNsFood;
|
import info.nightscout.androidaps.events.EventNsFood;
|
||||||
|
import info.nightscout.androidaps.events.EventNsTreatment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
||||||
|
@ -40,6 +41,7 @@ import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.utils.BundleLogger;
|
import info.nightscout.utils.BundleLogger;
|
||||||
|
import info.nightscout.utils.JsonHelper;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -382,19 +384,18 @@ public class DataService extends IntentService {
|
||||||
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
|
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
|
||||||
try {
|
try {
|
||||||
if (bundles.containsKey("treatment")) {
|
if (bundles.containsKey("treatment")) {
|
||||||
String trstring = bundles.getString("treatment");
|
JSONObject json = new JSONObject(bundles.getString("treatment"));
|
||||||
handleAddChangeDataFromNS(trstring);
|
handleTreatmentFromNS(json, intent);
|
||||||
}
|
}
|
||||||
if (bundles.containsKey("treatments")) {
|
if (bundles.containsKey("treatments")) {
|
||||||
String trstring = bundles.getString("treatments");
|
String trstring = bundles.getString("treatments");
|
||||||
JSONArray jsonArray = new JSONArray(trstring);
|
JSONArray jsonArray = new JSONArray(trstring);
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
JSONObject trJson = jsonArray.getJSONObject(i);
|
JSONObject json = jsonArray.getJSONObject(i);
|
||||||
String trstr = trJson.toString();
|
handleTreatmentFromNS(json, intent);
|
||||||
handleAddChangeDataFromNS(trstr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,21 +404,19 @@ public class DataService extends IntentService {
|
||||||
try {
|
try {
|
||||||
if (bundles.containsKey("treatment")) {
|
if (bundles.containsKey("treatment")) {
|
||||||
String trstring = bundles.getString("treatment");
|
String trstring = bundles.getString("treatment");
|
||||||
JSONObject trJson = new JSONObject(trstring);
|
JSONObject json = new JSONObject(trstring);
|
||||||
String _id = trJson.getString("_id");
|
handleTreatmentFromNS(json);
|
||||||
handleRemovedRecordFromNS(_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bundles.containsKey("treatments")) {
|
if (bundles.containsKey("treatments")) {
|
||||||
String trstring = bundles.getString("treatments");
|
String trstring = bundles.getString("treatments");
|
||||||
JSONArray jsonArray = new JSONArray(trstring);
|
JSONArray jsonArray = new JSONArray(trstring);
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
JSONObject trJson = jsonArray.getJSONObject(i);
|
JSONObject json = jsonArray.getJSONObject(i);
|
||||||
String _id = trJson.getString("_id");
|
handleTreatmentFromNS(json);
|
||||||
handleRemovedRecordFromNS(_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,8 +488,12 @@ public class DataService extends IntentService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleRemovedRecordFromNS(String _id) {
|
private void handleTreatmentFromNS(JSONObject json) {
|
||||||
MainApp.getDbHelper().deleteTreatmentById(_id);
|
// new DB model
|
||||||
|
EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.REMOVE, json);
|
||||||
|
MainApp.bus().post(evtTreatment);
|
||||||
|
// old DB model
|
||||||
|
String _id = JsonHelper.safeGetString(json, "_id");
|
||||||
MainApp.getDbHelper().deleteTempTargetById(_id);
|
MainApp.getDbHelper().deleteTempTargetById(_id);
|
||||||
MainApp.getDbHelper().deleteTempBasalById(_id);
|
MainApp.getDbHelper().deleteTempBasalById(_id);
|
||||||
MainApp.getDbHelper().deleteExtendedBolusById(_id);
|
MainApp.getDbHelper().deleteExtendedBolusById(_id);
|
||||||
|
@ -498,86 +501,53 @@ public class DataService extends IntentService {
|
||||||
MainApp.getDbHelper().deleteProfileSwitchById(_id);
|
MainApp.getDbHelper().deleteProfileSwitchById(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAddChangeDataFromNS(String trstring) throws JSONException {
|
private void handleTreatmentFromNS(JSONObject json, Intent intent) throws JSONException {
|
||||||
JSONObject trJson = new JSONObject(trstring);
|
// new DB model
|
||||||
handleDanaRHistoryRecords(trJson); // update record _id in history
|
int mode = Intents.ACTION_NEW_TREATMENT.equals(intent.getAction()) ? EventNsTreatment.ADD : EventNsTreatment.UPDATE;
|
||||||
handleAddChangeTempTargetRecord(trJson);
|
double insulin = JsonHelper.safeGetDouble(json, "insulin");
|
||||||
handleAddChangeTempBasalRecord(trJson);
|
double carbs = JsonHelper.safeGetDouble(json, "carbs");
|
||||||
handleAddChangeExtendedBolusRecord(trJson);
|
String eventType = JsonHelper.safeGetString(json, "eventType");
|
||||||
handleAddChangeCareportalEventRecord(trJson);
|
if (insulin > 0 || carbs > 0) {
|
||||||
handleAddChangeTreatmentRecord(trJson);
|
EventNsTreatment evtTreatment = new EventNsTreatment(mode, json);
|
||||||
handleAddChangeProfileSwitchRecord(trJson);
|
MainApp.bus().post(evtTreatment);
|
||||||
}
|
} else if (json.has(DanaRNSHistorySync.DANARSIGNATURE)) {
|
||||||
|
// old DB model
|
||||||
public void handleDanaRHistoryRecords(JSONObject trJson) {
|
MainApp.getDbHelper().updateDanaRHistoryRecordId(json);
|
||||||
if (trJson.has(DanaRNSHistorySync.DANARSIGNATURE)) {
|
} else if (eventType.equals(CareportalEvent.TEMPORARYTARGET)) {
|
||||||
MainApp.getDbHelper().updateDanaRHistoryRecordId(trJson);
|
MainApp.getDbHelper().createTemptargetFromJsonIfNotExists(json);
|
||||||
}
|
} else if (eventType.equals(CareportalEvent.TEMPBASAL)) {
|
||||||
}
|
MainApp.getDbHelper().createTempBasalFromJsonIfNotExists(json);
|
||||||
|
} else if (eventType.equals(CareportalEvent.COMBOBOLUS)) {
|
||||||
public void handleAddChangeTreatmentRecord(JSONObject trJson) throws JSONException {
|
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json);
|
||||||
if (trJson.has("insulin") || trJson.has("carbs")) {
|
} else if (eventType.equals(CareportalEvent.PROFILESWITCH)) {
|
||||||
MainApp.getDbHelper().createTreatmentFromJsonIfNotExists(trJson);
|
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(json);
|
||||||
return;
|
} else if (eventType.equals(CareportalEvent.SITECHANGE) ||
|
||||||
}
|
eventType.equals(CareportalEvent.INSULINCHANGE) ||
|
||||||
}
|
eventType.equals(CareportalEvent.SENSORCHANGE) ||
|
||||||
|
eventType.equals(CareportalEvent.BGCHECK) ||
|
||||||
public void handleAddChangeTempTargetRecord(JSONObject trJson) throws JSONException {
|
eventType.equals(CareportalEvent.NOTE) ||
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.TEMPORARYTARGET)) {
|
eventType.equals(CareportalEvent.NONE) ||
|
||||||
MainApp.getDbHelper().createTemptargetFromJsonIfNotExists(trJson);
|
eventType.equals(CareportalEvent.ANNOUNCEMENT) ||
|
||||||
}
|
eventType.equals(CareportalEvent.QUESTION) ||
|
||||||
}
|
eventType.equals(CareportalEvent.EXERCISE) ||
|
||||||
|
eventType.equals(CareportalEvent.OPENAPSOFFLINE) ||
|
||||||
public void handleAddChangeTempBasalRecord(JSONObject trJson) throws JSONException {
|
eventType.equals(CareportalEvent.PUMPBATTERYCHANGE)) {
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.TEMPBASAL)) {
|
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(json);
|
||||||
MainApp.getDbHelper().createTempBasalFromJsonIfNotExists(trJson);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleAddChangeExtendedBolusRecord(JSONObject trJson) throws JSONException {
|
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.COMBOBOLUS)) {
|
|
||||||
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(trJson);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleAddChangeCareportalEventRecord(JSONObject trJson) throws JSONException {
|
|
||||||
if (trJson.has("insulin") && trJson.getDouble("insulin") > 0)
|
|
||||||
return;
|
|
||||||
if (trJson.has("carbs") && trJson.getDouble("carbs") > 0)
|
|
||||||
return;
|
|
||||||
if (trJson.has("eventType") && (
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.SITECHANGE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.INSULINCHANGE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.SENSORCHANGE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.BGCHECK) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.NOTE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.NONE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.QUESTION) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.EXERCISE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.OPENAPSOFFLINE) ||
|
|
||||||
trJson.getString("eventType").equals(CareportalEvent.PUMPBATTERYCHANGE)
|
|
||||||
)) {
|
|
||||||
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(trJson);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
|
if (eventType.equals(CareportalEvent.ANNOUNCEMENT)) {
|
||||||
long date = trJson.getLong("mills");
|
long date = JsonHelper.safeGetLong(json,"mills");
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (date > now - 15 * 60 * 1000L && trJson.has("notes")
|
String enteredBy = JsonHelper.safeGetString(json, "enteredBy", "");
|
||||||
&& !(trJson.has("enteredBy") && trJson.getString("enteredBy").equals(SP.getString("careportal_enteredby", "AndroidAPS")))) {
|
String notes = JsonHelper.safeGetString(json, "notes", "");
|
||||||
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, trJson.getString("notes"), Notification.ANNOUNCEMENT, 60);
|
if (date > now - 15 * 60 * 1000L && !notes.isEmpty()
|
||||||
|
&& !enteredBy.equals(SP.getString("careportal_enteredby", "AndroidAPS"))) {
|
||||||
|
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60);
|
||||||
MainApp.bus().post(new EventNewNotification(announcement));
|
MainApp.bus().post(new EventNewNotification(announcement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleAddChangeProfileSwitchRecord(JSONObject trJson) throws JSONException {
|
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.PROFILESWITCH)) {
|
|
||||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(trJson);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleNewSMS(Intent intent) {
|
private void handleNewSMS(Intent intent) {
|
||||||
Bundle bundle = intent.getExtras();
|
Bundle bundle = intent.getExtras();
|
||||||
if (bundle == null) return;
|
if (bundle == null) return;
|
||||||
|
|
|
@ -98,6 +98,14 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
|
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOlderThan(double hours) {
|
||||||
|
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
||||||
|
if(diff.get(TimeUnit.DAYS)*24 + diff.get(TimeUnit.HOURS) > hours)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String log() {
|
public String log() {
|
||||||
return "CareportalEvent{" +
|
return "CareportalEvent{" +
|
||||||
"date= " + date +
|
"date= " + date +
|
||||||
|
@ -259,4 +267,5 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
public int getSecondColor() {
|
public int getSecondColor() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
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.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
|
@ -43,15 +41,10 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
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.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.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.PercentageSplitter;
|
import info.nightscout.utils.PercentageSplitter;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
@ -72,7 +65,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static final String DATABASE_TEMPORARYBASALS = "TemporaryBasals";
|
public static final String DATABASE_TEMPORARYBASALS = "TemporaryBasals";
|
||||||
public static final String DATABASE_EXTENDEDBOLUSES = "ExtendedBoluses";
|
public static final String DATABASE_EXTENDEDBOLUSES = "ExtendedBoluses";
|
||||||
public static final String DATABASE_TEMPTARGETS = "TempTargets";
|
public static final String DATABASE_TEMPTARGETS = "TempTargets";
|
||||||
public static final String DATABASE_TREATMENTS = "Treatments";
|
|
||||||
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
||||||
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
||||||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||||
|
@ -81,14 +73,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 8;
|
private static final int DATABASE_VERSION = 8;
|
||||||
|
|
||||||
private static Long earliestDataChange = null;
|
public static Long earliestDataChange = null;
|
||||||
|
|
||||||
private static final ScheduledExecutorService bgWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService bgWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledBgPost = null;
|
private static ScheduledFuture<?> scheduledBgPost = null;
|
||||||
|
|
||||||
private static final ScheduledExecutorService treatmentsWorker = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
private static ScheduledFuture<?> scheduledTratmentPost = null;
|
|
||||||
|
|
||||||
private static final ScheduledExecutorService tempBasalsWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService tempBasalsWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledTemBasalsPost = null;
|
private static ScheduledFuture<?> scheduledTemBasalsPost = null;
|
||||||
|
|
||||||
|
@ -118,7 +107,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
try {
|
try {
|
||||||
log.info("onCreate");
|
log.info("onCreate");
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
|
||||||
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
|
TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, DbRequest.class);
|
TableUtils.createTableIfNotExists(connectionSource, DbRequest.class);
|
||||||
|
@ -141,12 +129,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
if (oldVersion == 7 && newVersion == 8) {
|
if (oldVersion == 7 && newVersion == 8) {
|
||||||
log.debug("Upgrading database from v7 to v8");
|
log.debug("Upgrading database from v7 to v8");
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
|
||||||
} else {
|
} else {
|
||||||
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
|
||||||
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
||||||
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
||||||
TableUtils.dropTable(connectionSource, DbRequest.class, true);
|
TableUtils.dropTable(connectionSource, DbRequest.class, true);
|
||||||
|
@ -178,40 +163,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUpDatabases() {
|
|
||||||
// TODO: call it somewhere
|
|
||||||
log.debug("Before BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
|
||||||
getWritableDatabase().delete(DATABASE_BGREADINGS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
|
||||||
|
|
||||||
log.debug("Before TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
|
||||||
getWritableDatabase().delete(DATABASE_TEMPTARGETS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
|
||||||
|
|
||||||
log.debug("Before Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
|
||||||
getWritableDatabase().delete(DATABASE_TREATMENTS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
|
||||||
|
|
||||||
log.debug("Before History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
|
|
||||||
getWritableDatabase().delete(DATABASE_DANARHISTORY, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
|
|
||||||
|
|
||||||
log.debug("Before TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS));
|
|
||||||
getWritableDatabase().delete(DATABASE_TEMPORARYBASALS, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS));
|
|
||||||
|
|
||||||
log.debug("Before ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES));
|
|
||||||
getWritableDatabase().delete(DATABASE_EXTENDEDBOLUSES, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES));
|
|
||||||
|
|
||||||
log.debug("Before CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS));
|
|
||||||
getWritableDatabase().delete(DATABASE_CAREPORTALEVENTS, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS));
|
|
||||||
|
|
||||||
log.debug("Before ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES));
|
|
||||||
getWritableDatabase().delete(DATABASE_PROFILESWITCHES, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
|
|
||||||
log.debug("After ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES));
|
|
||||||
}
|
|
||||||
|
|
||||||
public long size(String database) {
|
public long size(String database) {
|
||||||
return DatabaseUtils.queryNumEntries(getReadableDatabase(), database);
|
return DatabaseUtils.queryNumEntries(getReadableDatabase(), database);
|
||||||
|
@ -222,7 +173,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void resetDatabases() {
|
public void resetDatabases() {
|
||||||
try {
|
try {
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
|
||||||
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
||||||
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
||||||
TableUtils.dropTable(connectionSource, DbRequest.class, true);
|
TableUtils.dropTable(connectionSource, DbRequest.class, true);
|
||||||
|
@ -232,7 +182,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
||||||
TableUtils.dropTable(connectionSource, TDD.class, true);
|
TableUtils.dropTable(connectionSource, TDD.class, true);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
|
||||||
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
|
TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, DbRequest.class);
|
TableUtils.createTableIfNotExists(connectionSource, DbRequest.class);
|
||||||
|
@ -248,7 +197,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.setFakingStatus(true);
|
||||||
scheduleBgChange(null); // trigger refresh
|
scheduleBgChange(null); // trigger refresh
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
scheduleTreatmentChange(null);
|
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
scheduleCareportalEventChange();
|
scheduleCareportalEventChange();
|
||||||
|
@ -264,17 +212,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetTreatments() {
|
|
||||||
try {
|
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
|
||||||
updateEarliestDataChange(0);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
scheduleTreatmentChange(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetTempTargets() {
|
public void resetTempTargets() {
|
||||||
try {
|
try {
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
|
@ -343,11 +280,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return getDao(TempTarget.class);
|
return getDao(TempTarget.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dao<Treatment, Long> getDaoTreatments() throws SQLException {
|
private Dao<BgReading, Long> getDaoBgReadings() throws SQLException {
|
||||||
return getDao(Treatment.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dao<BgReading, Long> getDaoBgReadings() throws SQLException {
|
|
||||||
return getDao(BgReading.class);
|
return getDao(BgReading.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +312,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return getDao(ProfileSwitch.class);
|
return getDao(ProfileSwitch.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long roundDateToSec(long date) {
|
public static long roundDateToSec(long date) {
|
||||||
return date - date % 1000;
|
return date - date % 1000;
|
||||||
}
|
}
|
||||||
// ------------------- BgReading handling -----------------------
|
// ------------------- BgReading handling -----------------------
|
||||||
|
@ -604,147 +537,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
// -------------------- TREATMENT HANDLING -------------------
|
// -------------------- TREATMENT HANDLING -------------------
|
||||||
|
|
||||||
// return true if new record is created
|
public static void updateEarliestDataChange(long newDate) {
|
||||||
public boolean createOrUpdate(Treatment treatment) {
|
|
||||||
try {
|
|
||||||
Treatment old;
|
|
||||||
treatment.date = roundDateToSec(treatment.date);
|
|
||||||
|
|
||||||
if (treatment.source == Source.PUMP) {
|
|
||||||
// check for changed from pump change in NS
|
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = getDaoTreatments().queryBuilder();
|
|
||||||
Where where = queryBuilder.where();
|
|
||||||
where.eq("pumpId", treatment.pumpId);
|
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
|
||||||
List<Treatment> trList = getDaoTreatments().query(preparedQuery);
|
|
||||||
if (trList.size() > 0) {
|
|
||||||
// do nothing, pump history record cannot be changed
|
|
||||||
log.debug("TREATMENT: Pump record already found in database: " + treatment.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
getDaoTreatments().create(treatment);
|
|
||||||
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
updateEarliestDataChange(treatment.date);
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (treatment.source == Source.NIGHTSCOUT) {
|
|
||||||
old = getDaoTreatments().queryForId(treatment.date);
|
|
||||||
if (old != null) {
|
|
||||||
if (!old.isEqual(treatment)) {
|
|
||||||
boolean historyChange = old.isDataChanging(treatment);
|
|
||||||
long oldDate = old.date;
|
|
||||||
getDaoTreatments().delete(old); // need to delete/create because date may change too
|
|
||||||
old.copyFrom(treatment);
|
|
||||||
getDaoTreatments().create(old);
|
|
||||||
log.debug("TREATMENT: Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
if (historyChange) {
|
|
||||||
updateEarliestDataChange(oldDate);
|
|
||||||
updateEarliestDataChange(old.date);
|
|
||||||
}
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// find by NS _id
|
|
||||||
if (treatment._id != null) {
|
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = getDaoTreatments().queryBuilder();
|
|
||||||
Where where = queryBuilder.where();
|
|
||||||
where.eq("_id", treatment._id);
|
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
|
||||||
List<Treatment> trList = getDaoTreatments().query(preparedQuery);
|
|
||||||
if (trList.size() > 0) {
|
|
||||||
old = trList.get(0);
|
|
||||||
if (!old.isEqual(treatment)) {
|
|
||||||
boolean historyChange = old.isDataChanging(treatment);
|
|
||||||
long oldDate = old.date;
|
|
||||||
getDaoTreatments().delete(old); // need to delete/create because date may change too
|
|
||||||
old.copyFrom(treatment);
|
|
||||||
getDaoTreatments().create(old);
|
|
||||||
log.debug("TREATMENT: Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
|
||||||
if (historyChange) {
|
|
||||||
updateEarliestDataChange(oldDate);
|
|
||||||
updateEarliestDataChange(old.date);
|
|
||||||
}
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getDaoTreatments().create(treatment);
|
|
||||||
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
updateEarliestDataChange(treatment.date);
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (treatment.source == Source.USER) {
|
|
||||||
getDaoTreatments().create(treatment);
|
|
||||||
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
|
||||||
updateEarliestDataChange(treatment.date);
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete(Treatment treatment) {
|
|
||||||
try {
|
|
||||||
getDaoTreatments().delete(treatment);
|
|
||||||
updateEarliestDataChange(treatment.date);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Treatment treatment) {
|
|
||||||
try {
|
|
||||||
getDaoTreatments().update(treatment);
|
|
||||||
updateEarliestDataChange(treatment.date);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
scheduleTreatmentChange(treatment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteTreatmentById(String _id) {
|
|
||||||
Treatment stored = findTreatmentById(_id);
|
|
||||||
if (stored != null) {
|
|
||||||
log.debug("TREATMENT: Removing Treatment record from database: " + stored.toString());
|
|
||||||
delete(stored);
|
|
||||||
updateEarliestDataChange(stored.date);
|
|
||||||
scheduleTreatmentChange(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private Treatment findTreatmentById(String _id) {
|
|
||||||
try {
|
|
||||||
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
|
||||||
Where where = queryBuilder.where();
|
|
||||||
where.eq("_id", _id);
|
|
||||||
queryBuilder.limit(10L);
|
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
|
||||||
List<Treatment> trList = daoTreatments.query(preparedQuery);
|
|
||||||
if (trList.size() != 1) {
|
|
||||||
//log.debug("Treatment findTreatmentById query size: " + trList.size());
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
//log.debug("Treatment findTreatmentById found: " + trList.get(0).log());
|
|
||||||
return trList.get(0);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateEarliestDataChange(long newDate) {
|
|
||||||
if (earliestDataChange == null) {
|
if (earliestDataChange == null) {
|
||||||
earliestDataChange = newDate;
|
earliestDataChange = newDate;
|
||||||
return;
|
return;
|
||||||
|
@ -754,73 +547,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void scheduleTreatmentChange(@Nullable final Treatment treatment) {
|
|
||||||
class PostRunnable implements Runnable {
|
|
||||||
public void run() {
|
|
||||||
log.debug("Firing EventTreatmentChange");
|
|
||||||
MainApp.bus().post(new EventReloadTreatmentData(new EventTreatmentChange(treatment)));
|
|
||||||
if (earliestDataChange != null)
|
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
|
||||||
earliestDataChange = null;
|
|
||||||
scheduledTratmentPost = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// prepare task for execution in 1 sec
|
|
||||||
// cancel waiting task to prevent sending multiple posts
|
|
||||||
if (scheduledTratmentPost != null)
|
|
||||||
scheduledTratmentPost.cancel(false);
|
|
||||||
Runnable task = new PostRunnable();
|
|
||||||
final int sec = 1;
|
|
||||||
scheduledTratmentPost = treatmentsWorker.schedule(task, sec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
|
|
||||||
try {
|
|
||||||
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
|
||||||
List<Treatment> treatments;
|
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
|
||||||
queryBuilder.orderBy("date", ascending);
|
|
||||||
Where where = queryBuilder.where();
|
|
||||||
where.ge("date", mills);
|
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
|
||||||
treatments = daoTreatments.query(preparedQuery);
|
|
||||||
return treatments;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return new ArrayList<Treatment>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createTreatmentFromJsonIfNotExists(JSONObject trJson) {
|
|
||||||
try {
|
|
||||||
Treatment treatment = new Treatment();
|
|
||||||
treatment.source = Source.NIGHTSCOUT;
|
|
||||||
treatment.date = roundDateToSec(trJson.getLong("mills"));
|
|
||||||
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
|
|
||||||
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
|
||||||
treatment.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
|
||||||
treatment._id = trJson.getString("_id");
|
|
||||||
if (trJson.has("isSMB"))
|
|
||||||
treatment.isSMB = trJson.getBoolean("isSMB");
|
|
||||||
if (trJson.has("eventType")) {
|
|
||||||
treatment.mealBolus = !trJson.get("eventType").equals("Correction Bolus");
|
|
||||||
double carbs = treatment.carbs;
|
|
||||||
if (trJson.has("boluscalc")) {
|
|
||||||
JSONObject boluscalc = trJson.getJSONObject("boluscalc");
|
|
||||||
if (boluscalc.has("carbs")) {
|
|
||||||
carbs = Math.max(boluscalc.getDouble("carbs"), carbs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (carbs <= 0)
|
|
||||||
treatment.mealBolus = false;
|
|
||||||
}
|
|
||||||
createOrUpdate(treatment);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------- TempTargets handling ---------------
|
// ---------------- TempTargets handling ---------------
|
||||||
|
|
||||||
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
|
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
|
||||||
|
@ -1557,7 +1283,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public void deleteCareportalEventById(String _id) {
|
public void deleteCareportalEventById(String _id) {
|
||||||
try {
|
try {
|
||||||
QueryBuilder<CareportalEvent, Long> queryBuilder = null;
|
QueryBuilder<CareportalEvent, Long> queryBuilder;
|
||||||
queryBuilder = getDaoCareportalEvents().queryBuilder();
|
queryBuilder = getDaoCareportalEvents().queryBuilder();
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.eq("_id", _id);
|
where.eq("_id", _id);
|
||||||
|
@ -1580,7 +1306,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public void createCareportalEventFromJsonIfNotExists(JSONObject trJson) {
|
public void createCareportalEventFromJsonIfNotExists(JSONObject trJson) {
|
||||||
try {
|
try {
|
||||||
QueryBuilder<CareportalEvent, Long> queryBuilder = null;
|
QueryBuilder<CareportalEvent, Long> queryBuilder;
|
||||||
queryBuilder = getDaoCareportalEvents().queryBuilder();
|
queryBuilder = getDaoCareportalEvents().queryBuilder();
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.eq("_id", trJson.getString("_id")).or().eq("date", trJson.getLong("mills"));
|
where.eq("_id", trJson.getString("_id")).or().eq("date", trJson.getLong("mills"));
|
||||||
|
|
|
@ -12,19 +12,17 @@ import com.j256.ormlite.table.DatabaseTable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.j256.ormlite.table.DatabaseTable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -17,6 +16,7 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event which is published with data fetched from NightScout specific for the
|
||||||
|
* Treatment-class.
|
||||||
|
* <p>
|
||||||
|
* Payload is the from NS retrieved JSON-String which should be handled by all
|
||||||
|
* subscriber.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventNsTreatment extends Event {
|
||||||
|
|
||||||
|
public static final int ADD = 0;
|
||||||
|
public static final int UPDATE = 1;
|
||||||
|
public static final int REMOVE = 2;
|
||||||
|
|
||||||
|
private final int mode;
|
||||||
|
|
||||||
|
private final JSONObject payload;
|
||||||
|
|
||||||
|
public EventNsTreatment(int mode, JSONObject payload) {
|
||||||
|
this.mode = mode;
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.06.2016.
|
* Created by mike on 04.06.2016.
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 17.04.2017.
|
* Created by mike on 17.04.2017.
|
||||||
|
|
|
@ -150,13 +150,13 @@ public abstract class PluginBase {
|
||||||
|
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
if (getType() == PluginType.PUMP) {
|
if (getType() == PluginType.PUMP) {
|
||||||
new Thread(() -> {
|
try {
|
||||||
SystemClock.sleep(3000);
|
new Thread(() -> {
|
||||||
try {
|
SystemClock.sleep(3000);
|
||||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Pump driver changed.", null);
|
ConfigBuilderPlugin.getCommandQueue().readStatus("Pump driver changed.", null);
|
||||||
} catch (Exception ignored) { // Thread fail to start in tests
|
}).start();
|
||||||
}
|
} catch (Exception ignored) { // Thread fail to start in tests
|
||||||
}).start();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.Careportal;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -12,7 +13,9 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -21,11 +24,12 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
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.NSClientInternal.data.NSSettingsStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
|
||||||
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CareportalFragment.class);
|
||||||
|
|
||||||
TextView iage;
|
TextView iage;
|
||||||
TextView cage;
|
TextView cage;
|
||||||
|
@ -208,26 +212,54 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
public static void updateAge(Activity activity, final TextView sage, final TextView iage, final TextView cage, final TextView pbage) {
|
public static void updateAge(Activity activity, final TextView sage, final TextView iage, final TextView cage, final TextView pbage) {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(
|
activity.runOnUiThread(
|
||||||
new Runnable() {
|
() -> {
|
||||||
@Override
|
CareportalEvent careportalEvent;
|
||||||
public void run() {
|
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
|
||||||
CareportalEvent careportalEvent;
|
|
||||||
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 72);
|
||||||
if (sage != null) {
|
double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 48);
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 72);
|
||||||
sage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 48);
|
||||||
|
double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 166);
|
||||||
|
double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 164);
|
||||||
|
double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360);
|
||||||
|
double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240);
|
||||||
|
|
||||||
|
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
||||||
|
if (sage != null) {
|
||||||
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
||||||
|
if (careportalEvent != null) {
|
||||||
|
sage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, sageWarn, sageUrgent));
|
||||||
|
sage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
sage.setText(notavailable);
|
||||||
}
|
}
|
||||||
if (iage != null) {
|
}
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
if (iage != null) {
|
||||||
iage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
||||||
|
if (careportalEvent != null) {
|
||||||
|
iage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, iageWarn, iageUrgent));
|
||||||
|
iage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
iage.setText(notavailable);
|
||||||
}
|
}
|
||||||
if (cage != null) {
|
}
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
if (cage != null) {
|
||||||
cage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
||||||
|
if (careportalEvent != null) {
|
||||||
|
cage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, cageWarn, cageUrgent));
|
||||||
|
cage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
cage.setText(notavailable);
|
||||||
}
|
}
|
||||||
if (pbage != null) {
|
}
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
if (pbage != null) {
|
||||||
pbage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
||||||
|
if (careportalEvent != null) {
|
||||||
|
pbage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, pbageWarn, pbageUrgent));
|
||||||
|
pbage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
pbage.setText(notavailable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,4 +267,15 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int determineTextColor(CareportalEvent careportalEvent, double warnThreshold, double urgentThreshold) {
|
||||||
|
if (careportalEvent.isOlderThan(urgentThreshold)) {
|
||||||
|
return MainApp.sResources.getColor(R.color.low);
|
||||||
|
} else if (careportalEvent.isOlderThan(warnThreshold)) {
|
||||||
|
return MainApp.sResources.getColor(R.color.high);
|
||||||
|
} else {
|
||||||
|
return Color.WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.HardLimits;
|
import info.nightscout.utils.HardLimits;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
|
@ -55,12 +57,18 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
|
||||||
if (!MainApp.isEngineeringModeOrRelease())
|
|
||||||
value.set(false, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), this);
|
|
||||||
|
|
||||||
String mode = SP.getString("aps_mode", "open");
|
String mode = SP.getString("aps_mode", "open");
|
||||||
if (!mode.equals("closed"))
|
if (!mode.equals("closed"))
|
||||||
value.set(false, MainApp.gs(R.string.closedmodedisabledinpreferences), this);
|
value.set(false, MainApp.gs(R.string.closedmodedisabledinpreferences), this);
|
||||||
|
|
||||||
|
if (!MainApp.isEngineeringModeOrRelease()) {
|
||||||
|
if (value.value()) {
|
||||||
|
Notification n = new Notification(Notification.TOAST_ALARM, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL);
|
||||||
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
}
|
||||||
|
value.set(false, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), this);
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -18,9 +16,7 @@ import info.nightscout.utils.JsonHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = Food.TABLE_FOODS)
|
@DatabaseTable(tableName = Food.TABLE_FOODS)
|
||||||
public class Food {
|
public class Food {
|
||||||
private static Logger log = LoggerFactory.getLogger(Food.class);
|
static final String TABLE_FOODS = "Foods";
|
||||||
|
|
||||||
public static final String TABLE_FOODS = "Foods";
|
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
public long key;
|
public long key;
|
||||||
|
@ -65,7 +61,7 @@ public class Food {
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int gi; // not used yet
|
public int gi; // not used yet
|
||||||
|
|
||||||
public Food() {
|
private Food() {
|
||||||
key = System.currentTimeMillis();
|
key = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
* @param _id
|
* @param _id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Food findByNSId(String _id) {
|
public Food findByNSId(String _id) {
|
||||||
try {
|
try {
|
||||||
List<Food> list = this.getDao().queryForEq("_id", _id);
|
List<Food> list = this.getDao().queryForEq("_id", _id);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.squareup.otto.Bus;
|
||||||
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.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
|
|
|
@ -10,8 +10,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.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
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.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
@ -155,7 +155,8 @@ public class IobCobThread extends Thread {
|
||||||
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
|
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
|
||||||
if (hourAgoData != null) {
|
if (hourAgoData != null) {
|
||||||
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time);
|
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time);
|
||||||
log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString());
|
if (Config.logAutosensData)
|
||||||
|
log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString());
|
||||||
int past = 1;
|
int past = 1;
|
||||||
try {
|
try {
|
||||||
for (; past < 12; past++) {
|
for (; past < 12; past++) {
|
||||||
|
@ -242,7 +243,8 @@ public class IobCobThread extends Thread {
|
||||||
|
|
||||||
previous = autosensData;
|
previous = autosensData;
|
||||||
autosensDataTable.put(bgTime, autosensData);
|
autosensDataTable.put(bgTime, autosensData);
|
||||||
log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime));
|
if (Config.logAutosensData)
|
||||||
|
log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime));
|
||||||
autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio;
|
autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio;
|
||||||
if (Config.logAutosensData)
|
if (Config.logAutosensData)
|
||||||
log.debug(autosensData.toString());
|
log.debug(autosensData.toString());
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.Loop;
|
package info.nightscout.androidaps.plugins.Loop;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.TaskStackBuilder;
|
import android.app.TaskStackBuilder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
@ -48,6 +51,9 @@ import info.nightscout.utils.SP;
|
||||||
public class LoopPlugin extends PluginBase {
|
public class LoopPlugin extends PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
||||||
|
|
||||||
|
public static final String CHANNEL_ID = "AndroidAPS-Openloop";
|
||||||
|
|
||||||
|
|
||||||
protected static LoopPlugin loopPlugin;
|
protected static LoopPlugin loopPlugin;
|
||||||
|
|
||||||
public static LoopPlugin getPlugin() {
|
public static LoopPlugin getPlugin() {
|
||||||
|
@ -90,9 +96,22 @@ public class LoopPlugin extends PluginBase {
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
createNotificationChannel();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createNotificationChannel() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) MainApp.instance().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||||
|
CHANNEL_ID,
|
||||||
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
mNotificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
@ -322,7 +341,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
} else {
|
} else {
|
||||||
if (result.isChangeRequested() && allowNotification) {
|
if (result.isChangeRequested() && allowNotification) {
|
||||||
NotificationCompat.Builder builder =
|
NotificationCompat.Builder builder =
|
||||||
new NotificationCompat.Builder(MainApp.instance().getApplicationContext());
|
new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID);
|
||||||
builder.setSmallIcon(R.drawable.notif_icon)
|
builder.setSmallIcon(R.drawable.notif_icon)
|
||||||
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
|
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
|
||||||
.setContentText(resultAfterConstraints.toString())
|
.setContentText(resultAfterConstraints.toString())
|
||||||
|
|
|
@ -170,6 +170,19 @@ public class NSSettingsStatus {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// valid property is "warn" or "urgent"
|
||||||
|
// plugings "iage" "sage" "cage" "pbage"
|
||||||
|
|
||||||
|
public double getExtendedWarnValue(String plugin, String property, double defaultvalue) {
|
||||||
|
JSONObject extendedSettings = this.getExtendedSettings();
|
||||||
|
if (extendedSettings == null)
|
||||||
|
return defaultvalue;
|
||||||
|
JSONObject pluginJson = extendedSettings.optJSONObject(plugin);
|
||||||
|
if (pluginJson == null)
|
||||||
|
return defaultvalue;
|
||||||
|
return pluginJson.optDouble(property, defaultvalue);
|
||||||
|
}
|
||||||
|
|
||||||
public String getActiveProfile() {
|
public String getActiveProfile() {
|
||||||
return getStringOrNull("activeProfile");
|
return getStringOrNull("activeProfile");
|
||||||
}
|
}
|
||||||
|
@ -193,7 +206,7 @@ public class NSSettingsStatus {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settingsO.has("alarmTimeagoWarnMins") && Objects.equals(what, "alarmTimeagoWarnMins")){
|
if (settingsO.has("alarmTimeagoWarnMins") && Objects.equals(what, "alarmTimeagoWarnMins")) {
|
||||||
Double result = settingsO.getDouble(what);
|
Double result = settingsO.getDouble(what);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +219,7 @@ public class NSSettingsStatus {
|
||||||
|
|
||||||
private String getStringOrNull(String key) {
|
private String getStringOrNull(String key) {
|
||||||
String ret = null;
|
String ret = null;
|
||||||
if(data == null) return null;
|
if (data == null) return null;
|
||||||
if (data.has(key)) {
|
if (data.has(key)) {
|
||||||
try {
|
try {
|
||||||
ret = data.getString(key);
|
ret = data.getString(key);
|
||||||
|
@ -288,21 +301,21 @@ public class NSSettingsStatus {
|
||||||
JSONObject pump = extentendedPumpSettings();
|
JSONObject pump = extentendedPumpSettings();
|
||||||
switch (setting) {
|
switch (setting) {
|
||||||
case "warnClock":
|
case "warnClock":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "urgentClock":
|
case "urgentClock":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "warnRes":
|
case "warnRes":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "urgentRes":
|
case "urgentRes":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "warnBattV":
|
case "warnBattV":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "urgentBattV":
|
case "urgentBattV":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "warnBattP":
|
case "warnBattP":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
case "urgentBattP":
|
case "urgentBattP":
|
||||||
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
return pump != null && pump.has(setting) ? pump.getDouble(setting) : 30;
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
@ -315,7 +328,7 @@ public class NSSettingsStatus {
|
||||||
public JSONObject extentendedPumpSettings() {
|
public JSONObject extentendedPumpSettings() {
|
||||||
try {
|
try {
|
||||||
JSONObject extended = getExtendedSettings();
|
JSONObject extended = getExtendedSettings();
|
||||||
if(extended == null) return null;
|
if (extended == null) return null;
|
||||||
if (extended.has("pump")) {
|
if (extended.has("pump")) {
|
||||||
JSONObject pump = extended.getJSONObject("pump");
|
JSONObject pump = extended.getJSONObject("pump");
|
||||||
return pump;
|
return pump;
|
||||||
|
@ -350,7 +363,7 @@ public class NSSettingsStatus {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean openAPSEnabledAlerts() {
|
public boolean openAPSEnabledAlerts() {
|
||||||
try {
|
try {
|
||||||
JSONObject pump = extentendedPumpSettings();
|
JSONObject pump = extentendedPumpSettings();
|
||||||
if (pump != null && pump.has("openaps")) {
|
if (pump != null && pump.has("openaps")) {
|
||||||
|
|
|
@ -111,6 +111,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
|
||||||
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;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationRecyclerViewAdapter;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||||
|
@ -460,32 +461,32 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||||
return;
|
return;
|
||||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
|
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||||
if (activeloop.isEnabled(PluginType.LOOP)) {
|
if (activeloop.isEnabled(PluginType.LOOP)) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.disableloop));
|
menu.add(MainApp.gs(R.string.disableloop));
|
||||||
if (!activeloop.isSuspended()) {
|
if (!activeloop.isSuspended()) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor1h));
|
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
|
menu.add(MainApp.gs(R.string.suspendloopfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
|
menu.add(MainApp.gs(R.string.suspendloopfor3h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
|
menu.add(MainApp.gs(R.string.suspendloopfor10h));
|
||||||
if (pumpDescription.tempDurationStep15mAllowed)
|
if (pumpDescription.tempDurationStep15mAllowed)
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor15m));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
||||||
if (pumpDescription.tempDurationStep30mAllowed)
|
if (pumpDescription.tempDurationStep30mAllowed)
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor1h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor2h));
|
||||||
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
|
||||||
} else {
|
} else {
|
||||||
menu.add(MainApp.sResources.getString(R.string.resume));
|
menu.add(MainApp.gs(R.string.resume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!activeloop.isEnabled(PluginType.LOOP))
|
if (!activeloop.isEnabled(PluginType.LOOP))
|
||||||
menu.add(MainApp.sResources.getString(R.string.enableloop));
|
menu.add(MainApp.gs(R.string.enableloop));
|
||||||
} else if (v == activeProfileView) {
|
} else if (v == activeProfileView) {
|
||||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.profile));
|
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
||||||
menu.add(MainApp.sResources.getString(R.string.danar_viewprofile));
|
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
||||||
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
||||||
menu.add(MainApp.sResources.getString(R.string.careportal_profileswitch));
|
menu.add(MainApp.gs(R.string.careportal_profileswitch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +497,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return true;
|
return true;
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
|
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
||||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||||
|
@ -505,75 +506,75 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
||||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
||||||
activeloop.suspendTo(0L);
|
activeloop.suspendTo(0L);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor1h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(60);
|
MainApp.getConfigBuilder().suspendLoop(60);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor2h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(120);
|
MainApp.getConfigBuilder().suspendLoop(120);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor3h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(180);
|
MainApp.getConfigBuilder().suspendLoop(180);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.suspendloopfor10h))) {
|
||||||
MainApp.getConfigBuilder().suspendLoop(600);
|
MainApp.getConfigBuilder().suspendLoop(600);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor15m))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor15m))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(15, profile);
|
MainApp.getConfigBuilder().disconnectPump(15, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor30m))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(30, profile);
|
MainApp.getConfigBuilder().disconnectPump(30, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor1h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(60, profile);
|
MainApp.getConfigBuilder().disconnectPump(60, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor2h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(120, profile);
|
MainApp.getConfigBuilder().disconnectPump(120, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.disconnectpumpfor3h))) {
|
||||||
MainApp.getConfigBuilder().disconnectPump(180, profile);
|
MainApp.getConfigBuilder().disconnectPump(180, profile);
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.careportal_profileswitch))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.careportal_profileswitch))) {
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
||||||
profileswitch.executeProfileSwitch = true;
|
profileswitch.executeProfileSwitch = true;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.danar_viewprofile))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.danar_viewprofile))) {
|
||||||
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(System.currentTimeMillis());
|
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(System.currentTimeMillis());
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
pvd.show(manager, "ProfileViewDialog");
|
pvd.show(manager, "ProfileViewDialog");
|
||||||
|
@ -753,9 +754,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
|
||||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +766,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
accepted = false;
|
accepted = false;
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
@ -789,7 +790,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", result.comment);
|
i.putExtra("status", result.comment);
|
||||||
i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -810,7 +811,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", result.comment);
|
i.putExtra("status", result.comment);
|
||||||
i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -841,12 +842,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
sRefreshLoop = new Runnable() {
|
sRefreshLoop = () -> {
|
||||||
@Override
|
scheduleUpdateGUI("refreshLoop");
|
||||||
public void run() {
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
scheduleUpdateGUI("refreshLoop");
|
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
registerForContextMenu(apsModeView);
|
registerForContextMenu(apsModeView);
|
||||||
|
@ -894,23 +892,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
scheduleUpdateGUI("EventExtendedBolusChange");
|
scheduleUpdateGUI("EventExtendedBolusChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled by EventAutosensCalculationFinished
|
|
||||||
// @Subscribe
|
|
||||||
// public void onStatusEvent(final EventNewBG ev) {
|
|
||||||
// scheduleUpdateGUI("EventNewBG");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
||||||
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled by EventAutosensCalculationFinished
|
|
||||||
// @Subscribe
|
|
||||||
// public void onStatusEvent(final EventNewBasalProfile ev) {
|
|
||||||
// scheduleUpdateGUI("EventNewBasalProfile");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
public void onStatusEvent(final EventTempTargetChange ev) {
|
||||||
scheduleUpdateGUI("EventTempTargetChange");
|
scheduleUpdateGUI("EventTempTargetChange");
|
||||||
|
@ -920,12 +906,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onStatusEvent(final EventPumpStatusChanged s) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> updatePumpStatus(s.textStatus()));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updatePumpStatus(s.textStatus());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideTempRecommendation() {
|
private void hideTempRecommendation() {
|
||||||
|
@ -962,12 +943,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void run() {
|
public void run() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> {
|
||||||
@Override
|
updateGUI(from);
|
||||||
public void run() {
|
scheduledUpdate = null;
|
||||||
updateGUI(from);
|
|
||||||
scheduledUpdate = null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1010,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
|
avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
|
||||||
" øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
|
" øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
|
||||||
} else {
|
} else {
|
||||||
deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable));
|
deltaView.setText("Δ " + MainApp.gs(R.string.notavailable));
|
||||||
if (avgdeltaView != null)
|
if (avgdeltaView != null)
|
||||||
avgdeltaView.setText("");
|
avgdeltaView.setText("");
|
||||||
}
|
}
|
||||||
|
@ -1049,25 +1027,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
|
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
|
||||||
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isDisconnected()) {
|
||||||
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), activeloop.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (pump.isSuspended()) {
|
} else if (pump.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
|
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
||||||
if (closedLoopEnabled.value()) {
|
if (closedLoopEnabled.value()) {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
|
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
||||||
} else {
|
} else {
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
|
apsModeView.setText(MainApp.gs(R.string.openloop));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
|
||||||
apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
|
apsModeView.setText(MainApp.gs(R.string.disabledloop));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1135,11 +1117,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String fullText = MainApp.sResources.getString(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h\n";
|
String fullText = MainApp.gs(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h\n";
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
fullText += MainApp.sResources.getString(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
fullText += MainApp.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
||||||
}
|
}
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.basal), fullText, null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.basal), fullText, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1173,7 +1155,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
extendedBolusView.setOnClickListener(new View.OnClickListener() {
|
extendedBolusView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.extendedbolus), extendedBolus.toString(), null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.extendedbolus), extendedBolus.toString(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1192,17 +1174,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
||||||
activeProfileView.setBackgroundColor(Color.GRAY);
|
activeProfileView.setBackgroundColor(Color.GRAY);
|
||||||
|
|
||||||
tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
|
tempTargetView.setOnLongClickListener(view -> {
|
||||||
@Override
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
public boolean onLongClick(View view) {
|
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
final OptionsToShow temptarget = CareportalFragment.TEMPTARGET;
|
||||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
temptarget.executeTempTarget = true;
|
||||||
final OptionsToShow temptarget = CareportalFragment.TEMPTARGET;
|
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||||
temptarget.executeTempTarget = true;
|
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
return true;
|
||||||
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
tempTargetView.setLongClickable(true);
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
|
@ -1276,14 +1255,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (shorttextmode) {
|
if (shorttextmode) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
||||||
iobView.setText(iobtext);
|
iobView.setText(iobtext);
|
||||||
iobView.setOnClickListener(new View.OnClickListener() {
|
iobView.setOnClickListener(v -> {
|
||||||
@Override
|
String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
||||||
public void onClick(View v) {
|
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
||||||
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1, null);
|
||||||
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.iob), iobtext, null);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
|
@ -1310,159 +1286,138 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// pump status from ns
|
// pump status from ns
|
||||||
if (pumpDeviceStatusView != null) {
|
if (pumpDeviceStatusView != null) {
|
||||||
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
||||||
pumpDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
pumpDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenAPS status from ns
|
// OpenAPS status from ns
|
||||||
if (openapsDeviceStatusView != null) {
|
if (openapsDeviceStatusView != null) {
|
||||||
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
||||||
openapsDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
openapsDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uploader status from ns
|
// Uploader status from ns
|
||||||
if (uploaderDeviceStatusView != null) {
|
if (uploaderDeviceStatusView != null) {
|
||||||
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
|
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
|
||||||
uploaderDeviceStatusView.setOnClickListener(new View.OnClickListener() {
|
uploaderDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
// allign to hours
|
||||||
public void run() {
|
Calendar calendar = Calendar.getInstance();
|
||||||
// allign to hours
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
Calendar calendar = Calendar.getInstance();
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
calendar.set(Calendar.SECOND, 0);
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.add(Calendar.HOUR, 1);
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.add(Calendar.HOUR, 1);
|
|
||||||
|
|
||||||
int hoursToFetch;
|
int hoursToFetch;
|
||||||
final long toTime;
|
final long toTime;
|
||||||
final long fromTime;
|
final long fromTime;
|
||||||
final long endTime;
|
final long endTime;
|
||||||
if (predictionsAvailable && SP.getBoolean("showprediction", false)) {
|
if (predictionsAvailable && SP.getBoolean("showprediction", false)) {
|
||||||
int predHours = (int) (Math.ceil(finalLastRun.constraintsProcessed.getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
|
int predHours = (int) (Math.ceil(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
|
||||||
// ------------------ 1st graph
|
// ------------------ 1st graph
|
||||||
Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
|
Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
|
||||||
|
|
||||||
final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin());
|
final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin());
|
||||||
|
|
||||||
// **** In range Area ****
|
// **** In range Area ****
|
||||||
graphData.addInRangeArea(fromTime, endTime, lowLine, highLine);
|
graphData.addInRangeArea(fromTime, endTime, lowLine, highLine);
|
||||||
|
|
||||||
// **** BG ****
|
// **** BG ****
|
||||||
if (predictionsAvailable && SP.getBoolean("showprediction", false))
|
if (predictionsAvailable && SP.getBoolean("showprediction", false))
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
|
||||||
else
|
else
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
||||||
|
|
||||||
// set manual x bounds to have nice steps
|
// set manual x bounds to have nice steps
|
||||||
graphData.formatAxis(fromTime, endTime);
|
graphData.formatAxis(fromTime, endTime);
|
||||||
|
|
||||||
// Treatments
|
// Treatments
|
||||||
graphData.addTreatments(fromTime, endTime);
|
graphData.addTreatments(fromTime, endTime);
|
||||||
|
|
||||||
// add basal data
|
// add basal data
|
||||||
if (pump.getPumpDescription().isTempBasalCapable && SP.getBoolean("showbasals", true)) {
|
if (pump.getPumpDescription().isTempBasalCapable && SP.getBoolean("showbasals", true)) {
|
||||||
graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d);
|
graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add target line
|
// add target line
|
||||||
graphData.addTargetLine(fromTime, toTime, profile);
|
graphData.addTargetLine(fromTime, toTime, profile);
|
||||||
|
|
||||||
// **** NOW line ****
|
// **** NOW line ****
|
||||||
graphData.addNowLine(now);
|
graphData.addNowLine(now);
|
||||||
|
|
||||||
// ------------------ 2nd graph
|
// ------------------ 2nd graph
|
||||||
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
|
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
|
||||||
|
|
||||||
final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin());
|
final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin());
|
||||||
|
|
||||||
boolean useIobForScale = false;
|
boolean useIobForScale = false;
|
||||||
boolean useCobForScale = false;
|
boolean useCobForScale = false;
|
||||||
boolean useDevForScale = false;
|
boolean useDevForScale = false;
|
||||||
boolean useRatioForScale = false;
|
boolean useRatioForScale = false;
|
||||||
boolean useDSForScale = false;
|
boolean useDSForScale = false;
|
||||||
|
|
||||||
if (SP.getBoolean("showiob", true)) {
|
if (SP.getBoolean("showiob", true)) {
|
||||||
useIobForScale = true;
|
useIobForScale = true;
|
||||||
} else if (SP.getBoolean("showcob", true)) {
|
} else if (SP.getBoolean("showcob", true)) {
|
||||||
useCobForScale = true;
|
useCobForScale = true;
|
||||||
} else if (SP.getBoolean("showdeviations", false)) {
|
} else if (SP.getBoolean("showdeviations", false)) {
|
||||||
useDevForScale = true;
|
useDevForScale = true;
|
||||||
} else if (SP.getBoolean("showratios", false)) {
|
} else if (SP.getBoolean("showratios", false)) {
|
||||||
useRatioForScale = true;
|
useRatioForScale = true;
|
||||||
} else if (Config.displayDeviationSlope) {
|
} else if (Config.displayDeviationSlope) {
|
||||||
useDSForScale = true;
|
useDSForScale = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.getBoolean("showiob", true))
|
if (SP.getBoolean("showiob", true))
|
||||||
secondGraphData.addIob(fromTime, now, useIobForScale, 1d);
|
secondGraphData.addIob(fromTime, now, useIobForScale, 1d);
|
||||||
if (SP.getBoolean("showcob", true))
|
if (SP.getBoolean("showcob", true))
|
||||||
secondGraphData.addCob(fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d);
|
secondGraphData.addCob(fromTime, now, useCobForScale, useCobForScale ? 1d : 0.5d);
|
||||||
if (SP.getBoolean("showdeviations", false))
|
if (SP.getBoolean("showdeviations", false))
|
||||||
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
|
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
|
||||||
if (SP.getBoolean("showratios", false))
|
if (SP.getBoolean("showratios", false))
|
||||||
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
|
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
|
||||||
if (Config.displayDeviationSlope)
|
if (Config.displayDeviationSlope)
|
||||||
secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d);
|
secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d);
|
||||||
|
|
||||||
// **** NOW line ****
|
// **** NOW line ****
|
||||||
// set manual x bounds to have nice steps
|
// set manual x bounds to have nice steps
|
||||||
secondGraphData.formatAxis(fromTime, endTime);
|
secondGraphData.formatAxis(fromTime, endTime);
|
||||||
secondGraphData.addNowLine(now);
|
secondGraphData.addNowLine(now);
|
||||||
|
|
||||||
// do GUI update
|
// do GUI update
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> {
|
||||||
@Override
|
if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) {
|
||||||
public void run() {
|
iobGraph.setVisibility(View.VISIBLE);
|
||||||
if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) {
|
} else {
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
iobGraph.setVisibility(View.GONE);
|
||||||
} else {
|
}
|
||||||
iobGraph.setVisibility(View.GONE);
|
// finally enforce drawing of graphs
|
||||||
}
|
graphData.performUpdate();
|
||||||
// finally enforce drawing of graphs
|
secondGraphData.performUpdate();
|
||||||
graphData.performUpdate();
|
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
|
||||||
secondGraphData.performUpdate();
|
});
|
||||||
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
@ -1470,108 +1425,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
|
|
||||||
|
|
||||||
List<Notification> notificationsList;
|
|
||||||
|
|
||||||
RecyclerViewAdapter(List<Notification> notificationsList) {
|
|
||||||
this.notificationsList = notificationsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
|
|
||||||
return new NotificationsViewHolder(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
|
||||||
Notification notification = notificationsList.get(position);
|
|
||||||
holder.dismiss.setTag(notification);
|
|
||||||
if (Objects.equals(notification.text, MainApp.sResources.getString(R.string.nsalarm_staledata)))
|
|
||||||
holder.dismiss.setText("snooze");
|
|
||||||
holder.text.setText(notification.text);
|
|
||||||
holder.time.setText(DateUtil.timeString(notification.date));
|
|
||||||
if (notification.level == Notification.URGENT)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
|
|
||||||
else if (notification.level == Notification.NORMAL)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
|
|
||||||
else if (notification.level == Notification.LOW)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
|
|
||||||
else if (notification.level == Notification.INFO)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
|
|
||||||
else if (notification.level == Notification.ANNOUNCEMENT)
|
|
||||||
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return notificationsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
|
||||||
CardView cv;
|
|
||||||
TextView time;
|
|
||||||
TextView text;
|
|
||||||
Button dismiss;
|
|
||||||
|
|
||||||
NotificationsViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
cv = (CardView) itemView.findViewById(R.id.notification_cardview);
|
|
||||||
time = (TextView) itemView.findViewById(R.id.notification_time);
|
|
||||||
text = (TextView) itemView.findViewById(R.id.notification_text);
|
|
||||||
dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
|
|
||||||
dismiss.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Notification notification = (Notification) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.notification_dismiss:
|
|
||||||
MainApp.bus().post(new EventDismissNotification(notification.id));
|
|
||||||
if (notification.nsAlarm != null) {
|
|
||||||
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
|
|
||||||
}
|
|
||||||
// Adding current time to snooze if we got staleData
|
|
||||||
log.debug("Notification text is: " + notification.text);
|
|
||||||
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
|
||||||
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
|
||||||
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
|
||||||
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
|
||||||
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateNotifications() {
|
void updateNotifications() {
|
||||||
Activity activity = getActivity();
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
if (activity != null)
|
nstore.removeExpired();
|
||||||
activity.runOnUiThread(new Runnable() {
|
nstore.unSnooze();
|
||||||
@Override
|
if (nstore.store.size() > 0) {
|
||||||
public void run() {
|
NotificationRecyclerViewAdapter adapter = new NotificationRecyclerViewAdapter(nstore.store);
|
||||||
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
notificationsView.setAdapter(adapter);
|
||||||
nstore.removeExpired();
|
notificationsView.setVisibility(View.VISIBLE);
|
||||||
nstore.unSnooze();
|
} else {
|
||||||
if (nstore.store.size() > 0) {
|
notificationsView.setVisibility(View.GONE);
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
|
}
|
||||||
notificationsView.setAdapter(adapter);
|
|
||||||
notificationsView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
notificationsView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,8 @@ public class OverviewPlugin extends PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewNotification n) {
|
public void onStatusEvent(final EventNewNotification n) {
|
||||||
notificationStore.add(n.notification);
|
if (notificationStore.add(n.notification))
|
||||||
MainApp.bus().post(new EventRefreshOverview("EventNewNotification"));
|
MainApp.bus().post(new EventRefreshOverview("EventNewNotification"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.Overview.events;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
|
|
||||||
public class EventOverviewBolusProgress extends Event {
|
public class EventOverviewBolusProgress extends Event {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.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.BasalData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Overview.notifications;
|
||||||
|
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<NotificationRecyclerViewAdapter.NotificationsViewHolder> {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(NotificationRecyclerViewAdapter.class);
|
||||||
|
|
||||||
|
private List<Notification> notificationsList;
|
||||||
|
|
||||||
|
public NotificationRecyclerViewAdapter(List<Notification> notificationsList) {
|
||||||
|
this.notificationsList = notificationsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
|
||||||
|
return new NotificationsViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
|
||||||
|
Notification notification = notificationsList.get(position);
|
||||||
|
holder.dismiss.setTag(notification);
|
||||||
|
if (Objects.equals(notification.text, MainApp.gs(R.string.nsalarm_staledata)))
|
||||||
|
holder.dismiss.setText("snooze");
|
||||||
|
holder.text.setText(notification.text);
|
||||||
|
holder.time.setText(DateUtil.timeString(notification.date));
|
||||||
|
if (notification.level == Notification.URGENT)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
|
||||||
|
else if (notification.level == Notification.NORMAL)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
|
||||||
|
else if (notification.level == Notification.LOW)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
|
||||||
|
else if (notification.level == Notification.INFO)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
|
||||||
|
else if (notification.level == Notification.ANNOUNCEMENT)
|
||||||
|
holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return notificationsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
CardView cv;
|
||||||
|
TextView time;
|
||||||
|
TextView text;
|
||||||
|
Button dismiss;
|
||||||
|
|
||||||
|
NotificationsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
cv = (CardView) itemView.findViewById(R.id.notification_cardview);
|
||||||
|
time = (TextView) itemView.findViewById(R.id.notification_time);
|
||||||
|
text = (TextView) itemView.findViewById(R.id.notification_text);
|
||||||
|
dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
|
||||||
|
dismiss.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Notification notification = (Notification) v.getTag();
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.notification_dismiss:
|
||||||
|
MainApp.bus().post(new EventDismissNotification(notification.id));
|
||||||
|
if (notification.nsAlarm != null) {
|
||||||
|
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
|
||||||
|
}
|
||||||
|
// Adding current time to snooze if we got staleData
|
||||||
|
log.debug("Notification text is: " + notification.text);
|
||||||
|
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
||||||
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
|
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
||||||
|
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
||||||
|
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.Overview.notifications;
|
package info.nightscout.androidaps.plugins.Overview.notifications;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -8,6 +10,7 @@ import android.graphics.BitmapFactory;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -28,11 +31,15 @@ import info.nightscout.utils.SP;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NotificationStore {
|
public class NotificationStore {
|
||||||
|
|
||||||
|
public static final String CHANNEL_ID = "AndroidAPS-Overview";
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(NotificationStore.class);
|
private static Logger log = LoggerFactory.getLogger(NotificationStore.class);
|
||||||
public List<Notification> store = new ArrayList<Notification>();
|
public List<Notification> store = new ArrayList<Notification>();
|
||||||
public long snoozedUntil = 0L;
|
public long snoozedUntil = 0L;
|
||||||
|
|
||||||
public NotificationStore() {
|
public NotificationStore() {
|
||||||
|
createNotificationChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NotificationComparator implements Comparator<Notification> {
|
public class NotificationComparator implements Comparator<Notification> {
|
||||||
|
@ -42,13 +49,13 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void add(Notification n) {
|
public synchronized boolean add(Notification n) {
|
||||||
log.info("Notification received: " + n.text);
|
log.info("Notification received: " + n.text);
|
||||||
for (Notification storeNotification : store) {
|
for (Notification storeNotification : store) {
|
||||||
if (storeNotification.id == n.id) {
|
if (storeNotification.id == n.id) {
|
||||||
storeNotification.date = n.date;
|
storeNotification.date = n.date;
|
||||||
storeNotification.validTo = n.validTo;
|
storeNotification.validTo = n.validTo;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
store.add(n);
|
store.add(n);
|
||||||
|
@ -64,6 +71,7 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(store, new NotificationComparator());
|
Collections.sort(store, new NotificationComparator());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean remove(int id) {
|
public synchronized boolean remove(int id) {
|
||||||
|
@ -110,7 +118,7 @@ public class NotificationStore {
|
||||||
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl);
|
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl);
|
||||||
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
|
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
|
||||||
NotificationCompat.Builder notificationBuilder =
|
NotificationCompat.Builder notificationBuilder =
|
||||||
new NotificationCompat.Builder(context)
|
new NotificationCompat.Builder(context, CHANNEL_ID)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setLargeIcon(largeIcon)
|
.setLargeIcon(largeIcon)
|
||||||
.setContentText(n.text)
|
.setContentText(n.text)
|
||||||
|
@ -127,4 +135,17 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
mgr.notify(n.id, notificationBuilder.build());
|
mgr.notify(n.id, notificationBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createNotificationChannel() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) MainApp.instance().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||||
|
CHANNEL_ID,
|
||||||
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
mNotificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.Persistentnotification;
|
package info.nightscout.androidaps.plugins.Persistentnotification;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.support.v4.app.TaskStackBuilder;
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
|
|
||||||
|
@ -41,6 +44,8 @@ import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
public class PersistentNotificationPlugin extends PluginBase {
|
public class PersistentNotificationPlugin extends PluginBase {
|
||||||
|
|
||||||
|
public static final String CHANNEL_ID = "AndroidAPS-Ongoing";
|
||||||
|
|
||||||
private static final int ONGOING_NOTIFICATION_ID = 4711;
|
private static final int ONGOING_NOTIFICATION_ID = 4711;
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
|
|
||||||
|
@ -57,10 +62,23 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
createNotificationChannel();
|
||||||
updateNotification();
|
updateNotification();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createNotificationChannel() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||||
|
CHANNEL_ID,
|
||||||
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
mNotificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
@ -118,7 +136,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
line3 += " - " + MainApp.getConfigBuilder().getProfileName();
|
line3 += " - " + MainApp.getConfigBuilder().getProfileName();
|
||||||
|
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
|
||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_STATUS);
|
builder.setCategory(NotificationCompat.CATEGORY_STATUS);
|
||||||
builder.setSmallIcon(R.drawable.ic_notification);
|
builder.setSmallIcon(R.drawable.ic_notification);
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCombo;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpAlert;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
public class ComboAlertHistoryDialog extends DialogFragment {
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View layout = inflater.inflate(R.layout.combo_alert_history_fragment, container, false);
|
|
||||||
TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text);
|
|
||||||
List<PumpAlert> errors = ComboPlugin.getPlugin().getPump().errorHistory;
|
|
||||||
if (errors.isEmpty()) {
|
|
||||||
text.setText(R.string.combo_no_alert_data_note);
|
|
||||||
} else {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
|
||||||
boolean first = true;
|
|
||||||
for (PumpAlert error : errors) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
sb.append("\n");
|
|
||||||
}
|
|
||||||
sb.append(dateTimeFormatter.format(error.timestamp));
|
|
||||||
sb.append(" ");
|
|
||||||
sb.append(error.message);
|
|
||||||
if (error.warningCode != null) {
|
|
||||||
sb.append(" (W");
|
|
||||||
sb.append(error.warningCode);
|
|
||||||
sb.append(")");
|
|
||||||
}
|
|
||||||
if (error.errorCode != null) {
|
|
||||||
sb.append(" (E");
|
|
||||||
sb.append(error.errorCode);
|
|
||||||
sb.append(")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
text.setText(sb.toString());
|
|
||||||
}
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ import android.app.AlertDialog;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -16,7 +17,6 @@ import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.PumpState;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.PumpState;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class ComboFragment extends SubscriberFragment implements View.OnClickListener, View.OnLongClickListener {
|
public class ComboFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private TextView stateView;
|
private TextView stateView;
|
||||||
private TextView activityView;
|
private TextView activityView;
|
||||||
private TextView batteryView;
|
private TextView batteryView;
|
||||||
|
@ -39,43 +39,28 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
private TextView baseBasalRate;
|
private TextView baseBasalRate;
|
||||||
private TextView tempBasalText;
|
private TextView tempBasalText;
|
||||||
private Button refreshButton;
|
private Button refreshButton;
|
||||||
private Button alertsButton;
|
|
||||||
private Button tddsButton;
|
|
||||||
private TextView bolusCount;
|
private TextView bolusCount;
|
||||||
private TextView tbrCount;
|
private TextView tbrCount;
|
||||||
private Button fullHistoryButton;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.combopump_fragment, container, false);
|
View view = inflater.inflate(R.layout.combopump_fragment, container, false);
|
||||||
|
|
||||||
stateView = (TextView) view.findViewById(R.id.combo_state);
|
stateView = view.findViewById(R.id.combo_state);
|
||||||
activityView = (TextView) view.findViewById(R.id.combo_activity);
|
activityView = view.findViewById(R.id.combo_activity);
|
||||||
batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery);
|
batteryView = view.findViewById(R.id.combo_pumpstate_battery);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate);
|
reservoirView = view.findViewById(R.id.combo_insulinstate);
|
||||||
lastBolusView = (TextView) view.findViewById(R.id.combo_last_bolus);
|
lastBolusView = view.findViewById(R.id.combo_last_bolus);
|
||||||
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
lastConnectionView = view.findViewById(R.id.combo_lastconnection);
|
||||||
baseBasalRate = (TextView) view.findViewById(R.id.combo_base_basal_rate);
|
baseBasalRate = view.findViewById(R.id.combo_base_basal_rate);
|
||||||
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
tempBasalText = view.findViewById(R.id.combo_temp_basal);
|
||||||
bolusCount = (TextView) view.findViewById(R.id.combo_bolus_count);
|
bolusCount = view.findViewById(R.id.combo_bolus_count);
|
||||||
tbrCount = (TextView) view.findViewById(R.id.combo_tbr_count);
|
tbrCount = view.findViewById(R.id.combo_tbr_count);
|
||||||
|
|
||||||
refreshButton = (Button) view.findViewById(R.id.combo_refresh_button);
|
refreshButton = view.findViewById(R.id.combo_refresh_button);
|
||||||
refreshButton.setOnClickListener(this);
|
refreshButton.setOnClickListener(this);
|
||||||
|
|
||||||
alertsButton = (Button) view.findViewById(R.id.combo_alerts_button);
|
|
||||||
alertsButton.setOnClickListener(this);
|
|
||||||
alertsButton.setOnLongClickListener(this);
|
|
||||||
|
|
||||||
tddsButton = (Button) view.findViewById(R.id.combo_tdds_button);
|
|
||||||
tddsButton.setOnClickListener(this);
|
|
||||||
tddsButton.setOnLongClickListener(this);
|
|
||||||
|
|
||||||
fullHistoryButton = (Button) view.findViewById(R.id.combo_full_history_button);
|
|
||||||
fullHistoryButton.setOnClickListener(this);
|
|
||||||
fullHistoryButton.setOnLongClickListener(this);
|
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -99,75 +84,9 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case R.id.combo_alerts_button:
|
|
||||||
ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog();
|
|
||||||
ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName());
|
|
||||||
break;
|
|
||||||
case R.id.combo_tdds_button:
|
|
||||||
ComboTddHistoryDialog thd = new ComboTddHistoryDialog();
|
|
||||||
thd.show(getFragmentManager(), ComboTddHistoryDialog.class.getSimpleName());
|
|
||||||
break;
|
|
||||||
case R.id.combo_full_history_button:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setMessage(R.string.combo_read_full_history_info);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO clean up when when queuing
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.combo_alerts_button:
|
|
||||||
alertsButton.setEnabled(false);
|
|
||||||
tddsButton.setEnabled(false);
|
|
||||||
fullHistoryButton.setEnabled(false);
|
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readAlertData(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
alertsButton.setEnabled(true);
|
|
||||||
tddsButton.setEnabled(true);
|
|
||||||
fullHistoryButton.setEnabled(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})).start();
|
|
||||||
return true;
|
|
||||||
case R.id.combo_tdds_button:
|
|
||||||
alertsButton.setEnabled(false);
|
|
||||||
tddsButton.setEnabled(false);
|
|
||||||
fullHistoryButton.setEnabled(false);
|
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readTddData(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
alertsButton.setEnabled(true);
|
|
||||||
tddsButton.setEnabled(true);
|
|
||||||
fullHistoryButton.setEnabled(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})).start();
|
|
||||||
return true;
|
|
||||||
case R.id.combo_full_history_button:
|
|
||||||
alertsButton.setEnabled(false);
|
|
||||||
tddsButton.setEnabled(false);
|
|
||||||
fullHistoryButton.setEnabled(false);
|
|
||||||
new Thread(() -> ComboPlugin.getPlugin().readAllPumpData(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
alertsButton.setEnabled(true);
|
|
||||||
tddsButton.setEnabled(true);
|
|
||||||
fullHistoryButton.setEnabled(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})).start();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventComboPumpUpdateGUI ignored) {
|
public void onStatusEvent(final EventComboPumpUpdateGUI ignored) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
@ -210,13 +129,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isInitialized()) {
|
if (plugin.isInitialized()) {
|
||||||
refreshButton.setVisibility(View.VISIBLE);
|
|
||||||
if (Config.enableComboBetaFeatures) {
|
|
||||||
alertsButton.setVisibility(View.VISIBLE);
|
|
||||||
tddsButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
fullHistoryButton.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
batteryView.setTextSize(20);
|
batteryView.setTextSize(20);
|
||||||
if (ps.batteryState == PumpState.EMPTY) {
|
if (ps.batteryState == PumpState.EMPTY) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
@ -68,8 +68,8 @@ import info.nightscout.utils.SP;
|
||||||
*/
|
*/
|
||||||
public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
|
public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
|
private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
|
||||||
public static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||||
public static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||||
|
|
||||||
private static ComboPlugin plugin = null;
|
private static ComboPlugin plugin = null;
|
||||||
|
|
||||||
|
@ -1124,11 +1124,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
*/
|
*/
|
||||||
private boolean readHistory(@Nullable PumpHistoryRequest request) {
|
private boolean readHistory(@Nullable PumpHistoryRequest request) {
|
||||||
CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request));
|
CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request));
|
||||||
if (!historyResult.success) {
|
PumpHistory history = historyResult.history;
|
||||||
|
if (!historyResult.success || history == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpHistory history = historyResult.history;
|
|
||||||
updateDbFromPumpHistory(history);
|
updateDbFromPumpHistory(history);
|
||||||
|
|
||||||
// update local cache
|
// update local cache
|
||||||
|
@ -1171,64 +1171,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000);
|
return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO use queue once ready
|
|
||||||
void readTddData(Callback post) {
|
|
||||||
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
|
|
||||||
// }
|
|
||||||
// }, post);
|
|
||||||
if (post != null) {
|
|
||||||
post.run();
|
|
||||||
}
|
|
||||||
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
|
||||||
if (commandQueue.performing() == null && commandQueue.size() == 0) {
|
|
||||||
ruffyScripter.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO use queue once ready
|
|
||||||
void readAlertData(Callback post) {
|
|
||||||
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
|
|
||||||
// }
|
|
||||||
// }, post);
|
|
||||||
if (post != null) {
|
|
||||||
post.run();
|
|
||||||
}
|
|
||||||
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
|
||||||
if (commandQueue.performing() == null && commandQueue.size() == 0) {
|
|
||||||
ruffyScripter.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO use queue once ready
|
|
||||||
void readAllPumpData(Callback post) {
|
|
||||||
// ConfigBuilderPlugin.getCommandQueue().custom(new Callback() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
readHistory(new PumpHistoryRequest()
|
|
||||||
.bolusHistory(PumpHistoryRequest.FULL)
|
|
||||||
.pumpErrorHistory(PumpHistoryRequest.FULL)
|
|
||||||
.tddHistory(PumpHistoryRequest.FULL));
|
|
||||||
CommandResult readBasalResult = runCommand(MainApp.gs(R.string.combo_actvity_reading_basal_profile), 2, ruffyScripter::readBasalProfile);
|
|
||||||
if (readBasalResult.success) {
|
|
||||||
pump.basalProfile = readBasalResult.basalProfile;
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
// }, post);
|
|
||||||
if (post != null) {
|
|
||||||
post.run();
|
|
||||||
}
|
|
||||||
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
|
||||||
if (commandQueue.performing() == null && commandQueue.size() == 0) {
|
|
||||||
ruffyScripter.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads QuickInfo to update reservoir level and determine if new boluses exist on the pump
|
* Reads QuickInfo to update reservoir level and determine if new boluses exist on the pump
|
||||||
* and if so, queries the history for all new records.
|
* and if so, queries the history for all new records.
|
||||||
|
@ -1378,7 +1320,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult loadTDDs() {
|
public PumpEnactResult loadTDDs() {
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
|
result.success = readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCombo;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
public class ComboTddHistoryDialog extends DialogFragment {
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View layout = inflater.inflate(R.layout.combo_tdd_history_fragment, container, false);
|
|
||||||
TextView text = (TextView) layout.findViewById(R.id.combo_tdd_history_text);
|
|
||||||
List<Tdd> tdds = ComboPlugin.getPlugin().getPump().tddHistory;
|
|
||||||
if (tdds.isEmpty()) {
|
|
||||||
text.setText(R.string.combo_no_tdd_data_note);
|
|
||||||
} else {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
DateFormat dateFormatter = DateFormat.getDateInstance();
|
|
||||||
double avg = 0;
|
|
||||||
double min = 999;
|
|
||||||
double max = 0;
|
|
||||||
int count = 0;
|
|
||||||
for (Tdd tdd : tdds) {
|
|
||||||
if (tdd.total > 0) {
|
|
||||||
avg += tdd.total;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (tdd.total < min) min = tdd.total;
|
|
||||||
if (tdd.total > max) max = tdd.total;
|
|
||||||
}
|
|
||||||
avg = avg / count;
|
|
||||||
sb.append(String.format(Locale.getDefault(), getString(R.string.combo_tdd_minimum), min));
|
|
||||||
sb.append("\n");
|
|
||||||
sb.append(String.format(Locale.getDefault(), getString(R.string.combo_tdd_average), avg));
|
|
||||||
sb.append("\n");
|
|
||||||
sb.append(String.format(Locale.getDefault(), getString(R.string.combo_tdd_maximum), max));
|
|
||||||
sb.append("\n");
|
|
||||||
for (Tdd tdd : tdds) {
|
|
||||||
sb.append("\n");
|
|
||||||
sb.append(dateFormatter.format(tdd.timestamp));
|
|
||||||
sb.append(" ");
|
|
||||||
sb.append(String.format(Locale.getDefault(), "%3.1f", tdd.total));
|
|
||||||
sb.append(" U");
|
|
||||||
}
|
|
||||||
text.setText(sb.toString());
|
|
||||||
}
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@ 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.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
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.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
|
||||||
public class MsgBolusProgress extends MessageBase {
|
public class MsgBolusProgress extends MessageBase {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
|
||||||
public class MsgBolusStop extends MessageBase {
|
public class MsgBolusStop extends MessageBase {
|
||||||
|
|
|
@ -21,10 +21,9 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.SerialIOThread;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStop;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStop;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryAlarm;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryAlarm;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
|
|
@ -18,7 +18,7 @@ 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.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import info.nightscout.androidaps.data.ProfileStore;
|
||||||
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.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
|
@ -363,9 +363,9 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
speed = 60;
|
speed = 60;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// v2 stores end time for bolus, we need to adjust time
|
// RS stores end time for bolus, we need to adjust time
|
||||||
// default delivery speed is 12 sec/U
|
// default delivery speed is 12 sec/U
|
||||||
detailedBolusInfo.date += detailedBolusInfo.insulin * speed * 1000;
|
detailedBolusInfo.date = DateUtil.now() + (long)(speed * detailedBolusInfo.insulin * 1000);
|
||||||
// clean carbs to prevent counting them as twice because they will picked up as another record
|
// clean carbs to prevent counting them as twice because they will picked up as another record
|
||||||
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
|
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
|
||||||
double carbs = detailedBolusInfo.carbs;
|
double carbs = detailedBolusInfo.carbs;
|
||||||
|
@ -379,7 +379,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
t.isSMB = detailedBolusInfo.isSMB;
|
t.isSMB = detailedBolusInfo.isSMB;
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || carbs > 0)
|
||||||
connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, System.currentTimeMillis() + carbTime * 60 * 1000, t);
|
connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = connectionOK;
|
result.success = connectionOK;
|
||||||
result.bolusDelivered = t.insulin;
|
result.bolusDelivered = t.insulin;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil;
|
import com.cozmo.danar.util.BleCommandUtil;
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
|
||||||
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
|
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil;
|
import com.cozmo.danar.util.BleCommandUtil;
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
|
||||||
public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
|
public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet {
|
||||||
|
|
|
@ -7,7 +7,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 com.cozmo.danar.util.BleCommandUtil;
|
import com.cozmo.danar.util.BleCommandUtil;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
|
|
||||||
public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
|
public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
|
@ -71,8 +71,10 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Notify_D
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_Pump_Time;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_Pump_Time;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Set_Pump_Time;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Set_Pump_Time;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
public class DanaRSService extends Service {
|
public class DanaRSService extends Service {
|
||||||
private static Logger log = LoggerFactory.getLogger(DanaRSService.class);
|
private static Logger log = LoggerFactory.getLogger(DanaRSService.class);
|
||||||
|
@ -145,8 +147,10 @@ public class DanaRSService extends Service {
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
if (Math.abs(timeDiff) > 10) {
|
if (Math.abs(timeDiff) > 3) {
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date()));
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
@ -458,4 +462,14 @@ public class DanaRSService extends Service {
|
||||||
log.debug("EventAppExit finished");
|
log.debug("EventAppExit finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void waitForWholeMinute() {
|
||||||
|
while (true) {
|
||||||
|
long time = DateUtil.now();
|
||||||
|
long timeToWholeMinute = (60000 - time % 60000);
|
||||||
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
|
||||||
|
break;
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000))));
|
||||||
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,15 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
speed = 60;
|
speed = 60;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
detailedBolusInfo.date += speed * detailedBolusInfo.insulin * 1000;
|
detailedBolusInfo.date = DateUtil.now() + (long)(speed * detailedBolusInfo.insulin * 1000);
|
||||||
// clean carbs to prevent counting them as twice because they will picked up as another record
|
// clean carbs to prevent counting them as twice because they will picked up as another record
|
||||||
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
|
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
|
||||||
double carbs = detailedBolusInfo.carbs;
|
double carbs = detailedBolusInfo.carbs;
|
||||||
|
@ -167,7 +168,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
t.isSMB = detailedBolusInfo.isSMB;
|
t.isSMB = detailedBolusInfo.isSMB;
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || carbs > 0)
|
||||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, System.currentTimeMillis() + carbTime * 60 * 1000, t);
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = connectionOK;
|
result.success = connectionOK;
|
||||||
result.bolusDelivered = t.insulin;
|
result.bolusDelivered = t.insulin;
|
||||||
|
@ -380,4 +381,5 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
return sExecutionService.loadEvents();
|
return sExecutionService.loadEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -64,8 +64,10 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgSetHistoryEntry_v2
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgStatusBolusExtended_v2;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgStatusBolusExtended_v2;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgStatusTempBasal_v2;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgStatusTempBasal_v2;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
@ -198,8 +200,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
if (Math.abs(timeDiff) > 10) {
|
if (Math.abs(timeDiff) > 3) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||||
|
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
@ -450,4 +454,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void waitForWholeMinute() {
|
||||||
|
while (true) {
|
||||||
|
long time = DateUtil.now();
|
||||||
|
long timeToWholeMinute = (60000 - time % 60000);
|
||||||
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
||||||
|
break;
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int)(timeToWholeMinute / 1000))));
|
||||||
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ 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;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
@ -193,8 +193,8 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult loadTDDs() {
|
public PumpEnactResult loadTDDs() {
|
||||||
//TODO: read TDDs and store to DB
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
result.success = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,6 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
// TODO review
|
// TODO review
|
||||||
if (!Config.NSCLIENT && !Config.G5UPLOADER)
|
if (!Config.NSCLIENT && !Config.G5UPLOADER)
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
lastDataTime = new Date();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -283,7 +282,6 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
|
|
||||||
log("getPumpStatus");
|
log("getPumpStatus");
|
||||||
lastDataTime = new Date();
|
|
||||||
if (Connector.get().isPumpConnected()) {
|
if (Connector.get().isPumpConnected()) {
|
||||||
log("is connected.. requesting status");
|
log("is connected.. requesting status");
|
||||||
final UUID uuid = aSyncTaskRunner(new StatusTaskRunner(connector.getServiceConnector()), "Status");
|
final UUID uuid = aSyncTaskRunner(new StatusTaskRunner(connector.getServiceConnector()), "Status");
|
||||||
|
@ -439,7 +437,6 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
updateGui();
|
updateGui();
|
||||||
connector.tryToGetPumpStatusAgain();
|
connector.tryToGetPumpStatusAgain();
|
||||||
|
|
||||||
lastDataTime = new Date();
|
|
||||||
connector.requestHistorySync(30000);
|
connector.requestHistorySync(30000);
|
||||||
|
|
||||||
if (result.success) while (true) {
|
if (result.success) while (true) {
|
||||||
|
@ -538,8 +535,6 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Setting temp basal absolute: " + pumpEnactResult.success);
|
log.debug("Setting temp basal absolute: " + pumpEnactResult.success);
|
||||||
|
|
||||||
lastDataTime = new Date();
|
|
||||||
|
|
||||||
updateGui();
|
updateGui();
|
||||||
|
|
||||||
connector.requestHistorySync(5000);
|
connector.requestHistorySync(5000);
|
||||||
|
@ -621,7 +616,6 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
}
|
}
|
||||||
lastDataTime = new Date();
|
|
||||||
updateGui();
|
updateGui();
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Canceling temp basal: "); // TODO get more info
|
log.debug("Canceling temp basal: "); // TODO get more info
|
||||||
|
@ -950,6 +944,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
singleMessageTaskRunner.fetch(new TaskRunner.ResultCallback() {
|
singleMessageTaskRunner.fetch(new TaskRunner.ResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(Object o) {
|
public void onResult(Object o) {
|
||||||
|
lastDataTime = new Date();
|
||||||
log(name + " success");
|
log(name + " success");
|
||||||
event.response_object = o;
|
event.response_object = o;
|
||||||
if (o instanceof BolusMessage) {
|
if (o instanceof BolusMessage) {
|
||||||
|
@ -988,6 +983,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
task.fetch(new TaskRunner.ResultCallback() {
|
task.fetch(new TaskRunner.ResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(Object o) {
|
public void onResult(Object o) {
|
||||||
|
lastDataTime = new Date();
|
||||||
log(name + " success");
|
log(name + " success");
|
||||||
event.response_object = o;
|
event.response_object = o;
|
||||||
event.success = true;
|
event.success = true;
|
||||||
|
|
|
@ -4,6 +4,10 @@ import android.content.Intent;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import android.database.DatabaseUtils;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import sugar.free.sightparser.handling.HistoryBroadcast;
|
import sugar.free.sightparser.handling.HistoryBroadcast;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.updatePumpSerialNumber;
|
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.updatePumpSerialNumber;
|
||||||
|
@ -109,4 +113,12 @@ class HistoryIntentAdapter {
|
||||||
log("ERROR, UNKNWON BOLUS TYPE: " + bolus_type);
|
log("ERROR, UNKNWON BOLUS TYPE: " + bolus_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void processDailyTotalIntent(Intent intent) {
|
||||||
|
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_TOTAL_DATE);
|
||||||
|
double basal = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BASAL_TOTAL, 0D);
|
||||||
|
double bolus = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BOLUS_TOTAL, 0D);
|
||||||
|
TDD tdd = new TDD(date.getTime(), bolus, basal, bolus + basal);
|
||||||
|
MainApp.getDbHelper().createOrUpdateTDD(tdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,7 @@ import info.nightscout.androidaps.R;
|
||||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.BUSY;
|
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.BUSY;
|
||||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCED;
|
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCED;
|
||||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCING;
|
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCING;
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_BOLUS_DELIVERED;
|
import static sugar.free.sightparser.handling.HistoryBroadcast.*;
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_BOLUS_PROGRAMMED;
|
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_END_OF_TBR;
|
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_PUMP_STATUS_CHANGED;
|
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_STILL_SYNCING;
|
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_SYNC_FINISHED;
|
|
||||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_SYNC_STARTED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jamorham on 27/01/2018.
|
* Created by jamorham on 27/01/2018.
|
||||||
|
@ -45,6 +39,7 @@ public class HistoryReceiver {
|
||||||
filter.addAction(ACTION_BOLUS_PROGRAMMED);
|
filter.addAction(ACTION_BOLUS_PROGRAMMED);
|
||||||
filter.addAction(ACTION_BOLUS_DELIVERED);
|
filter.addAction(ACTION_BOLUS_DELIVERED);
|
||||||
filter.addAction(ACTION_END_OF_TBR);
|
filter.addAction(ACTION_END_OF_TBR);
|
||||||
|
filter.addAction(ACTION_DAILY_TOTAL);
|
||||||
filter.addAction(ACTION_SYNC_STARTED);
|
filter.addAction(ACTION_SYNC_STARTED);
|
||||||
filter.addAction(ACTION_STILL_SYNCING);
|
filter.addAction(ACTION_STILL_SYNCING);
|
||||||
filter.addAction(ACTION_SYNC_FINISHED);
|
filter.addAction(ACTION_SYNC_FINISHED);
|
||||||
|
@ -95,6 +90,9 @@ public class HistoryReceiver {
|
||||||
case ACTION_END_OF_TBR:
|
case ACTION_END_OF_TBR:
|
||||||
intentAdapter.processTBRIntent(intent);
|
intentAdapter.processTBRIntent(intent);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_DAILY_TOTAL:
|
||||||
|
intentAdapter.processDailyTotalIntent(intent);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ import info.nightscout.utils.SafeParse;
|
||||||
* Created by mike on 24.06.2017.
|
* Created by mike on 24.06.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInterface{
|
public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
|
||||||
|
|
||||||
static SensitivityAAPSPlugin plugin = null;
|
static SensitivityAAPSPlugin plugin = null;
|
||||||
|
@ -118,7 +118,9 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
String sensResult = "";
|
String sensResult = "";
|
||||||
|
|
||||||
log.debug("Records: " + index + " " + pastSensitivity);
|
if (Config.logAutosensData)
|
||||||
|
log.debug("Records: " + index + " " + pastSensitivity);
|
||||||
|
|
||||||
Arrays.sort(deviations);
|
Arrays.sort(deviations);
|
||||||
|
|
||||||
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
||||||
|
@ -133,7 +135,8 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
|
||||||
sensResult = "Sensitivity normal";
|
sensResult = "Sensitivity normal";
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(sensResult);
|
if (Config.logAutosensData)
|
||||||
|
log.debug(sensResult);
|
||||||
|
|
||||||
double rawRatio = ratio;
|
double rawRatio = ratio;
|
||||||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
||||||
|
|
|
@ -118,7 +118,9 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
String sensResult = "";
|
String sensResult = "";
|
||||||
|
|
||||||
log.debug("Records: " + index + " " + pastSensitivity);
|
if (Config.logAutosensData)
|
||||||
|
log.debug("Records: " + index + " " + pastSensitivity);
|
||||||
|
|
||||||
Arrays.sort(deviations);
|
Arrays.sort(deviations);
|
||||||
|
|
||||||
for (double i = 0.9; i > 0.1; i = i - 0.02) {
|
for (double i = 0.9; i > 0.1; i = i - 0.02) {
|
||||||
|
@ -140,7 +142,10 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
|
||||||
} else {
|
} else {
|
||||||
sensResult = "Sensitivity normal";
|
sensResult = "Sensitivity normal";
|
||||||
}
|
}
|
||||||
log.debug(sensResult);
|
|
||||||
|
if (Config.logAutosensData)
|
||||||
|
log.debug(sensResult);
|
||||||
|
|
||||||
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||||
|
|
||||||
double rawRatio = ratio;
|
double rawRatio = ratio;
|
||||||
|
|
|
@ -315,7 +315,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
switch (splited[1].toUpperCase()) {
|
switch (splited[1].toUpperCase()) {
|
||||||
case "REFRESH":
|
case "REFRESH":
|
||||||
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||||
MainApp.getDbHelper().resetTreatments();
|
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
||||||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||||
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0);
|
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(restartNSClient, 0);
|
||||||
reply = "TERATMENTS REFRESH " + q.size() + " receivers";
|
reply = "TERATMENTS REFRESH " + q.size() + " receivers";
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package info.nightscout.androidaps.db;
|
package info.nightscout.androidaps.plugins.Treatments;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -14,6 +16,8 @@ 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.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
|
@ -21,11 +25,14 @@ import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWith
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.JsonHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TREATMENTS)
|
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
|
||||||
public class Treatment implements DataPointWithLabelInterface {
|
public class Treatment implements DataPointWithLabelInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(Treatment.class);
|
private static Logger log = LoggerFactory.getLogger(Treatment.class);
|
||||||
|
|
||||||
|
public static final String TABLE_TREATMENTS = "Treatments";
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
public long date;
|
public long date;
|
||||||
|
|
||||||
|
@ -57,6 +64,32 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
public Treatment() {
|
public Treatment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Treatment createFromJson(JSONObject json) throws JSONException {
|
||||||
|
Treatment treatment = new Treatment();
|
||||||
|
treatment.source = Source.NIGHTSCOUT;
|
||||||
|
treatment.date = DateUtil.roundDateToSec(JsonHelper.safeGetLong(json, "mills"));
|
||||||
|
if (treatment.date == 0L)
|
||||||
|
return null;
|
||||||
|
treatment.carbs = JsonHelper.safeGetDouble(json,"carbs");
|
||||||
|
treatment.insulin = JsonHelper.safeGetDouble(json,"insulin");
|
||||||
|
treatment.pumpId = JsonHelper.safeGetLong(json, "pumpId");
|
||||||
|
treatment._id = json.getString("_id");
|
||||||
|
treatment.isSMB = JsonHelper.safeGetBoolean(json,"isSMB");
|
||||||
|
if (json.has("eventType")) {
|
||||||
|
treatment.mealBolus = !json.get("eventType").equals("Correction Bolus");
|
||||||
|
double carbs = treatment.carbs;
|
||||||
|
if (json.has("boluscalc")) {
|
||||||
|
JSONObject boluscalc = json.getJSONObject("boluscalc");
|
||||||
|
if (boluscalc.has("carbs")) {
|
||||||
|
carbs = Math.max(boluscalc.getDouble("carbs"), carbs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (carbs <= 0)
|
||||||
|
treatment.mealBolus = false;
|
||||||
|
}
|
||||||
|
return treatment;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Treatment{" +
|
return "Treatment{" +
|
||||||
"date= " + date +
|
"date= " + date +
|
||||||
|
@ -72,9 +105,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDataChanging(Treatment other) {
|
public boolean isDataChanging(Treatment other) {
|
||||||
if (date != other.date) {
|
if (date != other.date)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
if (insulin != other.insulin)
|
if (insulin != other.insulin)
|
||||||
return true;
|
return true;
|
||||||
if (carbs != other.carbs)
|
if (carbs != other.carbs)
|
||||||
|
@ -83,9 +115,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEqual(Treatment other) {
|
public boolean isEqual(Treatment other) {
|
||||||
if (date != other.date) {
|
if (date != other.date)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (insulin != other.insulin)
|
if (insulin != other.insulin)
|
||||||
return false;
|
return false;
|
||||||
if (carbs != other.carbs)
|
if (carbs != other.carbs)
|
|
@ -0,0 +1,426 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Treatments;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
|
import com.j256.ormlite.android.apptools.OrmLiteBaseService;
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
import com.j256.ormlite.dao.DaoManager;
|
||||||
|
import com.j256.ormlite.stmt.PreparedQuery;
|
||||||
|
import com.j256.ormlite.stmt.QueryBuilder;
|
||||||
|
import com.j256.ormlite.stmt.Where;
|
||||||
|
import com.j256.ormlite.support.ConnectionSource;
|
||||||
|
import com.j256.ormlite.table.TableUtils;
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.db.ICallback;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
import info.nightscout.androidaps.events.Event;
|
||||||
|
import info.nightscout.androidaps.events.EventNsTreatment;
|
||||||
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||||
|
import info.nightscout.utils.JsonHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 24.09.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TreatmentService.class);
|
||||||
|
|
||||||
|
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;
|
||||||
|
|
||||||
|
public TreatmentService() {
|
||||||
|
onCreate();
|
||||||
|
dbInitialize();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is a simple re-implementation of the database create and up/downgrade functionality
|
||||||
|
* in SQLiteOpenHelper#getDatabaseLocked method.
|
||||||
|
* <p>
|
||||||
|
* It is implemented to be able to late initialize separate plugins of the application.
|
||||||
|
*/
|
||||||
|
protected void dbInitialize() {
|
||||||
|
DatabaseHelper helper = OpenHelperManager.getHelper(this, DatabaseHelper.class);
|
||||||
|
int newVersion = helper.getNewVersion();
|
||||||
|
int oldVersion = helper.getOldVersion();
|
||||||
|
|
||||||
|
if (oldVersion > newVersion) {
|
||||||
|
onDowngrade(this.getConnectionSource(), oldVersion, newVersion);
|
||||||
|
} else {
|
||||||
|
onUpgrade(this.getConnectionSource(), oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dao<Treatment, Long> getDao() {
|
||||||
|
try {
|
||||||
|
return DaoManager.createDao(this.getConnectionSource(), Treatment.class);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Cannot create Dao for Treatment.class");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void handleNsEvent(EventNsTreatment event) {
|
||||||
|
int mode = event.getMode();
|
||||||
|
JSONObject payload = event.getPayload();
|
||||||
|
|
||||||
|
if (mode == EventNsTreatment.ADD || mode == EventNsTreatment.UPDATE) {
|
||||||
|
this.createTreatmentFromJsonIfNotExists(payload);
|
||||||
|
} else { // EventNsTreatment.REMOVE
|
||||||
|
this.deleteNS(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
try {
|
||||||
|
log.info("onCreate");
|
||||||
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Can't create database", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
|
if (oldVersion == 7 && newVersion == 8) {
|
||||||
|
log.debug("Upgrading database from v7 to v8");
|
||||||
|
try {
|
||||||
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Can't create database", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("onUpgrade");
|
||||||
|
// this.resetFood();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDowngrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
|
// this method is not supported right now
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTreatments() {
|
||||||
|
try {
|
||||||
|
TableUtils.dropTable(this.getConnectionSource(), Treatment.class, true);
|
||||||
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(0);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
scheduleTreatmentChange(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A place to centrally register events to be posted, if any data changed.
|
||||||
|
* This should be implemented in an abstract service-class.
|
||||||
|
* <p>
|
||||||
|
* We do need to make sure, that ICallback is extended to be able to handle multiple
|
||||||
|
* events, or handle a list of events.
|
||||||
|
* <p>
|
||||||
|
* on some methods the earliestDataChange event is handled separatly, in that it is checked if it is
|
||||||
|
* set to null by another event already (eg. scheduleExtendedBolusChange).
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @param eventWorker
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
private void scheduleEvent(final Event event, ScheduledExecutorService eventWorker,
|
||||||
|
final ICallback callback) {
|
||||||
|
|
||||||
|
class PostRunnable implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
log.debug("Firing EventFoodChange");
|
||||||
|
MainApp.bus().post(event);
|
||||||
|
if (DatabaseHelper.earliestDataChange != null)
|
||||||
|
MainApp.bus().post(new EventNewHistoryData(DatabaseHelper.earliestDataChange));
|
||||||
|
DatabaseHelper.earliestDataChange = null;
|
||||||
|
callback.setPost(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// prepare task for execution in 1 sec
|
||||||
|
// cancel waiting task to prevent sending multiple posts
|
||||||
|
if (callback.getPost() != null)
|
||||||
|
callback.getPost().cancel(false);
|
||||||
|
Runnable task = new PostRunnable();
|
||||||
|
final int sec = 1;
|
||||||
|
callback.setPost(eventWorker.schedule(task, sec, TimeUnit.SECONDS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule a foodChange Event.
|
||||||
|
*/
|
||||||
|
public void scheduleTreatmentChange(@Nullable final Treatment treatment) {
|
||||||
|
this.scheduleEvent(new EventReloadTreatmentData(new EventTreatmentChange(treatment)), treatmentEventWorker, new ICallback() {
|
||||||
|
@Override
|
||||||
|
public void setPost(ScheduledFuture<?> post) {
|
||||||
|
scheduledTreatmentEventPost = post;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScheduledFuture<?> getPost() {
|
||||||
|
return scheduledTreatmentEventPost;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Treatment> getTreatmentData() {
|
||||||
|
try {
|
||||||
|
return this.getDao().queryForAll();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"_id": "551ee3ad368e06e80856e6a9",
|
||||||
|
"type": "food",
|
||||||
|
"category": "Zakladni",
|
||||||
|
"subcategory": "Napoje",
|
||||||
|
"name": "Mleko",
|
||||||
|
"portion": 250,
|
||||||
|
"carbs": 12,
|
||||||
|
"gi": 1,
|
||||||
|
"created_at": "2015-04-14T06:59:16.500Z",
|
||||||
|
"unit": "ml"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public void createTreatmentFromJsonIfNotExists(JSONObject json) {
|
||||||
|
try {
|
||||||
|
Treatment treatment = Treatment.createFromJson(json);
|
||||||
|
if (treatment != null)
|
||||||
|
createOrUpdate(treatment);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createFoodFromJsonIfNotExists(JSONArray array) {
|
||||||
|
try {
|
||||||
|
for (int n = 0; n < array.length(); n++) {
|
||||||
|
JSONObject json = array.getJSONObject(n);
|
||||||
|
createTreatmentFromJsonIfNotExists(json);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return true if new record is created
|
||||||
|
public boolean createOrUpdate(Treatment treatment) {
|
||||||
|
try {
|
||||||
|
Treatment old;
|
||||||
|
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
|
||||||
|
|
||||||
|
if (treatment.source == Source.PUMP) {
|
||||||
|
// check for changed from pump change in NS
|
||||||
|
QueryBuilder<Treatment, Long> queryBuilder = getDao().queryBuilder();
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("pumpId", treatment.pumpId);
|
||||||
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
|
List<Treatment> trList = getDao().query(preparedQuery);
|
||||||
|
if (trList.size() > 0) {
|
||||||
|
// do nothing, pump history record cannot be changed
|
||||||
|
log.debug("TREATMENT: Pump record already found in database: " + treatment.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
getDao().create(treatment);
|
||||||
|
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (treatment.source == Source.NIGHTSCOUT) {
|
||||||
|
old = getDao().queryForId(treatment.date);
|
||||||
|
if (old != null) {
|
||||||
|
if (!old.isEqual(treatment)) {
|
||||||
|
boolean historyChange = old.isDataChanging(treatment);
|
||||||
|
long oldDate = old.date;
|
||||||
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
|
old.copyFrom(treatment);
|
||||||
|
getDao().create(old);
|
||||||
|
log.debug("TREATMENT: Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
|
if (historyChange) {
|
||||||
|
DatabaseHelper.updateEarliestDataChange(oldDate);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(old.date);
|
||||||
|
}
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// find by NS _id
|
||||||
|
if (treatment._id != null) {
|
||||||
|
old = findByNSId(treatment._id);
|
||||||
|
if (old != null) {
|
||||||
|
if (!old.isEqual(treatment)) {
|
||||||
|
boolean historyChange = old.isDataChanging(treatment);
|
||||||
|
long oldDate = old.date;
|
||||||
|
getDao().delete(old); // need to delete/create because date may change too
|
||||||
|
old.copyFrom(treatment);
|
||||||
|
getDao().create(old);
|
||||||
|
log.debug("TREATMENT: Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString());
|
||||||
|
if (historyChange) {
|
||||||
|
DatabaseHelper.updateEarliestDataChange(oldDate);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(old.date);
|
||||||
|
}
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getDao().create(treatment);
|
||||||
|
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (treatment.source == Source.USER) {
|
||||||
|
getDao().create(treatment);
|
||||||
|
log.debug("TREATMENT: New record from: " + Source.getString(treatment.source) + " " + treatment.toString());
|
||||||
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteNS(JSONObject json) {
|
||||||
|
String _id = JsonHelper.safeGetString(json, "_id");
|
||||||
|
if (_id != null && !_id.isEmpty())
|
||||||
|
this.deleteByNSId(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes an entry by its NS Id.
|
||||||
|
* <p>
|
||||||
|
* Basically a convenience method for findByNSId and delete.
|
||||||
|
*
|
||||||
|
* @param _id
|
||||||
|
*/
|
||||||
|
private void deleteByNSId(String _id) {
|
||||||
|
Treatment stored = findByNSId(_id);
|
||||||
|
if (stored != null) {
|
||||||
|
log.debug("TREATMENT: Removing Treatment record from database: " + stored.toString());
|
||||||
|
delete(stored);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(stored.date);
|
||||||
|
scheduleTreatmentChange(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes the treatment and sends the treatmentChange Event
|
||||||
|
* <p>
|
||||||
|
* should be moved ot a Service
|
||||||
|
*
|
||||||
|
* @param treatment
|
||||||
|
*/
|
||||||
|
public void delete(Treatment treatment) {
|
||||||
|
try {
|
||||||
|
getDao().delete(treatment);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
|
this.scheduleTreatmentChange(treatment);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Treatment treatment) {
|
||||||
|
try {
|
||||||
|
getDao().update(treatment);
|
||||||
|
DatabaseHelper.updateEarliestDataChange(treatment.date);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
scheduleTreatmentChange(treatment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* finds treatment by its NS Id.
|
||||||
|
*
|
||||||
|
* @param _id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Treatment findByNSId(String _id) {
|
||||||
|
try {
|
||||||
|
Dao<Treatment, Long> daoTreatments = getDao();
|
||||||
|
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("_id", _id);
|
||||||
|
queryBuilder.limit(10L);
|
||||||
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
|
List<Treatment> trList = daoTreatments.query(preparedQuery);
|
||||||
|
if (trList.size() != 1) {
|
||||||
|
//log.debug("Treatment findTreatmentById query size: " + trList.size());
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
//log.debug("Treatment findTreatmentById found: " + trList.get(0).log());
|
||||||
|
return trList.get(0);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
|
||||||
|
try {
|
||||||
|
Dao<Treatment, Long> daoTreatments = getDao();
|
||||||
|
List<Treatment> treatments;
|
||||||
|
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.ge("date", mills);
|
||||||
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
|
treatments = daoTreatments.query(preparedQuery);
|
||||||
|
return treatments;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,6 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
|
@ -43,6 +42,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -58,14 +58,16 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
return treatmentsPlugin;
|
return treatmentsPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TreatmentService service;
|
||||||
|
|
||||||
private IobTotal lastTreatmentCalculation;
|
private IobTotal lastTreatmentCalculation;
|
||||||
private IobTotal lastTempBasalsCalculation;
|
private IobTotal lastTempBasalsCalculation;
|
||||||
|
|
||||||
private final static ArrayList<Treatment> treatments = new ArrayList<>();
|
private final ArrayList<Treatment> treatments = new ArrayList<>();
|
||||||
private final static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<>();
|
private final Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<>();
|
||||||
private final static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<>();
|
private final Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<>();
|
||||||
private final static Intervals<TempTarget> tempTargets = new OverlappingIntervals<>();
|
private final Intervals<TempTarget> tempTargets = new OverlappingIntervals<>();
|
||||||
private final static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
private final ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
||||||
|
|
||||||
public TreatmentsPlugin() {
|
public TreatmentsPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
|
@ -76,6 +78,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
.preferencesId(R.xml.pref_absorption_oref0)
|
.preferencesId(R.xml.pref_absorption_oref0)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
);
|
);
|
||||||
|
this.service = new TreatmentService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,18 +97,22 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTreatmentData() {
|
public TreatmentService getService() {
|
||||||
|
return this.service;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeTreatmentData() {
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
synchronized (treatments) {
|
synchronized (treatments) {
|
||||||
treatments.clear();
|
treatments.clear();
|
||||||
treatments.addAll(MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false));
|
treatments.addAll(getService().getTreatmentDataFromTime(fromMills, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTempBasalData() {
|
private void initializeTempBasalData() {
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
|
@ -117,7 +124,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeExtendedBolusData() {
|
private void initializeExtendedBolusData() {
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
|
@ -203,7 +210,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
if (profile == null) return result;
|
if (profile == null) return result;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * T.hours(1).msecs())).longValue();
|
||||||
|
|
||||||
synchronized (treatments) {
|
synchronized (treatments) {
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
|
@ -235,7 +242,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
@Override
|
@Override
|
||||||
public List<Treatment> getTreatmentsFromHistory() {
|
public List<Treatment> getTreatmentsFromHistory() {
|
||||||
synchronized (treatments) {
|
synchronized (treatments) {
|
||||||
return (List<Treatment>) treatments.clone();
|
return new ArrayList<>(treatments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +307,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void onStatusEvent(final EventReloadTempBasalData ev) {
|
public void onStatusEvent(final EventReloadTempBasalData ev) {
|
||||||
log.debug("EventReloadTempBasalData");
|
log.debug("EventReloadTempBasalData");
|
||||||
initializeTempBasalData();
|
initializeTempBasalData();
|
||||||
|
@ -442,7 +450,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
treatment.carbs = detailedBolusInfo.carbs;
|
treatment.carbs = detailedBolusInfo.carbs;
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
treatment.mealBolus = treatment.carbs > 0;
|
treatment.mealBolus = treatment.carbs > 0;
|
||||||
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment);
|
boolean newRecordCreated = getService().createOrUpdate(treatment);
|
||||||
//log.debug("Adding new Treatment record" + treatment.toString());
|
//log.debug("Adding new Treatment record" + treatment.toString());
|
||||||
if (detailedBolusInfo.carbTime != 0) {
|
if (detailedBolusInfo.carbTime != 0) {
|
||||||
Treatment carbsTreatment = new Treatment();
|
Treatment carbsTreatment = new Treatment();
|
||||||
|
@ -451,7 +459,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
||||||
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
||||||
carbsTreatment.source = detailedBolusInfo.source;
|
carbsTreatment.source = detailedBolusInfo.source;
|
||||||
MainApp.getDbHelper().createOrUpdate(carbsTreatment);
|
getService().createOrUpdate(carbsTreatment);
|
||||||
//log.debug("Adding new Treatment record" + carbsTreatment);
|
//log.debug("Adding new Treatment record" + carbsTreatment);
|
||||||
}
|
}
|
||||||
if (newRecordCreated && detailedBolusInfo.isValid)
|
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||||
|
@ -480,6 +488,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
// TempTargets
|
// TempTargets
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
public void onStatusEvent(final EventTempTargetChange ev) {
|
||||||
initializeTempTargetData();
|
initializeTempTargetData();
|
||||||
}
|
}
|
||||||
|
@ -509,6 +518,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
// Profile Switch
|
// Profile Switch
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void onStatusEvent(final EventReloadProfileSwitchData ev) {
|
public void onStatusEvent(final EventReloadProfileSwitchData ev) {
|
||||||
initializeProfileSwitchData();
|
initializeProfileSwitchData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.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;
|
||||||
|
@ -145,14 +145,14 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
final String _id = treatment._id;
|
final String _id = treatment._id;
|
||||||
if (treatment.source == Source.PUMP) {
|
if (treatment.source == Source.PUMP) {
|
||||||
treatment.isValid = false;
|
treatment.isValid = false;
|
||||||
MainApp.getDbHelper().update(treatment);
|
TreatmentsPlugin.getPlugin().getService().update(treatment);
|
||||||
} else {
|
} else {
|
||||||
if (NSUpload.isIdValid(_id)) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
} else {
|
} else {
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(treatment);
|
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
||||||
}
|
}
|
||||||
updateGUI();
|
updateGUI();
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
||||||
|
@ -204,7 +204,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?");
|
builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?");
|
||||||
builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
MainApp.getDbHelper().resetTreatments();
|
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
||||||
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
|
|
@ -299,9 +299,10 @@ public class CommandQueue {
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean setProfile(Profile profile, Callback callback) {
|
public boolean setProfile(Profile profile, Callback callback) {
|
||||||
if (isRunning(Command.CommandType.BASALPROFILE)) {
|
if (isThisProfileSet(profile)) {
|
||||||
|
log.debug("QUEUE: Correct profile already set");
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(executingNowError()).run();
|
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,13 +330,6 @@ public class CommandQueue {
|
||||||
|
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.BASAL_VALUE_BELOW_MINIMUM));
|
MainApp.bus().post(new EventDismissNotification(Notification.BASAL_VALUE_BELOW_MINIMUM));
|
||||||
|
|
||||||
if (isThisProfileSet(profile)) {
|
|
||||||
log.debug("QUEUE: Correct profile already set");
|
|
||||||
if (callback != null)
|
|
||||||
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove all unfinished
|
// remove all unfinished
|
||||||
removeAll(Command.CommandType.BASALPROFILE);
|
removeAll(Command.CommandType.BASALPROFILE);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.queue.commands;
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
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.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -17,6 +20,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandSetProfile extends Command {
|
public class CommandSetProfile extends Command {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CommandSetProfile.class);
|
||||||
private Profile profile;
|
private Profile profile;
|
||||||
|
|
||||||
public CommandSetProfile(Profile profile, Callback callback) {
|
public CommandSetProfile(Profile profile, Callback callback) {
|
||||||
|
@ -27,6 +31,13 @@ public class CommandSetProfile extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
if (ConfigBuilderPlugin.getCommandQueue().isThisProfileSet(profile)) {
|
||||||
|
log.debug("QUEUE: Correct profile already set");
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(r).run();
|
callback.result(r).run();
|
||||||
|
|
|
@ -167,4 +167,8 @@ public class DateUtil {
|
||||||
return System.currentTimeMillis();
|
return System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long roundDateToSec(long date) {
|
||||||
|
return date - date % 1000;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,41 +17,79 @@ public class JsonHelper {
|
||||||
|
|
||||||
private JsonHelper() {};
|
private JsonHelper() {};
|
||||||
|
|
||||||
public static String safeGetString(JSONObject json, String fieldName) throws JSONException {
|
public static String safeGetString(JSONObject json, String fieldName) {
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
if (json.has(fieldName)) {
|
if (json.has(fieldName)) {
|
||||||
result = json.getString(fieldName);
|
try {
|
||||||
|
result = json.getString(fieldName);
|
||||||
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String safeGetString(JSONObject json, String fieldName, String defaultValue) throws JSONException {
|
public static String safeGetString(JSONObject json, String fieldName, String defaultValue) {
|
||||||
String result = defaultValue;
|
String result = defaultValue;
|
||||||
|
|
||||||
if (json.has(fieldName)) {
|
if (json.has(fieldName)) {
|
||||||
result = json.getString(fieldName);
|
try {
|
||||||
|
result = json.getString(fieldName);
|
||||||
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double safeGetDouble(JSONObject json, String fieldName) throws JSONException {
|
public static double safeGetDouble(JSONObject json, String fieldName) {
|
||||||
double result = 0d;
|
double result = 0d;
|
||||||
|
|
||||||
if (json.has(fieldName)) {
|
if (json.has(fieldName)) {
|
||||||
result = json.getDouble(fieldName);
|
try {
|
||||||
|
result = json.getDouble(fieldName);
|
||||||
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int safeGetInt(JSONObject json, String fieldName) throws JSONException {
|
public static int safeGetInt(JSONObject json, String fieldName) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (json.has(fieldName)) {
|
if (json.has(fieldName)) {
|
||||||
result = json.getInt(fieldName);
|
try {
|
||||||
|
result = json.getInt(fieldName);
|
||||||
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long safeGetLong(JSONObject json, String fieldName) {
|
||||||
|
long result = 0;
|
||||||
|
|
||||||
|
if (json.has(fieldName)) {
|
||||||
|
try {
|
||||||
|
result = json.getLong(fieldName);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean safeGetBoolean(JSONObject json, String fieldName) {
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
if (json.has(fieldName)) {
|
||||||
|
try {
|
||||||
|
result = json.getBoolean(fieldName);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".plugins.PumpCombo.ComboFragment">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView3"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:text="Alerts"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/profileview_datedelimiter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dip"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:background="@color/listdelimiter" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/combo_error_history_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAlignment="textStart"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:gravity="start"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -1,54 +0,0 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".plugins.PumpCombo.ComboFragment">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView3"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:text="@string/combo_tdds"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/profileview_datedelimiter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dip"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:background="@color/listdelimiter" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/combo_tdd_history_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="start"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:textAlignment="textStart" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -499,46 +499,6 @@
|
||||||
android:paddingLeft="0dp"
|
android:paddingLeft="0dp"
|
||||||
android:paddingRight="0dp"
|
android:paddingRight="0dp"
|
||||||
android:text="@string/combo_refresh" />
|
android:text="@string/combo_refresh" />
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
|
||||||
android:id="@+id/combo_alerts_button"
|
|
||||||
style="@style/ButtonSmallFontStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:layout_marginRight="-4dp"
|
|
||||||
android:drawableTop="@drawable/icon_cp_announcement"
|
|
||||||
android:paddingLeft="0dp"
|
|
||||||
android:paddingRight="0dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/combo_pump_alerts" />
|
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
|
||||||
android:id="@+id/combo_tdds_button"
|
|
||||||
style="@style/ButtonSmallFontStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:layout_marginRight="-4dp"
|
|
||||||
android:drawableTop="@drawable/icon_danarstats"
|
|
||||||
android:paddingLeft="0dp"
|
|
||||||
android:paddingRight="0dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/combo_tdds" />
|
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
|
||||||
android:id="@+id/combo_full_history_button"
|
|
||||||
style="@style/ButtonSmallFontStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:layout_marginRight="-4dp"
|
|
||||||
android:drawableTop="@drawable/icon_danarhistory"
|
|
||||||
android:paddingLeft="0dp"
|
|
||||||
android:paddingRight="0dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/combo_history" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -678,9 +678,6 @@
|
||||||
<string name="shortenergy">En</string>
|
<string name="shortenergy">En</string>
|
||||||
<string name="raise_notifications_as_android_notifications">Използвай системни известия за аларми и съобщения</string>
|
<string name="raise_notifications_as_android_notifications">Използвай системни известия за аларми и съобщения</string>
|
||||||
<string name="combo_warning">Внимание</string>
|
<string name="combo_warning">Внимание</string>
|
||||||
<string name="combo_tdd_minimum" formatted="false">Минимум: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_maximum" formatted="false">Максимум: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_average" formatted="false">Средно: %3.1f U</string>
|
|
||||||
<string name="combo_reservoir_normal">Нормално</string>
|
<string name="combo_reservoir_normal">Нормално</string>
|
||||||
<string name="combo_reservoir_low">Ниско</string>
|
<string name="combo_reservoir_low">Ниско</string>
|
||||||
<string name="combo_reservoir_level_insufficient_for_bolus">Няма достатъчно инсулин в резервоара</string>
|
<string name="combo_reservoir_level_insufficient_for_bolus">Няма достатъчно инсулин в резервоара</string>
|
||||||
|
|
|
@ -704,7 +704,6 @@
|
||||||
<string name="bolus_frequency_exceeded">Bolus stejné velikosti už byl během poslední minuty požadován. Jako preventivní ochrana před zdvojeným bolusem byla operace zakázána.</string>
|
<string name="bolus_frequency_exceeded">Bolus stejné velikosti už byl během poslední minuty požadován. Jako preventivní ochrana před zdvojeným bolusem byla operace zakázána.</string>
|
||||||
<string name="combo_pump_connected_now">Teď</string>
|
<string name="combo_pump_connected_now">Teď</string>
|
||||||
<string name="combo_activity_reading_pump_history">Načítání historie pumpy</string>
|
<string name="combo_activity_reading_pump_history">Načítání historie pumpy</string>
|
||||||
<string name="combo_pump_alerts">Výstrahy</string>
|
|
||||||
<string name="combo_activity_setting_basal_profile">Nastavení bazálního profilu</string>
|
<string name="combo_activity_setting_basal_profile">Nastavení bazálního profilu</string>
|
||||||
<string name="combo_pump_cartridge_low_warrning">V zásobníku je málo inzulínu</string>
|
<string name="combo_pump_cartridge_low_warrning">V zásobníku je málo inzulínu</string>
|
||||||
<string name="combo_pump_battery_low_warrning">Slabá baterie v pumpě</string>
|
<string name="combo_pump_battery_low_warrning">Slabá baterie v pumpě</string>
|
||||||
|
@ -713,18 +712,12 @@
|
||||||
<string name="combo_error_bolus_verification_failed">Provádění bolusu a čtení historie selhalo. Zkontrolujte pumpu a zadejte bolus přes péči</string>
|
<string name="combo_error_bolus_verification_failed">Provádění bolusu a čtení historie selhalo. Zkontrolujte pumpu a zadejte bolus přes péči</string>
|
||||||
<string name="combo_error_no_bolus_delivered">Provádění bolusu selhalo. Zdá se, že žádný bolus nebyl podán. Zkontrolujte pumpu a případně pošlete bolus znovu. Jako bezpečnostní opatření podání bolusu není opakováno.</string>
|
<string name="combo_error_no_bolus_delivered">Provádění bolusu selhalo. Zdá se, že žádný bolus nebyl podán. Zkontrolujte pumpu a případně pošlete bolus znovu. Jako bezpečnostní opatření podání bolusu není opakováno.</string>
|
||||||
<string name="combo_error_partial_bolus_delivered" formatted="false">Pouze %.2f U z bolusu %.2f bylo podáno díky chybě. Zkontrolujte pumpu a proveďte nápravu.</string>
|
<string name="combo_error_partial_bolus_delivered" formatted="false">Pouze %.2f U z bolusu %.2f bylo podáno díky chybě. Zkontrolujte pumpu a proveďte nápravu.</string>
|
||||||
<string name="combo_history">Historie</string>
|
|
||||||
<string name="combo_pump_tbr_cancelled_warrning">Varování o ukončeném dočasném bazálu bylo potvrzeno.</string>
|
<string name="combo_pump_tbr_cancelled_warrning">Varování o ukončeném dočasném bazálu bylo potvrzeno.</string>
|
||||||
<string name="combo_warning">Varování</string>
|
<string name="combo_warning">Varování</string>
|
||||||
<string name="combo_reservoir_empty">Prázdný</string>
|
<string name="combo_reservoir_empty">Prázdný</string>
|
||||||
<string name="combo_reservoir_low">Nízký</string>
|
<string name="combo_reservoir_low">Nízký</string>
|
||||||
<string name="combo_reservoir_normal">Normální</string>
|
<string name="combo_reservoir_normal">Normální</string>
|
||||||
<string name="combo_tdd_average" formatted="false">Průměr: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_maximum" formatted="false">Maximum: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_minimum" formatted="false">Minimum: %3.1f U</string>
|
|
||||||
<string name="combo_no_alert_data_note">Pro přečtení historie chyb dlouze stiskněte tlačítko ALERTS. Varování: může to způsobit chybu, že pumpa bude odmítat všechny připojení a je pak vyžadováno stisknutí tlačítka na pumpě pro obnovení komunikace.</string>
|
|
||||||
<string name="combo_notification_check_time_date">Je vyžadována aktualizace času na pumpě</string>
|
<string name="combo_notification_check_time_date">Je vyžadována aktualizace času na pumpě</string>
|
||||||
<string name="combo_no_tdd_data_note">Pro přečtení celkových denních dávek dlouze stikněte na pumpě tlačítko TDDS. Varování: může to způsobit chybu, že pumpa bude odmítat všechna připojení a je pak vyžadováno stisknutí tlačítka na pumpě pro obnovení komunikace.</string>
|
|
||||||
<string name="combo_reservoir_level_insufficient_for_bolus">Nedostatek inzulínu pro takovýto bolus</string>
|
<string name="combo_reservoir_level_insufficient_for_bolus">Nedostatek inzulínu pro takovýto bolus</string>
|
||||||
<string name="extendedbolusdeliveryerror">Chyba spuštění extended bolusu</string>
|
<string name="extendedbolusdeliveryerror">Chyba spuštění extended bolusu</string>
|
||||||
<string name="smb_shortname">SMB</string>
|
<string name="smb_shortname">SMB</string>
|
||||||
|
@ -823,8 +816,6 @@
|
||||||
<string name="bolusrecordedonly">Bolus bude pouze zaznamenán</string>
|
<string name="bolusrecordedonly">Bolus bude pouze zaznamenán</string>
|
||||||
<string name="ns_autobackfill">Automaticky doplňovat chybějící glykémie z NS</string>
|
<string name="ns_autobackfill">Automaticky doplňovat chybějící glykémie z NS</string>
|
||||||
<string name="hypo">Hypoglykémie</string>
|
<string name="hypo">Hypoglykémie</string>
|
||||||
<string name="combo_tdds">CDD</string>
|
|
||||||
<string name="combo_read_full_history_info">Dlouhé stisknutí tohoto tlačítka pro plné načtení historie a bazálního profilu z pumpy. Obvykle to není nutné, protože se to děje průběžně, ale může to pomoci v případě změny datumu v pumpě nebo v případě výměny pumpy.</string>
|
|
||||||
<string name="overview_show_sensitivity">Citlivost</string>
|
<string name="overview_show_sensitivity">Citlivost</string>
|
||||||
<string name="overview_show_deviations">Odchylky</string>
|
<string name="overview_show_deviations">Odchylky</string>
|
||||||
<string name="overview_show_cob">Zbývající sacharidy</string>
|
<string name="overview_show_cob">Zbývající sacharidy</string>
|
||||||
|
|
|
@ -666,7 +666,6 @@
|
||||||
<string name="combo_pump_state_suspended_by_user">Gestoppt (Benutzer)</string>
|
<string name="combo_pump_state_suspended_by_user">Gestoppt (Benutzer)</string>
|
||||||
<string name="combo_pump_state_suspended_due_to_error">Gestoppt (Fehler)</string>
|
<string name="combo_pump_state_suspended_due_to_error">Gestoppt (Fehler)</string>
|
||||||
<string name="combo_pump_state_running">In Betrieb</string>
|
<string name="combo_pump_state_running">In Betrieb</string>
|
||||||
<string name="combo_tdds">TDDS</string>
|
|
||||||
<string name="combo_programming_bolus">Bolusabgabe wird vorbereitet</string>
|
<string name="combo_programming_bolus">Bolusabgabe wird vorbereitet</string>
|
||||||
<string name="combo_pump_action_cancelling_tbr">TBR wird abgebrochen</string>
|
<string name="combo_pump_action_cancelling_tbr">TBR wird abgebrochen</string>
|
||||||
<string name="combo_pump_action_setting_tbr">TBR wird gesetzt (%d%% / %d Min.)</string>
|
<string name="combo_pump_action_setting_tbr">TBR wird gesetzt (%d%% / %d Min.)</string>
|
||||||
|
@ -680,7 +679,6 @@
|
||||||
<string name="combo_error_bolus_verification_failed">Der abgegebene Bolus konnte nicht bestätigt werden. Bitte prüfe auf der Pumpe, ob ein Bolus abgegeben wurde und erstelle einen Eintrag im Careportal falls nötig.</string>
|
<string name="combo_error_bolus_verification_failed">Der abgegebene Bolus konnte nicht bestätigt werden. Bitte prüfe auf der Pumpe, ob ein Bolus abgegeben wurde und erstelle einen Eintrag im Careportal falls nötig.</string>
|
||||||
<string name="combo_error_no_bolus_delivered">Die Bolusabgabe ist fehlgeschlagen: Es wurde scheinbar kein Bolus abgegeben. Bitte prüfe auf der Pumpe, ob ein Bolus abgegeben wurde. Um doppelte Boli durch Programmfehler zu vermeiden, werden Boli nicht automatisch wiederholt.</string>
|
<string name="combo_error_no_bolus_delivered">Die Bolusabgabe ist fehlgeschlagen: Es wurde scheinbar kein Bolus abgegeben. Bitte prüfe auf der Pumpe, ob ein Bolus abgegeben wurde. Um doppelte Boli durch Programmfehler zu vermeiden, werden Boli nicht automatisch wiederholt.</string>
|
||||||
<string name="combo_error_partial_bolus_delivered">Wegen eines Fehlers wurden nur %.2f IE von den angeforderten %.2f IE abgegeben. Bitte prüfe den abgegebenen Bolus auf der Pumpe.</string>
|
<string name="combo_error_partial_bolus_delivered">Wegen eines Fehlers wurden nur %.2f IE von den angeforderten %.2f IE abgegeben. Bitte prüfe den abgegebenen Bolus auf der Pumpe.</string>
|
||||||
<string name="combo_history">Historie</string>
|
|
||||||
<string name="combo_pump_action_refreshing">Status wird aktualisiert</string>
|
<string name="combo_pump_action_refreshing">Status wird aktualisiert</string>
|
||||||
<string name="combo_pump_state_initializing">Die Pumpe wird initialisiert</string>
|
<string name="combo_pump_state_initializing">Die Pumpe wird initialisiert</string>
|
||||||
<string name="combo_pump_connected_now">Jetzt</string>
|
<string name="combo_pump_connected_now">Jetzt</string>
|
||||||
|
@ -689,19 +687,13 @@
|
||||||
<string name="combo_reservoir_empty">Leer</string>
|
<string name="combo_reservoir_empty">Leer</string>
|
||||||
<string name="combo_reservoir_low">Niedrig</string>
|
<string name="combo_reservoir_low">Niedrig</string>
|
||||||
<string name="combo_reservoir_normal">Normal</string>
|
<string name="combo_reservoir_normal">Normal</string>
|
||||||
<string name="combo_tdd_average">Durchschnitt: %3.1f IE</string>
|
|
||||||
<string name="combo_tdd_maximum">Maximum: %3.1f IE</string>
|
|
||||||
<string name="combo_tdd_minimum">Minimum: %3.1f IE</string>
|
|
||||||
<string name="combo_pump_unsupported_operation">Diese Aktion wird von der Pumpe nicht unterstützt</string>
|
<string name="combo_pump_unsupported_operation">Diese Aktion wird von der Pumpe nicht unterstützt</string>
|
||||||
<string name="combo_pump_alerts">Alarme</string>
|
|
||||||
<string name="combo_pump_battery_low_warrning">Die Batterie in der Pumpe ist fast leer</string>
|
<string name="combo_pump_battery_low_warrning">Die Batterie in der Pumpe ist fast leer</string>
|
||||||
<string name="combo_pump_cartridge_low_warrning">Das Reservoir in der Pumpe ist fast leer</string>
|
<string name="combo_pump_cartridge_low_warrning">Das Reservoir in der Pumpe ist fast leer</string>
|
||||||
<string name="combo_is_in_error_state">Die Pumpe zeigt einen Fehler an E%d: %s</string>
|
<string name="combo_is_in_error_state">Die Pumpe zeigt einen Fehler an E%d: %s</string>
|
||||||
<string name="combo_force_disabled_notification">Unsichere Verwendung: In der Pumpe ist nicht das erste Basalratenprofil gewählt. Der Loop wird deaktiviert bis dies korrigiert ist.</string>
|
<string name="combo_force_disabled_notification">Unsichere Verwendung: In der Pumpe ist nicht das erste Basalratenprofil gewählt. Der Loop wird deaktiviert bis dies korrigiert ist.</string>
|
||||||
<string name="combo_low_suspend_forced_notification">Unsichere Verwendung: Ein erweiterter oder Multiwave-Bolus ist aktiv. Der Loop wird für die nächsten 6 Stunden kein zusätzliches Insulin abgeben.</string>
|
<string name="combo_low_suspend_forced_notification">Unsichere Verwendung: Ein erweiterter oder Multiwave-Bolus ist aktiv. Der Loop wird für die nächsten 6 Stunden kein zusätzliches Insulin abgeben.</string>
|
||||||
<string name="combo_no_alert_data_note">Um die Fehlerhistorie der Pumpe zu lesen, drücke lange auf ALARME.</string>
|
|
||||||
<string name="combo_notification_check_time_date">Bitte aktualisiere die Uhrzeit der Pumpe</string>
|
<string name="combo_notification_check_time_date">Bitte aktualisiere die Uhrzeit der Pumpe</string>
|
||||||
<string name="combo_no_tdd_data_note">Um die TDD-Statistik der Pumpe zu lesen, drücken Sie den TDDS Knopf lange.\nWARNUNG: Es gibt einen bekannten Fehler in der Pumpe der dazu führt, dass die Pumpe nach dieser Aktion erst wieder Verbindungen annimmt, wenn auf der Pumpe selbst ein Konpf gedrückt wird. Aus diesem Grund sollte diese Aktion nicht durchgeführt werden.</string>
|
|
||||||
<string name="combo_reservoir_level_insufficient_for_bolus">Nicht mehr genug Insulin im Reservoir für den Bolus</string>
|
<string name="combo_reservoir_level_insufficient_for_bolus">Nicht mehr genug Insulin im Reservoir für den Bolus</string>
|
||||||
<string name="yes">Ja</string>
|
<string name="yes">Ja</string>
|
||||||
<string name="no">Nein</string>
|
<string name="no">Nein</string>
|
||||||
|
@ -723,7 +715,6 @@
|
||||||
<string name="openapsama_link_to_preferncejson_doc_txt">Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast.</string>
|
<string name="openapsama_link_to_preferncejson_doc_txt">Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast.</string>
|
||||||
<string name="combo_actvity_reading_basal_profile">Basalratenprofil wird gelesen</string>
|
<string name="combo_actvity_reading_basal_profile">Basalratenprofil wird gelesen</string>
|
||||||
<string name="pump_basebasalrate">%.2f IE/h</string>
|
<string name="pump_basebasalrate">%.2f IE/h</string>
|
||||||
<string name="combo_read_full_history_info">Drücke den Button lange, um die gesamte Historie und das Basal-Profil der Pumpe auszulesen. Dies ist eigentlich unnötig, weil die Historie regelmäßig gelesen wird. Hilfreich kann dies jedoch sein, wenn Datum und Zeit grundlegend verändert wurden oder die Pumpe ausgetauscht wurde.</string>
|
|
||||||
<string name="combo_error_no_connection_no_bolus_delivered">Keine Verbindung zur Pumpe: Es wurde kein Bolus abgegeben.</string>
|
<string name="combo_error_no_connection_no_bolus_delivered">Keine Verbindung zur Pumpe: Es wurde kein Bolus abgegeben.</string>
|
||||||
<string name="extendedbolusdeliveryerror">Fehler bei der Abgabe eines verlängerten Bolus</string>
|
<string name="extendedbolusdeliveryerror">Fehler bei der Abgabe eines verlängerten Bolus</string>
|
||||||
<string name="combo_bolus_rejected_due_to_pump_history_change">Nach der Berechnung des Bolus hat sich die Pumpenhistorie geändert. Daher wurde kein Bolus abgegeben. Bitte prüfe, ob überhaupt noch ein Bolus benötigt wird. Wenn die gleiche Bolusmenge erforderlich ist, warte zwei Minuten ab, denn es werden aus Sicherheitsgründen keine gleich großen Boli abgegeben, wenn sie innerhalb von zwei Minuten angefordert wurden (unabhängig davon, ob sie verabreicht wurden oder nicht).</string>
|
<string name="combo_bolus_rejected_due_to_pump_history_change">Nach der Berechnung des Bolus hat sich die Pumpenhistorie geändert. Daher wurde kein Bolus abgegeben. Bitte prüfe, ob überhaupt noch ein Bolus benötigt wird. Wenn die gleiche Bolusmenge erforderlich ist, warte zwei Minuten ab, denn es werden aus Sicherheitsgründen keine gleich großen Boli abgegeben, wenn sie innerhalb von zwei Minuten angefordert wurden (unabhängig davon, ob sie verabreicht wurden oder nicht).</string>
|
||||||
|
|
|
@ -676,7 +676,6 @@
|
||||||
<string name="zerovalueinprofile" formatted="false">Perfil invalido: %s</string>
|
<string name="zerovalueinprofile" formatted="false">Perfil invalido: %s</string>
|
||||||
<string name="combo_programming_bolus">Programando bomba para emitir bolo</string>
|
<string name="combo_programming_bolus">Programando bomba para emitir bolo</string>
|
||||||
<string name="combo_refresh">Actualizar</string>
|
<string name="combo_refresh">Actualizar</string>
|
||||||
<string name="combo_tdds">TDDS</string>
|
|
||||||
<string name="combo_pump_state_label">Estado</string>
|
<string name="combo_pump_state_label">Estado</string>
|
||||||
<string name="combo_pump_activity_label">Actividad</string>
|
<string name="combo_pump_activity_label">Actividad</string>
|
||||||
<string name="combo_no_pump_connection" formatted="false">Ninguna coneccnion por %d min</string>
|
<string name="combo_no_pump_connection" formatted="false">Ninguna coneccnion por %d min</string>
|
||||||
|
@ -694,21 +693,14 @@
|
||||||
<string name="bolus_frequency_exceeded">Un bolo de mismo valor ha sido dado durante el pasado minuto. Para evitar bolos dobles y asegurarse contra bugs esto no es permitido.</string>
|
<string name="bolus_frequency_exceeded">Un bolo de mismo valor ha sido dado durante el pasado minuto. Para evitar bolos dobles y asegurarse contra bugs esto no es permitido.</string>
|
||||||
<string name="combo_pump_connected_now">Ahora</string>
|
<string name="combo_pump_connected_now">Ahora</string>
|
||||||
<string name="combo_activity_reading_pump_history">Leiendo historia bomba</string>
|
<string name="combo_activity_reading_pump_history">Leiendo historia bomba</string>
|
||||||
<string name="combo_pump_alerts">Alarmas</string>
|
|
||||||
<string name="combo_activity_setting_basal_profile">" Activando perfil base "</string>
|
<string name="combo_activity_setting_basal_profile">" Activando perfil base "</string>
|
||||||
<string name="combo_pump_cartridge_low_warrning">"Nivel del deposito bajo "</string>
|
<string name="combo_pump_cartridge_low_warrning">"Nivel del deposito bajo "</string>
|
||||||
<string name="combo_pump_battery_low_warrning">Bateria casi agotada</string>
|
<string name="combo_pump_battery_low_warrning">Bateria casi agotada</string>
|
||||||
<string name="combo_is_in_error_state" formatted="false">La bomba muesta el error E%d: %s</string>
|
<string name="combo_is_in_error_state" formatted="false">La bomba muesta el error E%d: %s</string>
|
||||||
<string name="combo_no_alert_data_note">Para leer historial de los errores, pincha unos segundo el boton \"ALARMAS\" ATENCION: esto puede causar un bug. La bomba no vuelve a conectarse - necesitas pulsar un boton en la misma bomba para reiniciarse. Deberias evitar esto.</string>
|
|
||||||
<string name="combo_no_tdd_data_note">Para leer el hisorial TDD de la bomba pulsa el boton TDDS unso segundos. ATENCION: esto puede causar un bug. La bomba no vuelve a conectarse - necesitas pulsar un boton en la misma bomba para reiniciarse. Deberias evitar esto.</string>
|
|
||||||
<string name="combo_tdd_minimum" formatted="false">Mínimo: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_average" formatted="false">Media: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_maximum" formatted="false">Máximo: %3.1f U</string>
|
|
||||||
<string name="combo_reservoir_low">Bajo</string>
|
<string name="combo_reservoir_low">Bajo</string>
|
||||||
<string name="combo_reservoir_empty">Vacio</string>
|
<string name="combo_reservoir_empty">Vacio</string>
|
||||||
<string name="combo_reservoir_normal">Normal</string>
|
<string name="combo_reservoir_normal">Normal</string>
|
||||||
<string name="combo_notification_check_time_date">Se necesita actualizar reloj de la bomba</string>
|
<string name="combo_notification_check_time_date">Se necesita actualizar reloj de la bomba</string>
|
||||||
<string name="combo_history">Historial</string>
|
|
||||||
<string name="combo_warning">Alerta</string>
|
<string name="combo_warning">Alerta</string>
|
||||||
<string name="combo_pump_tbr_cancelled_warrning">TBR cancelada, advertencia acceptada</string>
|
<string name="combo_pump_tbr_cancelled_warrning">TBR cancelada, advertencia acceptada</string>
|
||||||
<string name="combo_error_no_bolus_delivered">Emision del bolo fallado. Ningún bolo se ha emitido. Para asegurarse, por favor controle la bomba para evitar bolo doble. Para evitar bugs no se reinician bolos automaticamente.</string>
|
<string name="combo_error_no_bolus_delivered">Emision del bolo fallado. Ningún bolo se ha emitido. Para asegurarse, por favor controle la bomba para evitar bolo doble. Para evitar bugs no se reinician bolos automaticamente.</string>
|
||||||
|
|
|
@ -684,7 +684,6 @@
|
||||||
<string name="zerovalueinprofile">Profile incorrect: %s</string>
|
<string name="zerovalueinprofile">Profile incorrect: %s</string>
|
||||||
<string name="combo_programming_bolus">Programmer la pompe pour administrer un bolus</string>
|
<string name="combo_programming_bolus">Programmer la pompe pour administrer un bolus</string>
|
||||||
<string name="combo_refresh">Actualiser</string>
|
<string name="combo_refresh">Actualiser</string>
|
||||||
<string name="combo_tdds">TDDS</string>
|
|
||||||
<string name="combo_pump_state_label">État</string>
|
<string name="combo_pump_state_label">État</string>
|
||||||
<string name="combo_pump_activity_label">Activité</string>
|
<string name="combo_pump_activity_label">Activité</string>
|
||||||
<string name="combo_no_pump_connection" formatted="false">Pas de connexion depuis %d min</string>
|
<string name="combo_no_pump_connection" formatted="false">Pas de connexion depuis %d min</string>
|
||||||
|
@ -708,21 +707,14 @@
|
||||||
<string name="bolus_frequency_exceeded">Un bolus avec la même quantité d’insuline a été demandé au cours de la dernière minute. Pour prévenir l’administration accidentelle de deux bolus à la fois et pour protéger contre les bugs quand ceci (bolus) non autorisé</string>
|
<string name="bolus_frequency_exceeded">Un bolus avec la même quantité d’insuline a été demandé au cours de la dernière minute. Pour prévenir l’administration accidentelle de deux bolus à la fois et pour protéger contre les bugs quand ceci (bolus) non autorisé</string>
|
||||||
<string name="combo_pump_connected_now">Maintenant</string>
|
<string name="combo_pump_connected_now">Maintenant</string>
|
||||||
<string name="combo_activity_reading_pump_history">Lecture historique pompe</string>
|
<string name="combo_activity_reading_pump_history">Lecture historique pompe</string>
|
||||||
<string name="combo_pump_alerts">Alertes</string>
|
|
||||||
<string name="combo_activity_setting_basal_profile">Définir le profil basal</string>
|
<string name="combo_activity_setting_basal_profile">Définir le profil basal</string>
|
||||||
<string name="combo_pump_cartridge_low_warrning">Niveau cartouche pompe bas</string>
|
<string name="combo_pump_cartridge_low_warrning">Niveau cartouche pompe bas</string>
|
||||||
<string name="combo_pump_battery_low_warrning">Niveau batterie pompe bas</string>
|
<string name="combo_pump_battery_low_warrning">Niveau batterie pompe bas</string>
|
||||||
<string name="combo_is_in_error_state" formatted="false">La pompe affiche l’erreur E%d: %s</string>
|
<string name="combo_is_in_error_state" formatted="false">La pompe affiche l’erreur E%d: %s</string>
|
||||||
<string name="combo_no_alert_data_note">Pour lire l’historique des erreurs de pompe, Appuyez longuement sur le bouton ALERTES, WARNING : ceci peut provoquer un bug et ce dernier va ordonner la pompe à rejeter toutes les tentatives de connexion et qui va nécessiter d’appuyer un bouton sur la pompe pour restaurer et par conséquent le bug devrait être évité</string>
|
|
||||||
<string name="combo_no_tdd_data_note">Pour lire l’historique DTQ de la pompe, Appuyez longuement les boutons DTQS, WARNING : ceci peut provoquer un bug ce qui ordonne la pompe à rejeter toutes les tentatives de connexion et qui va nécessiter d’appuyer un bouton sur la pompe pour restaurer et par conséquent le bug devrait être évité</string>
|
|
||||||
<string name="combo_tdd_minimum" formatted="false">Minimum: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_average" formatted="false">Moyen: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_maximum" formatted="false">Maximum: %3.1f U</string>
|
|
||||||
<string name="combo_reservoir_low">Bas</string>
|
<string name="combo_reservoir_low">Bas</string>
|
||||||
<string name="combo_reservoir_empty">Vide</string>
|
<string name="combo_reservoir_empty">Vide</string>
|
||||||
<string name="combo_reservoir_normal">Normal</string>
|
<string name="combo_reservoir_normal">Normal</string>
|
||||||
<string name="combo_notification_check_time_date">Mise à jour nécessaire pour l\'heure de la pompe</string>
|
<string name="combo_notification_check_time_date">Mise à jour nécessaire pour l\'heure de la pompe</string>
|
||||||
<string name="combo_history">Historique</string>
|
|
||||||
<string name="combo_warning">Warning</string>
|
<string name="combo_warning">Warning</string>
|
||||||
<string name="combo_pump_tbr_cancelled_warrning">TBR ANNULÉ warning confirmé</string>
|
<string name="combo_pump_tbr_cancelled_warrning">TBR ANNULÉ warning confirmé</string>
|
||||||
<string name="combo_error_no_bolus_delivered">Administration bolus échouée. Il semble qu’aucun bolus n’a été administré. Pour être sûr, Veuillez vérifier la pompe pour éviter un double bolus ensuite re bolusez une nouvelle fois</string>
|
<string name="combo_error_no_bolus_delivered">Administration bolus échouée. Il semble qu’aucun bolus n’a été administré. Pour être sûr, Veuillez vérifier la pompe pour éviter un double bolus ensuite re bolusez une nouvelle fois</string>
|
||||||
|
|
|
@ -693,12 +693,9 @@
|
||||||
<string name="combo_notification_check_time_date">Pomp klok moet bijgesteld worden</string>
|
<string name="combo_notification_check_time_date">Pomp klok moet bijgesteld worden</string>
|
||||||
<string name="combo_reservoir_empty">Leeg</string>
|
<string name="combo_reservoir_empty">Leeg</string>
|
||||||
<string name="combo_reservoir_low">Bijna leeg</string>
|
<string name="combo_reservoir_low">Bijna leeg</string>
|
||||||
<string name="combo_tdd_maximum">Maximum: %3.1f E</string>
|
<string name="combo_reservoir_normal">Normaal</string>
|
||||||
<string name="combo_reservoir_normal">Normaal</string>
|
|
||||||
<string name="combo_pump_action_refreshing">Vernieuwen</string>
|
<string name="combo_pump_action_refreshing">Vernieuwen</string>
|
||||||
<string name="combo_history">Historiek</string>
|
<string name="combo_pump_battery_low_warrning">Batterij pomp is bijna leeg</string>
|
||||||
<string name="combo_pump_alerts">Storingen</string>
|
|
||||||
<string name="combo_pump_battery_low_warrning">Batterij pomp is bijna leeg</string>
|
|
||||||
<string name="combo_pump_unsupported_operation">Gevraagde is niet momeglijk met de pomp</string>
|
<string name="combo_pump_unsupported_operation">Gevraagde is niet momeglijk met de pomp</string>
|
||||||
<string name="combo_pump_connected_now">Zojuist</string>
|
<string name="combo_pump_connected_now">Zojuist</string>
|
||||||
<string name="combo_pump_tbr_cancelled_warrning">TB GEANNULEERD Waarschuwing is bevestigd</string>
|
<string name="combo_pump_tbr_cancelled_warrning">TB GEANNULEERD Waarschuwing is bevestigd</string>
|
||||||
|
@ -709,20 +706,15 @@
|
||||||
<string name="combo_pump_cartridge_low_warrning">Insuline ampul is bijna leeg</string>
|
<string name="combo_pump_cartridge_low_warrning">Insuline ampul is bijna leeg</string>
|
||||||
<string name="combo_is_in_error_state">Pomp is in storing, controleer op de pomp: E%d %s</string>
|
<string name="combo_is_in_error_state">Pomp is in storing, controleer op de pomp: E%d %s</string>
|
||||||
<string name="combo_pump_action_bolusing">Bolus (%.1f E)</string>
|
<string name="combo_pump_action_bolusing">Bolus (%.1f E)</string>
|
||||||
<string name="combo_tdd_minimum">Minimum: %3.1f E</string>
|
<string name="combo_activity_setting_basal_profile">Instellen van basaal profiel</string>
|
||||||
<string name="combo_tdd_average">Gemiddelde: %3.1f E</string>
|
|
||||||
<string name="combo_activity_setting_basal_profile">Instellen van basaal profiel</string>
|
|
||||||
<string name="combo_activity_reading_pump_history">Lezen van pomp historiek</string>
|
<string name="combo_activity_reading_pump_history">Lezen van pomp historiek</string>
|
||||||
<string name="combo_no_alert_data_note">Om de pomp fouthistoriek op te halen, druk lang op de Storingen knop.</string>
|
<string name="combo_error_partial_bolus_delivered">Maar %.2f E van de gevraagde %.2f E zijn toegediend door een storing. Gelieve op de pomp te controleren en het gepaste gevolg uit te voeren.</string>
|
||||||
<string name="combo_error_partial_bolus_delivered">Maar %.2f E van de gevraagde %.2f E zijn toegediend door een storing. Gelieve op de pomp te controleren en het gepaste gevolg uit te voeren.</string>
|
<string name="combo_error_bolus_verification_failed">Toedienen en controleren van de bolus in de pomp historiek is mislukt, controleer de pomp en creëer een manuele bolus in het Careportal tabblad</string>
|
||||||
<string name="combo_no_tdd_data_note">"Om de TTD van de pomp op te halen, lang duwen op de TDDS knop OPGELET: dit kan een bug veroorzaken waardoor de pomp alle verbindingen verbreekt en het vereist is op een knop op de pomp te duwen, dit wordt daarom afgeraden."</string>
|
|
||||||
<string name="combo_error_bolus_verification_failed">Toedienen en controleren van de bolus in de pomp historiek is mislukt, controleer de pomp en creëer een manuele bolus in het Careportal tabblad</string>
|
|
||||||
<string name="combo_error_no_bolus_delivered">Bolus toedienen mislukt. Waarschijnlijk is er geen bolus toegediend. Gelieve de pomp te controleren om een dubbele bolus te vermijden. Als bescherming tegen programmeerfouten worden bolussen niet automatisch opnieuw uitgevoerd.</string>
|
<string name="combo_error_no_bolus_delivered">Bolus toedienen mislukt. Waarschijnlijk is er geen bolus toegediend. Gelieve de pomp te controleren om een dubbele bolus te vermijden. Als bescherming tegen programmeerfouten worden bolussen niet automatisch opnieuw uitgevoerd.</string>
|
||||||
<string name="combo_pump_activity_label">Actie</string>
|
<string name="combo_pump_activity_label">Actie</string>
|
||||||
<string name="combo_pump_action_setting_tbr">Instellen TBR (%d%% / %d min)</string>
|
<string name="combo_pump_action_setting_tbr">Instellen TBR (%d%% / %d min)</string>
|
||||||
<string name="combo_force_disabled_notification">Onvoorzichtig gebruik: Vertraagde of multi wave bolussen zijn toegediend in de afgelopen 6 uur op het geselecteerde basaal patroon is niet 1. Loop is onderbroken tot de 6 uur nadat deze bolussen of andere basale patronen zijn gedetecteerd. Alleen normale bolussen en basaal patroon 1 zijn mogelijk binnen basaal patroon 1</string>
|
<string name="combo_force_disabled_notification">Onvoorzichtig gebruik: Vertraagde of multi wave bolussen zijn toegediend in de afgelopen 6 uur op het geselecteerde basaal patroon is niet 1. Loop is onderbroken tot de 6 uur nadat deze bolussen of andere basale patronen zijn gedetecteerd. Alleen normale bolussen en basaal patroon 1 zijn mogelijk binnen basaal patroon 1</string>
|
||||||
<string name="combo_tdds">TDDS</string>
|
<string name="combo_low_suspend_forced_notification">Opgelet: verlengde en multi wafe bolussen zijn actief. Loop is naar onderdruk lage waardes enkel overgeschakeld gedurende 6 uur. Alleen gewone bolussen worden onderdsteund in loop modus.</string>
|
||||||
<string name="combo_low_suspend_forced_notification">Opgelet: verlengde en multi wafe bolussen zijn actief. Loop is naar onderdruk lage waardes enkel overgeschakeld gedurende 6 uur. Alleen gewone bolussen worden onderdsteund in loop modus.</string>
|
|
||||||
<string name="combo_reservoir_level_insufficient_for_bolus">Niet genoeg insuline aanwezig in reservoir voor de bolus</string>
|
<string name="combo_reservoir_level_insufficient_for_bolus">Niet genoeg insuline aanwezig in reservoir voor de bolus</string>
|
||||||
<string name="careportal_combobolus">Combinatie-Bolus</string>
|
<string name="careportal_combobolus">Combinatie-Bolus</string>
|
||||||
<string name="pump_basebasalrate">%.2f E/u</string>
|
<string name="pump_basebasalrate">%.2f E/u</string>
|
||||||
|
@ -732,7 +724,6 @@
|
||||||
<string name="combo_actvity_reading_basal_profile">Basaal profiel wordt gelezen</string>
|
<string name="combo_actvity_reading_basal_profile">Basaal profiel wordt gelezen</string>
|
||||||
<string name="basalprofilenotaligned">Basale patroon niet geschikt op complete uren: %s</string>
|
<string name="basalprofilenotaligned">Basale patroon niet geschikt op complete uren: %s</string>
|
||||||
<string name="zerovalueinprofile">Ongeldig profiel: %s</string>
|
<string name="zerovalueinprofile">Ongeldig profiel: %s</string>
|
||||||
<string name="combo_read_full_history_info">Lang duwen op deze knop zal de volledige historiek en basaal profiel uit de pomp ophalen. Dit is normaal gezien niet nodig, daar de pomp historiek permanent wordt gelezen, maar kan nuttig zijn wanneer de pomp dat en tijd grote afwijkingen hadden of de pomp vervangen is.</string>
|
|
||||||
<string name="combo_error_no_connection_no_bolus_delivered">Er kon geen verbinding met de pomp gemaakt worden. De Bolus is niet toegediend.</string>
|
<string name="combo_error_no_connection_no_bolus_delivered">Er kon geen verbinding met de pomp gemaakt worden. De Bolus is niet toegediend.</string>
|
||||||
<string name="extendedbolusdeliveryerror">Vertraagde bolus toedien storing</string>
|
<string name="extendedbolusdeliveryerror">Vertraagde bolus toedien storing</string>
|
||||||
<string name="combo_bolus_rejected_due_to_pump_history_change">De pomp historiek is gewijzigd nadat de bolus berend was. De bolus is NIET toegediend. Programmeer een nieuwe bolus indien nodig. Als dezelfde bolus hoeveelheid moet worden toegediend, gelieve 2 minuten te wachten. Gelijke bolussen worden geweigerd om veiligheidsredenen (toegediend of niet).</string>
|
<string name="combo_bolus_rejected_due_to_pump_history_change">De pomp historiek is gewijzigd nadat de bolus berend was. De bolus is NIET toegediend. Programmeer een nieuwe bolus indien nodig. Als dezelfde bolus hoeveelheid moet worden toegediend, gelieve 2 minuten te wachten. Gelijke bolussen worden geweigerd om veiligheidsredenen (toegediend of niet).</string>
|
||||||
|
|
|
@ -780,7 +780,6 @@
|
||||||
<string name="zerovalueinprofile" formatted="false">Invalid profile: %s</string>
|
<string name="zerovalueinprofile" formatted="false">Invalid profile: %s</string>
|
||||||
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
<string name="combo_programming_bolus">Programming pump for bolusing</string>
|
||||||
<string name="combo_refresh">Refresh</string>
|
<string name="combo_refresh">Refresh</string>
|
||||||
<string name="combo_tdds">TDDS</string>
|
|
||||||
<string name="combo_pump_state_label">State</string>
|
<string name="combo_pump_state_label">State</string>
|
||||||
<string name="combo_pump_activity_label">Activity</string>
|
<string name="combo_pump_activity_label">Activity</string>
|
||||||
<string name="combo_no_pump_connection">No connection for %d min</string>
|
<string name="combo_no_pump_connection">No connection for %d min</string>
|
||||||
|
@ -801,23 +800,15 @@
|
||||||
<string name="combo_pump_connected_now">Now</string>
|
<string name="combo_pump_connected_now">Now</string>
|
||||||
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
||||||
<string name="danar_history">pump history</string>
|
<string name="danar_history">pump history</string>
|
||||||
<string name="combo_pump_alerts">Alerts</string>
|
|
||||||
<string name="combo_activity_setting_basal_profile">Setting basal profile</string>
|
<string name="combo_activity_setting_basal_profile">Setting basal profile</string>
|
||||||
<string name="combo_pump_cartridge_low_warrning">Pump cartridge level is low</string>
|
<string name="combo_pump_cartridge_low_warrning">Pump cartridge level is low</string>
|
||||||
<string name="combo_pump_battery_low_warrning">Pump battery is low</string>
|
<string name="combo_pump_battery_low_warrning">Pump battery is low</string>
|
||||||
<string name="combo_is_in_error_state">The pump is showing the error E%d: %s</string>
|
<string name="combo_is_in_error_state">The pump is showing the error E%d: %s</string>
|
||||||
<string name="combo_no_alert_data_note">To read the pump\'s error history, long press this button</string>
|
|
||||||
<string name="combo_no_tdd_data_note">To read the pump\'s TDD history, long press this button</string>
|
|
||||||
<string name="combo_tdd_minimum">Minimum: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_average">Average: %3.1f U</string>
|
|
||||||
<string name="combo_tdd_maximum">Maximum: %3.1f U</string>
|
|
||||||
<string name="combo_reservoir_low">Low</string>
|
<string name="combo_reservoir_low">Low</string>
|
||||||
<string name="combo_reservoir_empty">Empty</string>
|
<string name="combo_reservoir_empty">Empty</string>
|
||||||
<string name="combo_reservoir_normal">Normal</string>
|
<string name="combo_reservoir_normal">Normal</string>
|
||||||
<string name="combo_notification_check_time_date">Pump clock update needed</string>
|
<string name="combo_notification_check_time_date">Pump clock update needed</string>
|
||||||
<string name="combo_history">History</string>
|
|
||||||
<string name="combo_warning">Warning</string>
|
<string name="combo_warning">Warning</string>
|
||||||
<string name="combo_read_full_history_info">Long press this button to force a full read of history and basal profile from the pump. This is generally not needed, since the pump\'s history is read continuously, but can be useful if the pump\'s date and time changed significantly or the pump was replaced.</string>
|
|
||||||
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string>
|
<string name="combo_pump_tbr_cancelled_warrning">TBR CANCELLED warning was confirmed</string>
|
||||||
<string name="combo_error_no_connection_no_bolus_delivered">The pump could not be reached. No bolus was given</string>
|
<string name="combo_error_no_connection_no_bolus_delivered">The pump could not be reached. No bolus was given</string>
|
||||||
<string name="combo_error_no_bolus_delivered">Bolus delivery failed. It appears no bolus was delivered. To be sure, please check the pump to avoid a double bolus and then bolus again. To guard against bugs, boluses are not automatically retried.</string>
|
<string name="combo_error_no_bolus_delivered">Bolus delivery failed. It appears no bolus was delivered. To be sure, please check the pump to avoid a double bolus and then bolus again. To guard against bugs, boluses are not automatically retried.</string>
|
||||||
|
@ -997,5 +988,6 @@
|
||||||
<string name="food_short">Food</string>
|
<string name="food_short">Food</string>
|
||||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||||
<string name="reset">reset</string>
|
<string name="reset">reset</string>
|
||||||
|
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
|
||||||
|
<string name="loopdisconnectedfor">Disconnected (%d m)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
|
@ -122,11 +123,17 @@ public class AAPSMocker {
|
||||||
when(MainApp.getDbHelper()).thenReturn(databaseHelper);
|
when(MainApp.getDbHelper()).thenReturn(databaseHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void mockCommandQueue() {
|
||||||
|
CommandQueue queue = mock(CommandQueue.class);
|
||||||
|
when(ConfigBuilderPlugin.getCommandQueue()).thenReturn(queue);
|
||||||
|
}
|
||||||
|
|
||||||
public static Profile getValidProfile() {
|
public static Profile getValidProfile() {
|
||||||
try {
|
try {
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
profile = new Profile(new JSONObject(validProfile), Constants.MGDL);
|
profile = new Profile(new JSONObject(validProfile), Constants.MGDL);
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {
|
||||||
|
}
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,7 @@ public class ConstraintsCheckerTest {
|
||||||
AAPSMocker.mockBus();
|
AAPSMocker.mockBus();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
// RS constructor
|
// RS constructor
|
||||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||||
|
|
|
@ -230,6 +230,7 @@ public class SafetyPluginTest {
|
||||||
AAPSMocker.mockConstraintsChecker();
|
AAPSMocker.mockConstraintsChecker();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
AAPSMocker.mockBus();
|
||||||
|
|
||||||
|
|
||||||
when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump);
|
when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
|
@ -15,12 +15,13 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class})
|
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class, CommandQueue.class})
|
||||||
public class ComboPluginTest {
|
public class ComboPluginTest {
|
||||||
|
|
||||||
ComboPlugin comboPlugin;
|
ComboPlugin comboPlugin;
|
||||||
|
@ -63,6 +64,7 @@ public class ComboPluginTest {
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
AAPSMocker.mockBus();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
comboPlugin = ComboPlugin.getPlugin();
|
comboPlugin = ComboPlugin.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class DanaRPluginTest {
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class DanaRSPluginTest {
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class InsightPluginTest {
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
AAPSMocker.mockBus();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
insightPlugin = InsightPlugin.getPlugin();
|
insightPlugin = InsightPlugin.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.MainApp;
|
||||||
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.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
||||||
|
|
|
@ -18,8 +18,8 @@ buildscript {
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url "https://maven.google.com"
|
url "https://maven.google.com"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
supportLibraryVersion = "23.0.1"
|
|
||||||
wearableVersion = "2.0.1"
|
wearableVersion = "2.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +26,12 @@ def generateGitBuild = { ->
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 27
|
||||||
buildToolsVersion "27.0.3"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.androidaps"
|
||||||
minSdkVersion 20
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 25
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0.2"
|
versionName "1.0.2"
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
|
|
Loading…
Reference in a new issue