commit
3be191df4c
13
.travis.yml
13
.travis.yml
|
@ -1,24 +1,25 @@
|
||||||
language: android
|
language: android
|
||||||
jdk: oraclejdk8
|
jdk: oraclejdk8
|
||||||
|
dist: trusty
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- ANDROID_TARGET=android-23 ANDROID_ABI=x86 org.gradle.jvmargs=-XX:-OmitStackTraceInFastThrow
|
- ANDROID_TARGET=android-28 ANDROID_ABI=x86 org.gradle.jvmargs=-XX:-OmitStackTraceInFastThrow
|
||||||
android:
|
android:
|
||||||
components:
|
components:
|
||||||
- platform-tools
|
- platform-tools
|
||||||
- tools
|
- tools
|
||||||
- build-tools-27.0.2
|
- build-tools-28.0.3
|
||||||
- android-23
|
- android-28
|
||||||
- extra-google-m2repository
|
- extra-google-m2repository
|
||||||
- extra-android-m2repository
|
- extra-android-m2repository
|
||||||
- extra-google-google_play_services
|
- extra-google-google_play_services
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- yes | sdkmanager "platforms;android-27"
|
#- yes | sdkmanager "platforms;android-28"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Unit Test
|
# Unit Test
|
||||||
- ./gradlew -Pcoverage testFullDebugUnitTest jacocoTestFullDebugUnitTestReport
|
- ./gradlew -Pcoverage -PfirebaseDisable testFullDebugUnitTest jacocoTestFullDebugUnitTestReport
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
@ -31,4 +32,4 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.gradle/caches/
|
- $HOME/.gradle/caches/
|
||||||
- $HOME/.gradle/wrapper/
|
- $HOME/.gradle/wrapper/
|
||||||
- $HOME/.android/build-cache
|
- $HOME/.android/build-cache
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
dev: [![codecov](https://codecov.io/gh/MilosKozak/AndroidAPS/branch/dev/graph/badge.svg)](https://codecov.io/gh/MilosKozak/AndroidAPS)
|
dev: [![codecov](https://codecov.io/gh/MilosKozak/AndroidAPS/branch/dev/graph/badge.svg)](https://codecov.io/gh/MilosKozak/AndroidAPS)
|
||||||
|
|
||||||
|
|
||||||
[![Donate via PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y4LHGJJESAVB8)
|
[![Donate via PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y4LHGJJESAVB8)
|
216
app/build.gradle
216
app/build.gradle
|
@ -6,30 +6,39 @@ buildscript {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'io.fabric.tools:gradle:1.+'
|
classpath 'io.fabric.tools:gradle:1.+'
|
||||||
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
|
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
|
||||||
|
classpath 'de.undercouch:gradle-download-task:3.4.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: "com.android.application"
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: "io.fabric"
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: "jacoco-android"
|
apply plugin: 'kotlin-android-extensions'
|
||||||
apply plugin: 'com.jakewharton.butterknife'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
apply plugin: 'io.fabric'
|
||||||
|
apply plugin: 'jacoco-android'
|
||||||
|
apply plugin: 'de.undercouch.download'
|
||||||
|
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.3"
|
||||||
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
supportLibraryVersion = "27.1.0"
|
supportLibraryVersion = "28.0.0"
|
||||||
ormLiteVersion = "4.46"
|
ormLiteVersion = "4.46"
|
||||||
powermockVersion = "1.7.3"
|
powermockVersion = "1.7.3"
|
||||||
dexmakerVersion = "1.2"
|
dexmakerVersion = "1.2"
|
||||||
butterknifeVersion = "8.8.1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
jcenter { url "https://jcenter.bintray.com/" }
|
jcenter { url "https://jcenter.bintray.com/" }
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
def generateGitBuild = { ->
|
def generateGitBuild = { ->
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder()
|
||||||
try {
|
try {
|
||||||
def stdout = new ByteArrayOutputStream()
|
def stdout = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
|
@ -44,40 +53,82 @@ def generateGitBuild = { ->
|
||||||
return stringBuilder.toString()
|
return stringBuilder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def generateGitRemote = { ->
|
||||||
|
StringBuilder stringBuilder = new StringBuilder()
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'remote', 'get-url', 'origin'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
String commitObject = stdout.toString().trim()
|
||||||
|
stringBuilder.append(commitObject)
|
||||||
|
} catch (ignored) {
|
||||||
|
stringBuilder.append('NoGitSystemAvailable')
|
||||||
|
}
|
||||||
|
return stringBuilder.toString()
|
||||||
|
}
|
||||||
|
|
||||||
def generateDate = { ->
|
def generateDate = { ->
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder()
|
||||||
stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm'))
|
stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm'))
|
||||||
return stringBuilder.toString()
|
return stringBuilder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def isMaster = { ->
|
||||||
|
return !version.contains('-')
|
||||||
|
}
|
||||||
|
|
||||||
|
def allCommited = { ->
|
||||||
|
StringBuilder stringBuilder = new StringBuilder()
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'status', '-s'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
String commitObject = stdout.toString().trim()
|
||||||
|
stringBuilder.append(commitObject)
|
||||||
|
} catch (ignored) {
|
||||||
|
return false // NoGitSystemAvailable
|
||||||
|
}
|
||||||
|
return stringBuilder.toString().isEmpty()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
tasks.matching { it instanceof Test }.all {
|
tasks.matching { it instanceof Test }.all {
|
||||||
testLogging.events = ["failed", "skipped", "started"]
|
testLogging.events = ["failed", "skipped", "started"]
|
||||||
testLogging.exceptionFormat = "full"
|
testLogging.exceptionFormat = "full"
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 28
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21
|
minSdkVersion 23
|
||||||
targetSdkVersion 25
|
targetSdkVersion 28
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
version "2.0"
|
version "2.6-dev"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
|
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
moduleName "BleCommandUtil"
|
moduleName "BleCommandUtil"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
// 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
|
||||||
|
@ -90,7 +141,10 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
testCoverageEnabled(project.hasProperty('coverage') ? true : false)
|
testCoverageEnabled(project.hasProperty('coverage'))
|
||||||
|
}
|
||||||
|
firebaseDisable {
|
||||||
|
System.setProperty("disableFirebase", "true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
@ -101,17 +155,17 @@ android {
|
||||||
resValue "string", "app_name", "AndroidAPS"
|
resValue "string", "app_name", "AndroidAPS"
|
||||||
versionName version
|
versionName version
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
appIcon: "@mipmap/ic_launcher",
|
appIcon : "@mipmap/ic_launcher",
|
||||||
appIconRound: "@mipmap/ic_launcher_round"
|
appIconRound: "@mipmap/ic_launcher_round"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
pumpcontrol {
|
pumpcontrol {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.aapspumpcontrol"
|
||||||
dimension "standard"
|
dimension "standard"
|
||||||
resValue "string", "app_name", "AndroidAPS"
|
resValue "string", "app_name", "Pumpcontrol"
|
||||||
versionName version
|
versionName version + "-pumpcontrol"
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
appIcon: "@mipmap/blueowl",
|
appIcon : "@mipmap/ic_pumpcontrol",
|
||||||
appIconRound: "@null"
|
appIconRound: "@null"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -121,7 +175,7 @@ android {
|
||||||
resValue "string", "app_name", "NSClient"
|
resValue "string", "app_name", "NSClient"
|
||||||
versionName version + "-nsclient"
|
versionName version + "-nsclient"
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
appIcon: "@mipmap/yellowowl",
|
appIcon : "@mipmap/ic_yellowowl",
|
||||||
appIconRound: "@null"
|
appIconRound: "@null"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -131,7 +185,7 @@ android {
|
||||||
resValue "string", "app_name", "NSClient2"
|
resValue "string", "app_name", "NSClient2"
|
||||||
versionName version + "-nsclient"
|
versionName version + "-nsclient"
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
appIcon: "@mipmap/yellowowl",
|
appIcon : "@mipmap/ic_yellowowl",
|
||||||
appIconRound: "@null"
|
appIconRound: "@null"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -142,11 +196,18 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.returnDefaultValues = true
|
unitTests {
|
||||||
unitTests.includeAndroidResources = true
|
returnDefaultValues = true
|
||||||
|
includeAndroidResources = true
|
||||||
|
|
||||||
|
all {
|
||||||
|
maxParallelForks = 10
|
||||||
|
forkEvery = 20
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useLibrary "org.apache.http.legacy"
|
useLibrary "org.apache.http.legacy"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
@ -155,48 +216,45 @@ allprojects {
|
||||||
flatDir {
|
flatDir {
|
||||||
dirs 'libs'
|
dirs 'libs'
|
||||||
}
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
|
||||||
libs
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
wearApp project(':wear')
|
wearApp project(':wear')
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation("com.crashlytics.sdk.android:crashlytics:2.6.7@aar") {
|
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
|
||||||
|
implementation 'com.google.firebase:firebase-core:17.2.0'
|
||||||
|
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
|
||||||
transitive = true;
|
transitive = true;
|
||||||
}
|
}
|
||||||
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") {
|
|
||||||
transitive = true;
|
|
||||||
}
|
|
||||||
libs "MilosKozak:danars-support-lib:master@zip"
|
|
||||||
|
|
||||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation "com.android.support:support-v13:${supportLibraryVersion}"
|
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
||||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
|
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||||
implementation "com.android.support:gridlayout-v7:${supportLibraryVersion}"
|
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||||
implementation "com.android.support:design:${supportLibraryVersion}"
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
implementation "com.android.support:percent:${supportLibraryVersion}"
|
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
||||||
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
|
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
|
||||||
implementation "com.squareup:otto:1.3.7"
|
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
||||||
|
|
||||||
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
||||||
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
|
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
|
||||||
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
|
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
|
||||||
exclude group: "com.google.android", module: "android"
|
exclude group: "com.google.android", module: "android"
|
||||||
}
|
}
|
||||||
implementation "org.apache.commons:commons-lang3:3.6"
|
implementation "org.apache.commons:commons-lang3:3.7"
|
||||||
implementation "org.slf4j:slf4j-api:1.7.12"
|
implementation "org.slf4j:slf4j-api:1.7.21"
|
||||||
|
// Graphview cannot be upgraded
|
||||||
implementation "com.jjoe64:graphview:4.0.1"
|
implementation "com.jjoe64:graphview:4.0.1"
|
||||||
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
|
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
|
||||||
implementation "com.google.android.gms:play-services-wearable:7.5.0"
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
|
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
|
||||||
implementation(name: "sightparser-release", ext: "aar")
|
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||||
|
|
||||||
implementation("com.google.android:flexbox:0.3.0") {
|
implementation("com.google.android:flexbox:0.3.0") {
|
||||||
exclude group: "com.android.support"
|
exclude group: "com.android.support"
|
||||||
|
@ -205,44 +263,65 @@ dependencies {
|
||||||
// excluding org.json which is provided by Android
|
// excluding org.json which is provided by Android
|
||||||
exclude group: "org.json", module: "json"
|
exclude group: "org.json", module: "json"
|
||||||
}
|
}
|
||||||
implementation "com.google.code.gson:gson:2.7"
|
implementation "com.google.code.gson:gson:2.8.5"
|
||||||
implementation "com.google.guava:guava:20.0"
|
implementation "com.google.guava:guava:24.1-jre"
|
||||||
|
|
||||||
implementation "net.danlew:android.joda:2.9.9.1"
|
implementation "net.danlew:android.joda:2.9.9.1"
|
||||||
implementation "uk.com.robust-it:cloning:1.9.9"
|
implementation "uk.com.robust-it:cloning:1.9.9"
|
||||||
|
|
||||||
implementation 'org.mozilla:rhino:1.7.7.2'
|
implementation 'org.mozilla:rhino:1.7.7.2'
|
||||||
|
|
||||||
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
|
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
|
||||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
|
|
||||||
|
|
||||||
testImplementation "junit:junit:4.12"
|
testImplementation "junit:junit:4.12"
|
||||||
testImplementation "org.json:json:20140107"
|
testImplementation "org.json:json:20140107"
|
||||||
testImplementation "org.mockito:mockito-core:2.7.22"
|
testImplementation "org.mockito:mockito-core:2.8.47"
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
testImplementation "joda-time:joda-time:2.9.4.2"
|
testImplementation "joda-time:joda-time:2.9.9"
|
||||||
testImplementation "com.google.truth:truth:0.39"
|
testImplementation("com.google.truth:truth:0.39") {
|
||||||
testImplementation 'org.robolectric:robolectric:3.8'
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
||||||
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
||||||
|
/*
|
||||||
|
testImplementation("uk.org.lidalia:slf4j-test:1.2.0") {
|
||||||
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
androidTestImplementation "org.mockito:mockito-core:2.7.22"
|
androidTestImplementation "org.mockito:mockito-core:2.8.47"
|
||||||
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
||||||
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
|
androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
|
|
||||||
|
|
||||||
|
// new for tidepool
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||||
|
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
|
||||||
|
implementation "com.squareup.retrofit2:retrofit:2.4.0"
|
||||||
|
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
|
||||||
|
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task unzip(type: Copy) {
|
|
||||||
def zipPath = configurations.libs.find { it.name.startsWith("danars") }
|
|
||||||
def zipFile = file(zipPath)
|
|
||||||
def outputDir = file("${buildDir}/unpacked/dist")
|
|
||||||
|
|
||||||
from zipTree(zipFile)
|
task downloadZipFile(type: Download) {
|
||||||
|
src 'https://github.com/MilosKozak/danars-support-lib/archive/master.zip'
|
||||||
|
dest new File(buildDir, 'danars.zip')
|
||||||
|
}
|
||||||
|
|
||||||
|
task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
|
||||||
|
from zipTree(downloadZipFile.dest)
|
||||||
|
def outputDir = file("${buildDir}/unpacked/dist")
|
||||||
into outputDir
|
into outputDir
|
||||||
}
|
}
|
||||||
|
|
||||||
task copyLibs(dependsOn: unzip, type: Copy) {
|
|
||||||
|
task copyLibs(dependsOn: downloadAndUnzipFile, type: Copy) {
|
||||||
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
|
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
|
||||||
def target = file("src/main/jniLibs/")
|
def target = file("src/main/jniLibs/")
|
||||||
|
|
||||||
|
@ -256,3 +335,12 @@ task full_clean(type: Delete) {
|
||||||
|
|
||||||
clean.dependsOn full_clean
|
clean.dependsOn full_clean
|
||||||
preBuild.dependsOn copyLibs
|
preBuild.dependsOn copyLibs
|
||||||
|
|
||||||
|
printf('--------------\n')
|
||||||
|
printf('isMaster: %s\n', isMaster().toString())
|
||||||
|
printf('allCommited: %s\n', allCommited().toString())
|
||||||
|
printf('--------------\n')
|
||||||
|
if (isMaster() && !allCommited()) {
|
||||||
|
throw new GradleException('There are uncommitted changes or git system is not available. Clone sources again as described in wiki and do not allow gradle update')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
107
app/google-services.json
Normal file
107
app/google-services.json
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "477603612366",
|
||||||
|
"firebase_url": "https://androidaps-c34f8.firebaseio.com",
|
||||||
|
"project_id": "androidaps-c34f8",
|
||||||
|
"storage_bucket": "androidaps-c34f8.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:477603612366:android:aef229914e3e5448",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "info.nightscout.aapspumpcontrol"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyDcZpDRMaGjdhihXp531cVYM6LkEL8KbgM"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "477603612366-a925drvlvs7qn7gt73r585erbqto8c79.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:477603612366:android:efc956f55b281623",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "info.nightscout.androidaps"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyDcZpDRMaGjdhihXp531cVYM6LkEL8KbgM"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "477603612366-a925drvlvs7qn7gt73r585erbqto8c79.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:477603612366:android:b38d6e7351f73cc0",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "info.nightscout.nsclient"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyDcZpDRMaGjdhihXp531cVYM6LkEL8KbgM"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "477603612366-a925drvlvs7qn7gt73r585erbqto8c79.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:477603612366:android:2dc8cf3acd3332e7",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "info.nightscout.nsclient2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyDcZpDRMaGjdhihXp531cVYM6LkEL8KbgM"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "477603612366-a925drvlvs7qn7gt73r585erbqto8c79.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
Binary file not shown.
|
@ -17,10 +17,12 @@
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
|
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<uses-permission android:name="sugar.free.sightremote.HISTORY_BROADCASTS" />
|
<uses-permission android:name="com.dexcom.cgm.EXTERNAL_PERMISSION" />
|
||||||
|
|
||||||
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
|
@ -31,73 +33,88 @@
|
||||||
android:name=".MainApp"
|
android:name=".MainApp"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="${appIcon}"
|
android:icon="${appIcon}"
|
||||||
android:roundIcon="${appIconRound}"
|
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="${appIconRound}"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.Launcher"
|
||||||
|
android:fullBackupContent="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.car.application"
|
android:name="com.google.android.gms.car.application"
|
||||||
android:resource="@xml/automotive_app_desc" />
|
android:resource="@xml/automotive_app_desc" />
|
||||||
|
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activities.PreferencesActivity" />
|
<activity android:name=".activities.PreferencesActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.Overview.Dialogs.BolusProgressHelperActivity"
|
android:name=".plugins.general.overview.dialogs.BolusProgressHelperActivity"
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
android:theme="@style/Theme.AppCompat.Translucent" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".plugins.Overview.Dialogs.ErrorHelperActivity"
|
android:name=".plugins.general.overview.dialogs.ErrorHelperActivity"
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
android:theme="@style/Theme.AppCompat.Translucent" />
|
||||||
<activity android:name=".activities.AgreementActivity" />
|
<activity android:name=".activities.AgreementActivity" />
|
||||||
<activity android:name=".plugins.PumpDanaR.activities.DanaRHistoryActivity" />
|
<activity android:name=".plugins.pump.danaR.activities.DanaRHistoryActivity" />
|
||||||
<activity android:name=".plugins.PumpDanaR.activities.DanaRUserOptionsActivity" />
|
<activity android:name=".plugins.pump.danaR.activities.DanaRUserOptionsActivity" />
|
||||||
<activity android:name=".activities.TDDStatsActivity" />
|
<activity android:name=".activities.TDDStatsActivity" />
|
||||||
<activity android:name=".plugins.Overview.activities.QuickWizardListActivity">
|
<activity android:name=".plugins.general.overview.activities.QuickWizardListActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".plugins.PumpDanaRS.activities.BLEScanActivity">
|
<activity android:name=".plugins.pump.danaRS.activities.BLEScanActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.PumpDanaRS.activities.BLEScanActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.PumpDanaRS.activities.BLEScanActivity" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".plugins.PumpDanaRS.activities.PairingHelperActivity" />
|
<activity android:name=".plugins.pump.danaRS.activities.PairingHelperActivity" />
|
||||||
<activity android:name=".activities.HistoryBrowseActivity" />
|
<activity android:name=".activities.HistoryBrowseActivity" />
|
||||||
|
|
||||||
|
<!-- Receive new BG readings from other local apps -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.DataReceiver"
|
android:name=".receivers.DataReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<!-- Receive new SMS messages -->
|
|
||||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
|
||||||
<!-- Receiver from xDrip -->
|
<!-- Receiver from xDrip -->
|
||||||
<action android:name="com.eveningoutpost.dexdrip.BgEstimate" />
|
<action android:name="com.eveningoutpost.dexdrip.BgEstimate"/>
|
||||||
<!-- Receiver from 640g uploader -->
|
<!-- Receiver from 640g uploader -->
|
||||||
<action android:name="com.eveningoutpost.dexdrip.NS_EMULATOR" />
|
<action android:name="com.eveningoutpost.dexdrip.NS_EMULATOR"/>
|
||||||
<!-- Receiver from glimp -->
|
<!-- Receiver from glimp -->
|
||||||
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
|
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED"/>
|
||||||
<!-- Receiver from DexcomG5 -->
|
<!-- Receiver from Dexcom -->
|
||||||
<action android:name="com.dexcom.cgm.DATA" />
|
<action android:name="com.dexcom.cgm.EXTERNAL_BROADCAST"/>
|
||||||
<!-- Receiver from Poctech -->
|
<!-- Receiver from Poctech -->
|
||||||
<action android:name="com.china.poctech.data" />
|
<action android:name="com.china.poctech.data"/>
|
||||||
|
<!-- Receiver from Tomato -->
|
||||||
|
<action android:name="com.fanqies.tomatofn.BgEstimate"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<!-- Receive new SMS messages -->
|
||||||
|
<receiver
|
||||||
|
android:name=".receivers.SmsReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:permission="android.permission.BROADCAST_SMS">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
<!-- Receiver keepalive, scheduled every 30 min -->
|
||||||
<receiver android:name=".receivers.KeepAliveReceiver" />
|
<receiver android:name=".receivers.KeepAliveReceiver" />
|
||||||
|
|
||||||
<!-- Auto start -->
|
<!-- Auto start -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".plugins.NSClientInternal.receivers.AutoStartReceiver"
|
android:name=".plugins.general.nsclient.receivers.AutoStartReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -106,16 +123,8 @@
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<!-- NSClient -->
|
<!-- NSClient -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".plugins.NSClientInternal.receivers.RestartReceiver"
|
android:name=".plugins.general.nsclient.receivers.DBAccessReceiver"
|
||||||
android:enabled="true"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="info.nightscout.client.RESTART" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
<receiver
|
|
||||||
android:name=".plugins.NSClientInternal.receivers.DBAccessReceiver"
|
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -132,7 +141,7 @@
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="android.support.v4.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
|
@ -146,30 +155,89 @@
|
||||||
android:name=".services.DataService"
|
android:name=".services.DataService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.PumpDanaR.services.DanaRExecutionService"
|
android:name=".services.LocationService"
|
||||||
|
android:exported="false" />
|
||||||
|
<service
|
||||||
|
android:name=".plugins.pump.danaR.services.DanaRExecutionService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService"
|
android:name=".plugins.pump.danaRKorean.services.DanaRKoreanExecutionService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.PumpDanaRv2.services.DanaRv2ExecutionService"
|
android:name=".plugins.pump.danaRv2.services.DanaRv2ExecutionService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.PumpDanaRS.services.DanaRSService"
|
android:name=".plugins.pump.danaRS.services.DanaRSService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.Wear.wearintegration.WatchUpdaterService"
|
android:name=".plugins.general.wear.wearintegration.WatchUpdaterService"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
|
<!-- <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> -->
|
||||||
|
<!-- listeners receive events that match the action and data filters -->
|
||||||
|
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
|
||||||
|
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_data"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_data_resend"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_cancel_bolus"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_confirmactionstring"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_initiateactionstring"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/openwearsettings"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/sendstatustowear"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/sendpreferencestowear"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_basal"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_bolusprogress"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_actionconfirmationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_changeconfirmationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
|
<data
|
||||||
|
android:host="*"
|
||||||
|
android:pathPrefix="/nightscout_watch_cancelnotificationrequest"
|
||||||
|
android:scheme="wear" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.NSClientInternal.services.NSClientService"
|
android:name=".plugins.general.nsclient.services.NSClientService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
<service
|
<service
|
||||||
|
@ -177,10 +245,12 @@
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.Overview.notifications.DismissNotificationService"
|
android:name=".plugins.general.overview.notifications.DismissNotificationService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<service android:name=".plugins.Persistentnotification.DummyService" />
|
<service android:name=".plugins.general.persistentNotification.DummyService" />
|
||||||
|
<service android:name=".plugins.pump.insight.connection_service.InsightConnectionService" />
|
||||||
|
<service android:name=".plugins.pump.insight.InsightAlertService" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="io.fabric.ApiKey"
|
android:name="io.fabric.ApiKey"
|
||||||
|
@ -189,12 +259,46 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".setupwizard.SetupWizardActivity"
|
android:name=".setupwizard.SetupWizardActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:label="@string/title_activity_setup_wizard"
|
||||||
android:label="@string/title_activity_setup_wizard" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
|
|
||||||
<activity android:name=".activities.SingleFragmentActivity"
|
<activity
|
||||||
|
android:name=".activities.SingleFragmentActivity"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity android:name=".plugins.Maintenance.activities.LogSettingActivity"></activity>
|
<activity android:name=".plugins.general.maintenance.activities.LogSettingActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".plugins.pump.insight.activities.InsightPairingActivity"
|
||||||
|
android:label="@string/insight_pairing"
|
||||||
|
android:theme="@style/AppTheme" />
|
||||||
|
<activity
|
||||||
|
android:name=".plugins.pump.insight.activities.InsightAlertActivity"
|
||||||
|
android:label="@string/pump_alert"
|
||||||
|
android:theme="@style/InsightAlertDialog" />
|
||||||
|
<activity
|
||||||
|
android:name=".plugins.pump.insight.activities.InsightPairingInformationActivity"
|
||||||
|
android:label="@string/pairing_information"
|
||||||
|
android:theme="@style/AppTheme" />
|
||||||
|
<activity android:name=".activities.RequestDexcomPermissionActivity" />
|
||||||
|
|
||||||
|
<!-- Medtronic service and activities -->
|
||||||
|
<service
|
||||||
|
android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true" />
|
||||||
|
<activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"
|
||||||
|
android:label="@string/title_activity_rileylink_settings"
|
||||||
|
android:theme="@style/Theme.AppCompat.NoTitle" />
|
||||||
|
<activity android:name=".plugins.pump.medtronic.dialog.MedtronicHistoryActivity" />
|
||||||
|
|
||||||
|
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -1,12 +1,33 @@
|
||||||
var console = { };
|
var console = { };
|
||||||
console.error = function error(){
|
console.error = function error(){
|
||||||
|
var s = '';
|
||||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||||
console2.log(arguments[i]);
|
if (i > 0) s = s + ' ';
|
||||||
|
if (typeof arguments[i] === 'undefined') {
|
||||||
|
s = s + 'undefined';
|
||||||
|
} else if (typeof arguments[i] === 'object') {
|
||||||
|
s = s + JSON.stringify(arguments[i]);
|
||||||
|
} else {
|
||||||
|
s = s + arguments[i].toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
s = s + "\n";
|
||||||
|
console2.log(s);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log = function log(){
|
console.log = function log(){
|
||||||
|
var s = '';
|
||||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||||
console2.log(arguments[i]);
|
if (i > 0) s = s + ' ';
|
||||||
|
if (typeof arguments[i] === 'undefined') {
|
||||||
|
s = s + 'undefined';
|
||||||
|
} else if (typeof arguments[i] === 'object') {
|
||||||
|
s = s + JSON.stringify(arguments[i]);
|
||||||
|
} else {
|
||||||
|
s = s + arguments[i].toString();
|
||||||
|
}
|
||||||
|
//console2.log(arguments[i]);
|
||||||
}
|
}
|
||||||
|
s = s + "\n";
|
||||||
|
console2.log(s);
|
||||||
};
|
};
|
||||||
|
|
2
app/src/main/assets/revoked_certs.txt
Normal file
2
app/src/main/assets/revoked_certs.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#Demo certificate
|
||||||
|
51:6D:12:67:4C:27:F4:9B:9F:E5:42:9B:01:B3:98:E4:66:2B:85:B7:A8:DD:70:32:B7:6A:D7:97:9A:0D:97:10
|
|
@ -1,96 +0,0 @@
|
||||||
package com.squareup.otto;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ConcurrentModificationException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs events has they're being posted to and dispatched from the event bus.
|
|
||||||
* <p>
|
|
||||||
* A summary of event-receiver calls that occurred so far is logged
|
|
||||||
* after 10s (after startup) and then again every 60s.
|
|
||||||
*/
|
|
||||||
public class LoggingBus extends Bus {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(L.EVENTS);
|
|
||||||
|
|
||||||
private static long everyMinute = System.currentTimeMillis() + 10 * 1000;
|
|
||||||
private Map<String, Set<String>> event2Receiver = new HashMap<>();
|
|
||||||
|
|
||||||
public LoggingBus(ThreadEnforcer enforcer) {
|
|
||||||
super(enforcer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void post(Object event) {
|
|
||||||
if (event instanceof DeadEvent) {
|
|
||||||
log.debug("Event has no receiver: " + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(event instanceof Event)) {
|
|
||||||
log.error("Posted event not an event class: " + event.getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug("<<< " + event);
|
|
||||||
try {
|
|
||||||
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
|
||||||
String className = caller.getClassName();
|
|
||||||
className = className.substring(className.lastIndexOf(".") + 1);
|
|
||||||
log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber());
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
log.debug(" source: <unknown>");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
super.post(event);
|
|
||||||
} catch (IllegalStateException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(Object event, EventHandler wrapper) {
|
|
||||||
try {
|
|
||||||
log.debug(">>> " + event);
|
|
||||||
Field methodField = wrapper.getClass().getDeclaredField("method");
|
|
||||||
methodField.setAccessible(true);
|
|
||||||
Method targetMethod = (Method) methodField.get(wrapper);
|
|
||||||
String className = targetMethod.getDeclaringClass().getSimpleName();
|
|
||||||
String methodName = targetMethod.getName();
|
|
||||||
String receiverMethod = className + "." + methodName;
|
|
||||||
log.debug(" receiver: " + receiverMethod);
|
|
||||||
|
|
||||||
String key = event.getClass().getSimpleName();
|
|
||||||
if (!event2Receiver.containsKey(key)) event2Receiver.put(key, new HashSet<String>());
|
|
||||||
event2Receiver.get(key).add(receiverMethod);
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
log.debug(" receiver: <unknown>");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (everyMinute < System.currentTimeMillis()) {
|
|
||||||
log.debug("***************** Event -> receiver pairings seen so far ****************");
|
|
||||||
for (Map.Entry<String, Set<String>> stringSetEntry : event2Receiver.entrySet()) {
|
|
||||||
log.debug(" " + stringSetEntry.getKey());
|
|
||||||
for (String s : stringSetEntry.getValue()) {
|
|
||||||
log.debug(" -> " + s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.debug("*************************************************************************");
|
|
||||||
everyMinute = System.currentTimeMillis() + 60 * 1000;
|
|
||||||
}
|
|
||||||
} catch (ConcurrentModificationException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
super.dispatch(event, wrapper);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,13 +12,4 @@ public class Config {
|
||||||
public static final boolean PUMPCONTROL = BuildConfig.FLAVOR.equals("pumpcontrol");
|
public static final boolean PUMPCONTROL = BuildConfig.FLAVOR.equals("pumpcontrol");
|
||||||
|
|
||||||
public static final boolean PUMPDRIVERS = BuildConfig.FLAVOR.equals("full") || BuildConfig.FLAVOR.equals("pumpcontrol");
|
public static final boolean PUMPDRIVERS = BuildConfig.FLAVOR.equals("full") || BuildConfig.FLAVOR.equals("pumpcontrol");
|
||||||
|
|
||||||
public static final boolean ACTION = !NSCLIENT;
|
|
||||||
public static final boolean MDI = !NSCLIENT;
|
|
||||||
public static final boolean OTHERPROFILES = !NSCLIENT;
|
|
||||||
public static final boolean SAFETY = !NSCLIENT;
|
|
||||||
|
|
||||||
public static final boolean SMSCOMMUNICATORENABLED = !NSCLIENT;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 07.06.2016.
|
* Created by mike on 07.06.2016.
|
||||||
|
@ -31,11 +31,13 @@ public class Constants {
|
||||||
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
|
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
|
||||||
|
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 30;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
public static final int CPP_MIN_TIMESHIFT = -6;
|
public static final int CPP_MIN_TIMESHIFT = -6;
|
||||||
public static final int CPP_MAX_TIMESHIFT = 23;
|
public static final int CPP_MAX_TIMESHIFT = 23;
|
||||||
|
|
||||||
|
public static final double MAX_PROFILE_SWITCH_DURATION = 7 * 24 * 60; // [min] ~ 7 days
|
||||||
|
|
||||||
//DanaR
|
//DanaR
|
||||||
public static final double dailyLimitWarning = 0.95d;
|
public static final double dailyLimitWarning = 0.95d;
|
||||||
|
|
||||||
|
@ -50,6 +52,11 @@ public class Constants {
|
||||||
public static final double defaultHypoTTmgdl = 120d;
|
public static final double defaultHypoTTmgdl = 120d;
|
||||||
public static final double defaultHypoTTmmol = 6.5d;
|
public static final double defaultHypoTTmmol = 6.5d;
|
||||||
|
|
||||||
|
public static final double MIN_TT_MGDL = 72d;
|
||||||
|
public static final double MAX_TT_MGDL = 180d;
|
||||||
|
public static final double MIN_TT_MMOL = 4d;
|
||||||
|
public static final double MAX_TT_MMOL = 10d;
|
||||||
|
|
||||||
//NSClientInternal
|
//NSClientInternal
|
||||||
public static final int MAX_LOG_LINES = 100;
|
public static final int MAX_LOG_LINES = 100;
|
||||||
|
|
||||||
|
@ -68,4 +75,7 @@ public class Constants {
|
||||||
//SMS Communicator
|
//SMS Communicator
|
||||||
public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs();
|
public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs();
|
||||||
|
|
||||||
|
//Storage [MB]
|
||||||
|
public static final long MINIMUM_FREE_SPACE = 200;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,6 @@ import android.content.pm.PackageManager;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.design.widget.NavigationView;
|
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v4.widget.DrawerLayout;
|
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
|
@ -31,53 +20,65 @@ import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.google.android.material.navigation.NavigationView;
|
||||||
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.joanzapata.iconify.Iconify;
|
import com.joanzapata.iconify.Iconify;
|
||||||
import com.joanzapata.iconify.fonts.FontAwesomeModule;
|
import com.joanzapata.iconify.fonts.FontAwesomeModule;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.activities.AgreementActivity;
|
import info.nightscout.androidaps.activities.AgreementActivity;
|
||||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity;
|
import info.nightscout.androidaps.activities.HistoryBrowseActivity;
|
||||||
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.activities.PreferencesActivity;
|
import info.nightscout.androidaps.activities.PreferencesActivity;
|
||||||
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventFeatureRunning;
|
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRebuildTabs;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt;
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
||||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity;
|
import info.nightscout.androidaps.setupwizard.SetupWizardActivity;
|
||||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||||
import info.nightscout.utils.AndroidPermission;
|
import info.nightscout.androidaps.utils.AndroidPermission;
|
||||||
import info.nightscout.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.OKDialog;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
import info.nightscout.utils.PasswordProtection;
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||||
import info.nightscout.utils.VersionChecker;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
protected PowerManager.WakeLock mWakeLock;
|
|
||||||
|
|
||||||
private ActionBarDrawerToggle actionBarDrawerToggle;
|
private ActionBarDrawerToggle actionBarDrawerToggle;
|
||||||
|
|
||||||
private MenuItem pluginPreferencesMenuItem;
|
private MenuItem pluginPreferencesMenuItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (L.isEnabled(L.CORE))
|
|
||||||
log.debug("onCreate");
|
|
||||||
|
|
||||||
Iconify.with(new FontAwesomeModule());
|
Iconify.with(new FontAwesomeModule());
|
||||||
LocaleHelper.onCreate(this, "en");
|
LocaleHelper.INSTANCE.update(getApplicationContext());
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
setSupportActionBar(findViewById(R.id.toolbar));
|
setSupportActionBar(findViewById(R.id.toolbar));
|
||||||
|
@ -91,14 +92,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
actionBarDrawerToggle.syncState();
|
actionBarDrawerToggle.syncState();
|
||||||
|
|
||||||
// initialize screen wake lock
|
// initialize screen wake lock
|
||||||
onEventPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on));
|
processPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on));
|
||||||
|
|
||||||
doMigrations();
|
doMigrations();
|
||||||
|
|
||||||
registerBus();
|
|
||||||
setupTabs();
|
|
||||||
setupViews(false);
|
|
||||||
|
|
||||||
final ViewPager viewPager = findViewById(R.id.pager);
|
final ViewPager viewPager = findViewById(R.id.pager);
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,7 +111,49 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public void onPageScrollStateChanged(int state) {
|
public void onPageScrollStateChanged(int state) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
VersionChecker.check();
|
|
||||||
|
//Check here if loop plugin is disabled. Else check via constraints
|
||||||
|
if (!LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||||
|
VersionCheckerUtilsKt.triggerCheckVersion();
|
||||||
|
|
||||||
|
FabricPrivacy.setUserStats();
|
||||||
|
|
||||||
|
setupTabs();
|
||||||
|
setupViews();
|
||||||
|
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRebuildTabs.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
LocaleHelper.INSTANCE.update(getApplicationContext());
|
||||||
|
if (event.getRecreate()) {
|
||||||
|
recreate();
|
||||||
|
} else {
|
||||||
|
setupTabs();
|
||||||
|
setupViews();
|
||||||
|
}
|
||||||
|
setWakeLock();
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPreferenceChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(this::processPreferenceChange, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
|
||||||
|
Intent intent = new Intent(this, SetupWizardActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
checkEula();
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidPermission.notifyForStoragePermission(this);
|
||||||
|
AndroidPermission.notifyForBatteryOptimizationPermission(this);
|
||||||
|
if (Config.PUMPDRIVERS) {
|
||||||
|
AndroidPermission.notifyForLocationPermissions(this);
|
||||||
|
AndroidPermission.notifyForSMSPermissions(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPluginPreferences(ViewPager viewPager) {
|
private void checkPluginPreferences(ViewPager viewPager) {
|
||||||
|
@ -130,86 +169,29 @@ public class MainActivity extends AppCompatActivity {
|
||||||
actionBarDrawerToggle.syncState();
|
actionBarDrawerToggle.syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
if (L.isEnabled(L.CORE))
|
|
||||||
log.debug("onResume");
|
|
||||||
|
|
||||||
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
|
|
||||||
Intent intent = new Intent(this, SetupWizardActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
|
||||||
checkEula();
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidPermission.notifyForStoragePermission(this);
|
|
||||||
AndroidPermission.notifyForBatteryOptimizationPermission(this);
|
|
||||||
if (Config.PUMPDRIVERS) {
|
|
||||||
AndroidPermission.notifyForLocationPermissions(this);
|
|
||||||
AndroidPermission.notifyForSMSPermissions(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
if (L.isEnabled(L.CORE))
|
|
||||||
log.debug("onDestroy");
|
|
||||||
if (mWakeLock != null)
|
|
||||||
if (mWakeLock.isHeld())
|
|
||||||
mWakeLock.release();
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
private void setWakeLock() {
|
||||||
public void onEventPreferenceChange(final EventPreferenceChange ev) {
|
boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false);
|
||||||
if (ev.isChanged(R.string.key_keep_screen_on)) {
|
if (keepScreenOn)
|
||||||
boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
else
|
||||||
if (keepScreenOn) {
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AAPS");
|
|
||||||
if (!mWakeLock.isHeld())
|
|
||||||
mWakeLock.acquire();
|
|
||||||
} else {
|
|
||||||
if (mWakeLock != null && mWakeLock.isHeld())
|
|
||||||
mWakeLock.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
public void processPreferenceChange(final EventPreferenceChange ev) {
|
||||||
public void onStatusEvent(final EventRefreshGui ev) {
|
if (ev.isChanged(R.string.key_keep_screen_on))
|
||||||
String lang = SP.getString(R.string.key_language, "en");
|
setWakeLock();
|
||||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
if (ev.recreate) {
|
|
||||||
recreate();
|
|
||||||
} else {
|
|
||||||
try { // activity may be destroyed
|
|
||||||
setupTabs();
|
|
||||||
setupViews(true);
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean keepScreenOn = Config.NSCLIENT && SP.getBoolean(R.string.key_keep_screen_on, false);
|
|
||||||
if (keepScreenOn)
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
||||||
else
|
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupViews(boolean switchToLast) {
|
private void setupViews() {
|
||||||
TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this);
|
TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this);
|
||||||
NavigationView navigationView = findViewById(R.id.navigation_view);
|
NavigationView navigationView = findViewById(R.id.navigation_view);
|
||||||
navigationView.setNavigationItemSelectedListener(menuItem -> {
|
navigationView.setNavigationItemSelectedListener(menuItem -> true);
|
||||||
return true;
|
|
||||||
});
|
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
menu.clear();
|
menu.clear();
|
||||||
for (PluginBase p : MainApp.getPluginsList()) {
|
for (PluginBase p : MainApp.getPluginsList()) {
|
||||||
|
@ -228,8 +210,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
ViewPager mPager = findViewById(R.id.pager);
|
ViewPager mPager = findViewById(R.id.pager);
|
||||||
mPager.setAdapter(pageAdapter);
|
mPager.setAdapter(pageAdapter);
|
||||||
if (switchToLast)
|
//if (switchToLast)
|
||||||
mPager.setCurrentItem(pageAdapter.getCount() - 1, false);
|
// mPager.setCurrentItem(pageAdapter.getCount() - 1, false);
|
||||||
checkPluginPreferences(mPager);
|
checkPluginPreferences(mPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,15 +237,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerBus() {
|
|
||||||
try {
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
} catch (RuntimeException x) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkEula() {
|
private void checkEula() {
|
||||||
//SP.removeBoolean(R.string.key_i_understand);
|
//SP.removeBoolean(R.string.key_i_understand);
|
||||||
boolean IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
boolean IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
||||||
|
@ -280,10 +253,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
// guarantee that the unreachable threshold is at least 30 and of type String
|
// guarantee that the unreachable threshold is at least 30 and of type String
|
||||||
// Added in 1.57 at 21.01.2018
|
// Added in 1.57 at 21.01.2018
|
||||||
Integer unreachable_threshold = SP.getInt(R.string.key_pump_unreachable_threshold, 30);
|
int unreachable_threshold = SP.getInt(R.string.key_pump_unreachable_threshold, 30);
|
||||||
SP.remove(R.string.key_pump_unreachable_threshold);
|
SP.remove(R.string.key_pump_unreachable_threshold);
|
||||||
if (unreachable_threshold < 30) unreachable_threshold = 30;
|
if (unreachable_threshold < 30) unreachable_threshold = 30;
|
||||||
SP.putString(R.string.key_pump_unreachable_threshold, unreachable_threshold.toString());
|
SP.putString(R.string.key_pump_unreachable_threshold, Integer.toString(unreachable_threshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,19 +272,16 @@ public class MainActivity extends AppCompatActivity {
|
||||||
String message = "Target range is changed in current version.\n\nIt's not taken from preferences but from profile.\n\n!!! REVIEW YOUR SETTINGS !!!";
|
String message = "Target range is changed in current version.\n\nIt's not taken from preferences but from profile.\n\n!!! REVIEW YOUR SETTINGS !!!";
|
||||||
message += "\n\nOld settings: " + oldRange;
|
message += "\n\nOld settings: " + oldRange;
|
||||||
message += "\nProfile settings: " + newRange;
|
message += "\nProfile settings: " + newRange;
|
||||||
OKDialog.show(this, "Target range change", message, new Runnable() {
|
OKDialog.show(this, "Target range change", message, () -> {
|
||||||
@Override
|
SP.remove("openapsma_min_bg");
|
||||||
public void run() {
|
SP.remove("openapsma_max_bg");
|
||||||
SP.remove("openapsma_min_bg");
|
SP.remove("openapsma_target_bg");
|
||||||
SP.remove("openapsma_max_bg");
|
|
||||||
SP.remove("openapsma_target_bg");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (permissions.length != 0) {
|
if (permissions.length != 0) {
|
||||||
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
@ -326,7 +296,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
case AndroidPermission.CASE_LOCATION:
|
case AndroidPermission.CASE_LOCATION:
|
||||||
case AndroidPermission.CASE_SMS:
|
case AndroidPermission.CASE_SMS:
|
||||||
case AndroidPermission.CASE_BATTERY:
|
case AndroidPermission.CASE_BATTERY:
|
||||||
case AndroidPermission.CASE_PHONESTATE:
|
case AndroidPermission.CASE_PHONE_STATE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,10 +348,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
case R.id.nav_about:
|
case R.id.nav_about:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION);
|
builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION);
|
||||||
if (Config.NSCLIENT)
|
builder.setIcon(MainApp.getIcon());
|
||||||
builder.setIcon(R.mipmap.yellowowl);
|
|
||||||
else
|
|
||||||
builder.setIcon(R.mipmap.blueowl);
|
|
||||||
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
||||||
message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n";
|
message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n";
|
||||||
message += MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + NSSettingsStatus.getInstance().nightscoutVersionName;
|
message += MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + NSSettingsStatus.getInstance().nightscoutVersionName;
|
||||||
|
@ -399,7 +366,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
case R.id.nav_exit:
|
case R.id.nav_exit:
|
||||||
log.debug("Exiting");
|
log.debug("Exiting");
|
||||||
MainApp.instance().stopKeepAliveService();
|
MainApp.instance().stopKeepAliveService();
|
||||||
MainApp.bus().post(new EventAppExit());
|
RxBus.INSTANCE.send(new EventAppExit());
|
||||||
MainApp.closeDbHelper();
|
MainApp.closeDbHelper();
|
||||||
finish();
|
finish();
|
||||||
System.runFinalization();
|
System.runFinalization();
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.annotation.PluralsRes;
|
import androidx.annotation.PluralsRes;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
import com.squareup.otto.LoggingBus;
|
|
||||||
import com.squareup.otto.ThreadEnforcer;
|
|
||||||
|
|
||||||
import net.danlew.android.joda.JodaTimeAndroid;
|
import net.danlew.android.joda.JodaTimeAndroid;
|
||||||
|
|
||||||
|
@ -29,69 +27,82 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
import info.nightscout.androidaps.plugins.constraints.dstHelper.DstHelperPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.constraints.storage.StorageConstraintPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin;
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
import info.nightscout.androidaps.plugins.general.food.FoodPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.DBAccessReceiver;
|
import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.receivers.AckAlarmReceiver;
|
||||||
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessReceiver;
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.profile.simple.SimpleProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceEversensePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceMM640gPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceNSClientPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourcePoctechPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceTomatoPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||||
|
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
||||||
import info.nightscout.androidaps.services.Intents;
|
import info.nightscout.androidaps.services.Intents;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion;
|
||||||
|
|
||||||
|
|
||||||
public class MainApp extends Application {
|
public class MainApp extends Application {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
private static KeepAliveReceiver keepAliveReceiver;
|
private static KeepAliveReceiver keepAliveReceiver;
|
||||||
|
|
||||||
private static Bus sBus;
|
|
||||||
private static MainApp sInstance;
|
private static MainApp sInstance;
|
||||||
public static Resources sResources;
|
public static Resources sResources;
|
||||||
|
|
||||||
|
private static FirebaseAnalytics mFirebaseAnalytics;
|
||||||
|
|
||||||
private static DatabaseHelper sDatabaseHelper = null;
|
private static DatabaseHelper sDatabaseHelper = null;
|
||||||
private static ConstraintChecker sConstraintsChecker = null;
|
private static ConstraintChecker sConstraintsChecker = null;
|
||||||
|
|
||||||
|
@ -102,6 +113,8 @@ public class MainApp extends Application {
|
||||||
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
|
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
|
||||||
private static DBAccessReceiver dbAccessReciever = new DBAccessReceiver();
|
private static DBAccessReceiver dbAccessReciever = new DBAccessReceiver();
|
||||||
private LocalBroadcastManager lbm;
|
private LocalBroadcastManager lbm;
|
||||||
|
BroadcastReceiver btReceiver;
|
||||||
|
TimeDateOrTZChangeReceiver timeDateOrTZChangeReceiver;
|
||||||
|
|
||||||
public static boolean devBranch;
|
public static boolean devBranch;
|
||||||
public static boolean engineeringMode;
|
public static boolean engineeringMode;
|
||||||
|
@ -112,40 +125,47 @@ public class MainApp extends Application {
|
||||||
log.debug("onCreate");
|
log.debug("onCreate");
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
sResources = getResources();
|
sResources = getResources();
|
||||||
sConstraintsChecker = new ConstraintChecker(this);
|
LocaleHelper.INSTANCE.update(this);
|
||||||
|
sConstraintsChecker = new ConstraintChecker();
|
||||||
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
||||||
|
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> log.error("Uncaught exception crashing app", ex));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (FabricPrivacy.fabricEnabled()) {
|
if (FabricPrivacy.fabricEnabled()) {
|
||||||
Fabric.with(this, new Crashlytics());
|
Fabric.with(this, new Crashlytics());
|
||||||
Fabric.with(this, new Answers());
|
|
||||||
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error with Fabric init! " + e);
|
log.error("Error with Fabric init! " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
||||||
|
mFirebaseAnalytics.setAnalyticsCollectionEnabled(!Boolean.getBoolean("disableFirebase"));
|
||||||
|
|
||||||
JodaTimeAndroid.init(this);
|
JodaTimeAndroid.init(this);
|
||||||
|
|
||||||
log.info("Version: " + BuildConfig.VERSION_NAME);
|
log.info("Version: " + BuildConfig.VERSION_NAME);
|
||||||
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
||||||
|
log.info("Remote: " + BuildConfig.REMOTE);
|
||||||
|
|
||||||
String extFilesDir = LoggerUtils.getLogDirectory();
|
String extFilesDir = LoggerUtils.getLogDirectory();
|
||||||
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
|
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
|
||||||
|
|
||||||
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
||||||
devBranch = BuildConfig.VERSION.contains("dev");
|
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
|
||||||
|
|
||||||
sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
|
|
||||||
|
|
||||||
registerLocalBroadcastReceiver();
|
registerLocalBroadcastReceiver();
|
||||||
|
|
||||||
|
//trigger here to see the new version on app start after an update
|
||||||
|
triggerCheckVersion();
|
||||||
|
//setBTReceiver();
|
||||||
|
|
||||||
if (pluginsList == null) {
|
if (pluginsList == null) {
|
||||||
pluginsList = new ArrayList<>();
|
pluginsList = new ArrayList<>();
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(OverviewPlugin.getPlugin());
|
pluginsList.add(OverviewPlugin.INSTANCE);
|
||||||
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
||||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(ActionsPlugin.INSTANCE);
|
||||||
pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin());
|
pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin());
|
||||||
pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin());
|
pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin());
|
||||||
pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin());
|
pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin());
|
||||||
|
@ -157,39 +177,49 @@ public class MainApp extends Application {
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||||
pluginsList.add(CareportalPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(LocalInsightPlugin.getPlugin());
|
||||||
if (Config.PUMPDRIVERS && engineeringMode)
|
|
||||||
pluginsList.add(InsightPlugin.getPlugin()); // <-- Enable Insight plugin here
|
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
||||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(MedtronicPumpPlugin.getPlugin());
|
||||||
|
if (!Config.NSCLIENT) pluginsList.add(MDIPlugin.getPlugin());
|
||||||
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||||
|
pluginsList.add(CareportalPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
|
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin());
|
if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin());
|
||||||
pluginsList.add(NSProfilePlugin.getPlugin());
|
pluginsList.add(NSProfilePlugin.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(SimpleProfilePlugin.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(LocalProfilePlugin.getPlugin());
|
||||||
pluginsList.add(TreatmentsPlugin.getPlugin());
|
pluginsList.add(TreatmentsPlugin.getPlugin());
|
||||||
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(SafetyPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(VersionCheckerPlugin.INSTANCE);
|
||||||
|
if (Config.APS) pluginsList.add(StorageConstraintPlugin.getPlugin());
|
||||||
|
if (Config.APS) pluginsList.add(SignatureVerifierPlugin.getPlugin());
|
||||||
|
if (Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE);
|
||||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||||
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
|
pluginsList.add(SourceDexcomPlugin.INSTANCE);
|
||||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
pluginsList.add(SourceTomatoPlugin.getPlugin());
|
||||||
|
pluginsList.add(SourceEversensePlugin.getPlugin());
|
||||||
|
if (!Config.NSCLIENT) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||||
pluginsList.add(FoodPlugin.getPlugin());
|
pluginsList.add(FoodPlugin.getPlugin());
|
||||||
|
|
||||||
pluginsList.add(WearPlugin.initPlugin(this));
|
pluginsList.add(WearPlugin.initPlugin(this));
|
||||||
pluginsList.add(StatuslinePlugin.initPlugin(this));
|
pluginsList.add(StatuslinePlugin.initPlugin(this));
|
||||||
pluginsList.add(PersistentNotificationPlugin.getPlugin());
|
pluginsList.add(PersistentNotificationPlugin.getPlugin());
|
||||||
pluginsList.add(NSClientPlugin.getPlugin());
|
pluginsList.add(NSClientPlugin.getPlugin());
|
||||||
|
// if (engineeringMode) pluginsList.add(TidepoolPlugin.INSTANCE);
|
||||||
pluginsList.add(MaintenancePlugin.initPlugin(this));
|
pluginsList.add(MaintenancePlugin.initPlugin(this));
|
||||||
|
pluginsList.add(AutomationPlugin.INSTANCE);
|
||||||
|
|
||||||
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
||||||
|
|
||||||
|
pluginsList.add(DstHelperPlugin.getPlugin());
|
||||||
|
|
||||||
|
|
||||||
ConfigBuilderPlugin.getPlugin().initialize();
|
ConfigBuilderPlugin.getPlugin().initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +261,10 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
//register dbaccess
|
//register dbaccess
|
||||||
lbm.registerReceiver(dbAccessReciever, new IntentFilter(Intents.ACTION_DATABASE));
|
lbm.registerReceiver(dbAccessReciever, new IntentFilter(Intents.ACTION_DATABASE));
|
||||||
|
|
||||||
|
this.timeDateOrTZChangeReceiver = new TimeDateOrTZChangeReceiver();
|
||||||
|
this.timeDateOrTZChangeReceiver.registerBroadcasts(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startKeepAliveService() {
|
private void startKeepAliveService() {
|
||||||
|
@ -245,26 +279,6 @@ public class MainApp extends Application {
|
||||||
KeepAliveReceiver.cancelAlarm(this);
|
KeepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subscribe(Object subscriber) {
|
|
||||||
try {
|
|
||||||
bus().register(subscriber);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// already registered
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unsubscribe(Object subscriber) {
|
|
||||||
try {
|
|
||||||
bus().unregister(subscriber);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// already unregistered
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bus bus() {
|
|
||||||
return sBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String gs(int id) {
|
public static String gs(int id) {
|
||||||
return sResources.getString(id);
|
return sResources.getString(id);
|
||||||
}
|
}
|
||||||
|
@ -296,6 +310,10 @@ public class MainApp extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FirebaseAnalytics getFirebaseAnalytics() {
|
||||||
|
return mFirebaseAnalytics;
|
||||||
|
}
|
||||||
|
|
||||||
public static ConstraintChecker getConstraintChecker() {
|
public static ConstraintChecker getConstraintChecker() {
|
||||||
return sConstraintsChecker;
|
return sConstraintsChecker;
|
||||||
}
|
}
|
||||||
|
@ -362,19 +380,6 @@ public class MainApp extends Application {
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
|
|
||||||
if (pluginsList != null) {
|
|
||||||
for (PluginBase p : pluginsList) {
|
|
||||||
if (pluginClass.isAssignableFrom(p.getClass()))
|
|
||||||
return (T) p;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("pluginsList=null");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEngineeringModeOrRelease() {
|
public static boolean isEngineeringModeOrRelease() {
|
||||||
if (!Config.APS)
|
if (!Config.APS)
|
||||||
return true;
|
return true;
|
||||||
|
@ -385,6 +390,24 @@ public class MainApp extends Application {
|
||||||
return devBranch;
|
return devBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getIcon() {
|
||||||
|
if (Config.NSCLIENT)
|
||||||
|
return R.mipmap.ic_yellowowl;
|
||||||
|
else if (Config.PUMPCONTROL)
|
||||||
|
return R.mipmap.ic_pumpcontrol;
|
||||||
|
else
|
||||||
|
return R.mipmap.ic_launcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNotificationIcon() {
|
||||||
|
if (Config.NSCLIENT)
|
||||||
|
return R.drawable.ic_notif_nsclient;
|
||||||
|
else if (Config.PUMPCONTROL)
|
||||||
|
return R.drawable.ic_notif_pumpcontrol;
|
||||||
|
else
|
||||||
|
return R.drawable.ic_notif_aaps;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTerminate() {
|
public void onTerminate() {
|
||||||
if (L.isEnabled(L.CORE))
|
if (L.isEnabled(L.CORE))
|
||||||
|
@ -394,5 +417,19 @@ public class MainApp extends Application {
|
||||||
sDatabaseHelper.close();
|
sDatabaseHelper.close();
|
||||||
sDatabaseHelper = null;
|
sDatabaseHelper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (btReceiver != null) {
|
||||||
|
unregisterReceiver(btReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeDateOrTZChangeReceiver != null) {
|
||||||
|
unregisterReceiver(timeDateOrTZChangeReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int dpToPx(int dp) {
|
||||||
|
float scale = sResources.getDisplayMetrics().density;
|
||||||
|
return (int) (dp * scale + 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,22 @@ package info.nightscout.androidaps.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
public class AgreementActivity extends Activity {
|
public class AgreementActivity extends NoSplashActivity {
|
||||||
boolean IUnderstand;
|
boolean IUnderstand;
|
||||||
CheckBox agreeCheckBox;
|
CheckBox agreeCheckBox;
|
||||||
Button saveButton;
|
Button saveButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_agreement);
|
setContentView(R.layout.activity_agreement);
|
||||||
IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
IUnderstand = SP.getBoolean(R.string.key_i_understand, false);
|
||||||
|
|
|
@ -2,9 +2,6 @@ package info.nightscout.androidaps.activities;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.v4.content.res.ResourcesCompat;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.PopupMenu;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -15,8 +12,10 @@ import android.widget.ImageButton;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -25,49 +24,43 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import butterknife.OnLongClick;
|
|
||||||
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.events.EventCustomCalculationFinished;
|
import info.nightscout.androidaps.events.EventCustomCalculationFinished;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class HistoryBrowseActivity extends AppCompatActivity {
|
public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(HistoryBrowseActivity.class);
|
private static Logger log = LoggerFactory.getLogger(HistoryBrowseActivity.class);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
ImageButton chartButton;
|
ImageButton chartButton;
|
||||||
|
|
||||||
boolean showBasal = true;
|
boolean showBasal = true;
|
||||||
boolean showIob, showCob, showDev, showRat, showDevslope;
|
boolean showIob, showCob, showDev, showRat, showActPrim, showActSec, showDevslope;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.historybrowse_date)
|
|
||||||
Button buttonDate;
|
Button buttonDate;
|
||||||
@BindView(R.id.historybrowse_zoom)
|
|
||||||
Button buttonZoom;
|
Button buttonZoom;
|
||||||
@BindView(R.id.historyybrowse_bggraph)
|
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
@BindView(R.id.historybrowse_iobgraph)
|
|
||||||
GraphView iobGraph;
|
GraphView iobGraph;
|
||||||
@BindView(R.id.historybrowse_seekBar)
|
|
||||||
SeekBar seekBar;
|
SeekBar seekBar;
|
||||||
@BindView(R.id.historybrowse_noprofile)
|
|
||||||
TextView noProfile;
|
TextView noProfile;
|
||||||
@BindView(R.id.overview_iobcalculationprogess)
|
|
||||||
TextView iobCalculationProgressView;
|
TextView iobCalculationProgressView;
|
||||||
|
|
||||||
private int rangeToDisplay = 24; // for graph
|
private int rangeToDisplay = 24; // for graph
|
||||||
|
@ -82,11 +75,83 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_historybrowse);
|
setContentView(R.layout.activity_historybrowse);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
buttonDate = findViewById(R.id.historybrowse_date);
|
||||||
|
buttonZoom = findViewById(R.id.historybrowse_zoom);
|
||||||
|
bgGraph = findViewById(R.id.historyybrowse_bggraph);
|
||||||
|
iobGraph = findViewById(R.id.historybrowse_iobgraph);
|
||||||
|
seekBar = findViewById(R.id.historybrowse_seekBar);
|
||||||
|
noProfile = findViewById(R.id.historybrowse_noprofile);
|
||||||
|
iobCalculationProgressView = findViewById(R.id.overview_iobcalculationprogess);
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_left).setOnClickListener(v -> {
|
||||||
|
start -= T.hours(rangeToDisplay).msecs();
|
||||||
|
updateGUI("onClickLeft");
|
||||||
|
runCalculation("onClickLeft");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_right).setOnClickListener(v -> {
|
||||||
|
start += T.hours(rangeToDisplay).msecs();
|
||||||
|
updateGUI("onClickRight");
|
||||||
|
runCalculation("onClickRight");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_end).setOnClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
start = calendar.getTimeInMillis();
|
||||||
|
updateGUI("onClickEnd");
|
||||||
|
runCalculation("onClickEnd");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_zoom).setOnClickListener(v -> {
|
||||||
|
rangeToDisplay += 6;
|
||||||
|
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||||
|
updateGUI("rangeChange");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_zoom).setOnLongClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(start);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
start = calendar.getTimeInMillis();
|
||||||
|
updateGUI("resetToMidnight");
|
||||||
|
runCalculation("onLongClickZoom");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_date).setOnClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(new Date(start));
|
||||||
|
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||||
|
(view, year, monthOfYear, dayOfMonth) -> {
|
||||||
|
Date date = new Date(0);
|
||||||
|
date.setYear(year - 1900);
|
||||||
|
date.setMonth(monthOfYear);
|
||||||
|
date.setDate(dayOfMonth);
|
||||||
|
date.setHours(0);
|
||||||
|
start = date.getTime();
|
||||||
|
updateGUI("onClickDate");
|
||||||
|
runCalculation("onClickDate");
|
||||||
|
},
|
||||||
|
calendar.get(Calendar.YEAR),
|
||||||
|
calendar.get(Calendar.MONTH),
|
||||||
|
calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
);
|
||||||
|
dpd.setThemeDark(true);
|
||||||
|
dpd.dismissOnPause(true);
|
||||||
|
dpd.show(getFragmentManager(), "Datepickerdialog");
|
||||||
|
});
|
||||||
|
|
||||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
|
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
|
||||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
@ -103,14 +168,33 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
disposable.clear();
|
||||||
iobCobCalculatorPlugin.stopCalculation("onPause");
|
iobCobCalculatorPlugin.stopCalculation("onPause");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventAutosensCalculationFinished.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (event.getCause() == eventCustomCalculationFinished) {
|
||||||
|
log.debug("EventAutosensCalculationFinished");
|
||||||
|
synchronized (HistoryBrowseActivity.this) {
|
||||||
|
updateGUI("EventAutosensCalculationFinished");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventIobCalculationProgress.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (iobCalculationProgressView != null)
|
||||||
|
iobCalculationProgressView.setText(event.getProgress());
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
// set start of current day
|
// set start of current day
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
@ -124,78 +208,6 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
updateGUI("onResume");
|
updateGUI("onResume");
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_left)
|
|
||||||
void onClickLeft() {
|
|
||||||
start -= T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickLeft");
|
|
||||||
runCalculation("onClickLeft");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_right)
|
|
||||||
void onClickRight() {
|
|
||||||
start += T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickRight");
|
|
||||||
runCalculation("onClickRight");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_end)
|
|
||||||
void onClickEnd() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("onClickEnd");
|
|
||||||
runCalculation("onClickEnd");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_zoom)
|
|
||||||
void onClickZoom() {
|
|
||||||
rangeToDisplay += 6;
|
|
||||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
|
||||||
updateGUI("rangeChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnLongClick(R.id.historybrowse_zoom)
|
|
||||||
boolean onLongClickZoom() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(start);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("resetToMidnight");
|
|
||||||
runCalculation("onLongClickZoom");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_date)
|
|
||||||
void onClickDate() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(new Date(start));
|
|
||||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
|
||||||
(view, year, monthOfYear, dayOfMonth) -> {
|
|
||||||
Date date = new Date(0);
|
|
||||||
date.setYear(year - 1900);
|
|
||||||
date.setMonth(monthOfYear);
|
|
||||||
date.setDate(dayOfMonth);
|
|
||||||
date.setHours(0);
|
|
||||||
start = date.getTime();
|
|
||||||
updateGUI("onClickDate");
|
|
||||||
runCalculation("onClickDate");
|
|
||||||
},
|
|
||||||
calendar.get(Calendar.YEAR),
|
|
||||||
calendar.get(Calendar.MONTH),
|
|
||||||
calendar.get(Calendar.DAY_OF_MONTH)
|
|
||||||
);
|
|
||||||
dpd.setThemeDark(true);
|
|
||||||
dpd.dismissOnPause(true);
|
|
||||||
dpd.show(getFragmentManager(), "Datepickerdialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runCalculation(String from) {
|
private void runCalculation(String from) {
|
||||||
long end = start + T.hours(rangeToDisplay).msecs();
|
long end = start + T.hours(rangeToDisplay).msecs();
|
||||||
iobCobCalculatorPlugin.stopCalculation(from);
|
iobCobCalculatorPlugin.stopCalculation(from);
|
||||||
|
@ -203,26 +215,6 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
iobCobCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished);
|
iobCobCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished e) {
|
|
||||||
if (e.cause == eventCustomCalculationFinished) {
|
|
||||||
log.debug("EventAutosensCalculationFinished");
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
synchronized (HistoryBrowseActivity.this) {
|
|
||||||
updateGUI("EventAutosensCalculationFinished");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventIobCalculationProgress e) {
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
if (iobCalculationProgressView != null)
|
|
||||||
iobCalculationProgressView.setText(e.progress);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateGUI(String from) {
|
void updateGUI(String from) {
|
||||||
log.debug("updateGUI from: " + from);
|
log.debug("updateGUI from: " + from);
|
||||||
|
|
||||||
|
@ -240,14 +232,23 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String units = profile.getUnits();
|
final String units = profile.getUnits();
|
||||||
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
final double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
||||||
final double highLine = OverviewPlugin.getPlugin().determineHighLine(units);
|
final double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
||||||
|
|
||||||
buttonDate.setText(DateUtil.dateAndTimeString(start));
|
buttonDate.setText(DateUtil.dateAndTimeString(start));
|
||||||
buttonZoom.setText(String.valueOf(rangeToDisplay));
|
buttonZoom.setText(String.valueOf(rangeToDisplay));
|
||||||
|
|
||||||
final boolean showPrediction = false;
|
final boolean showPrediction = false;
|
||||||
|
|
||||||
|
showBasal = SP.getBoolean("hist_showbasals", true);
|
||||||
|
showIob = SP.getBoolean("hist_showiob", true);
|
||||||
|
showCob = SP.getBoolean("hist_showcob", true);
|
||||||
|
showDev = SP.getBoolean("hist_showdeviations", false);
|
||||||
|
showRat = SP.getBoolean("hist_showratios", false);
|
||||||
|
showActPrim = SP.getBoolean("hist_showactivityprimary", false);
|
||||||
|
showActSec = SP.getBoolean("hist_showactivitysecondary", false);
|
||||||
|
showDevslope = SP.getBoolean("hist_showdevslope", false);
|
||||||
|
|
||||||
int hoursToFetch;
|
int hoursToFetch;
|
||||||
final long toTime;
|
final long toTime;
|
||||||
final long fromTime;
|
final long fromTime;
|
||||||
|
@ -285,6 +286,10 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
// set manual x bounds to have nice steps
|
// set manual x bounds to have nice steps
|
||||||
graphData.formatAxis(fromTime, toTime);
|
graphData.formatAxis(fromTime, toTime);
|
||||||
|
|
||||||
|
if (showActPrim) {
|
||||||
|
graphData.addActivity(fromTime, toTime, false, 1d);
|
||||||
|
}
|
||||||
|
|
||||||
// Treatments
|
// Treatments
|
||||||
graphData.addTreatments(fromTime, toTime);
|
graphData.addTreatments(fromTime, toTime);
|
||||||
|
|
||||||
|
@ -305,6 +310,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
boolean useCobForScale = false;
|
boolean useCobForScale = false;
|
||||||
boolean useDevForScale = false;
|
boolean useDevForScale = false;
|
||||||
boolean useRatioForScale = false;
|
boolean useRatioForScale = false;
|
||||||
|
boolean useIAForScale = false;
|
||||||
boolean useDSForScale = false;
|
boolean useDSForScale = false;
|
||||||
|
|
||||||
if (showIob) {
|
if (showIob) {
|
||||||
|
@ -315,18 +321,22 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
useDevForScale = true;
|
useDevForScale = true;
|
||||||
} else if (showRat) {
|
} else if (showRat) {
|
||||||
useRatioForScale = true;
|
useRatioForScale = true;
|
||||||
|
} else if (showActSec) {
|
||||||
|
useIAForScale = true;
|
||||||
} else if (showDevslope) {
|
} else if (showDevslope) {
|
||||||
useDSForScale = true;
|
useDSForScale = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showIob)
|
if (showIob)
|
||||||
secondGraphData.addIob(fromTime, toTime, useIobForScale, 1d);
|
secondGraphData.addIob(fromTime, toTime, useIobForScale, 1d, showPrediction);
|
||||||
if (showCob)
|
if (showCob)
|
||||||
secondGraphData.addCob(fromTime, toTime, useCobForScale, useCobForScale ? 1d : 0.5d);
|
secondGraphData.addCob(fromTime, toTime, useCobForScale, useCobForScale ? 1d : 0.5d);
|
||||||
if (showDev)
|
if (showDev)
|
||||||
secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d);
|
secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d);
|
||||||
if (showRat)
|
if (showRat)
|
||||||
secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
|
secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
|
||||||
|
if (showActSec)
|
||||||
|
secondGraphData.addActivity(fromTime, toTime, useIAForScale, useIAForScale ? 2d : 1d);
|
||||||
if (showDevslope)
|
if (showDevslope)
|
||||||
secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1d);
|
secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1d);
|
||||||
|
|
||||||
|
@ -337,14 +347,14 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
// do GUI update
|
// do GUI update
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (showIob || showCob || showDev || showRat || showDevslope) {
|
if (showIob || showCob || showDev || showRat || showActSec || showDevslope) {
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
iobGraph.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
iobGraph.setVisibility(View.GONE);
|
iobGraph.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
// finally enforce drawing of graphs
|
// finally enforce drawing of graphs
|
||||||
graphData.performUpdate();
|
graphData.performUpdate();
|
||||||
if (showIob || showCob || showDev || showRat || showDevslope)
|
if (showIob || showCob || showDev || showRat || showActSec || showDevslope)
|
||||||
secondGraphData.performUpdate();
|
secondGraphData.performUpdate();
|
||||||
});
|
});
|
||||||
}).start();
|
}).start();
|
||||||
|
@ -353,22 +363,37 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
private void setupChartMenu() {
|
private void setupChartMenu() {
|
||||||
chartButton = (ImageButton) findViewById(R.id.overview_chartMenuButton);
|
chartButton = (ImageButton) findViewById(R.id.overview_chartMenuButton);
|
||||||
chartButton.setOnClickListener(v -> {
|
chartButton.setOnClickListener(v -> {
|
||||||
MenuItem item;
|
MenuItem item, dividerItem;
|
||||||
CharSequence title;
|
CharSequence title;
|
||||||
|
int titleMaxChars = 0;
|
||||||
SpannableString s;
|
SpannableString s;
|
||||||
PopupMenu popup = new PopupMenu(v.getContext(), v);
|
PopupMenu popup = new PopupMenu(v.getContext(), v);
|
||||||
|
|
||||||
|
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
item.setCheckable(true);
|
item.setCheckable(true);
|
||||||
item.setChecked(showBasal);
|
item.setChecked(showBasal);
|
||||||
|
|
||||||
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.ACTPRIM.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
|
||||||
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
|
s = new SpannableString(title);
|
||||||
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
|
||||||
|
item.setTitle(s);
|
||||||
|
item.setCheckable(true);
|
||||||
|
item.setChecked(showActPrim);
|
||||||
|
|
||||||
|
dividerItem = popup.getMenu().add("");
|
||||||
|
dividerItem.setEnabled(false);
|
||||||
|
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
|
@ -377,6 +402,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
|
@ -385,6 +411,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
|
@ -393,15 +420,27 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
item.setCheckable(true);
|
item.setCheckable(true);
|
||||||
item.setChecked(showRat);
|
item.setChecked(showRat);
|
||||||
|
|
||||||
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.ACTSEC.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
|
||||||
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
|
s = new SpannableString(title);
|
||||||
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
|
||||||
|
item.setTitle(s);
|
||||||
|
item.setCheckable(true);
|
||||||
|
item.setChecked(showActSec);
|
||||||
|
|
||||||
|
|
||||||
if (MainApp.devBranch) {
|
if (MainApp.devBranch) {
|
||||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
|
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
|
||||||
title = item.getTitle();
|
title = item.getTitle();
|
||||||
|
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||||
s = new SpannableString(title);
|
s = new SpannableString(title);
|
||||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
|
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
|
||||||
item.setTitle(s);
|
item.setTitle(s);
|
||||||
|
@ -409,19 +448,27 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
item.setChecked(showDevslope);
|
item.setChecked(showDevslope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fairly good guestimate for required divider text size...
|
||||||
|
title = new String(new char[titleMaxChars + 10]).replace("\0", "_");
|
||||||
|
dividerItem.setTitle(title);
|
||||||
|
|
||||||
popup.setOnMenuItemClickListener(item1 -> {
|
popup.setOnMenuItemClickListener(item1 -> {
|
||||||
if (item1.getItemId() == OverviewFragment.CHARTTYPE.BAS.ordinal()) {
|
if (item1.getItemId() == OverviewFragment.CHARTTYPE.BAS.ordinal()) {
|
||||||
showBasal = !item1.isChecked();
|
SP.putBoolean("hist_showbasals", !item1.isChecked());
|
||||||
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.IOB.ordinal()) {
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.IOB.ordinal()) {
|
||||||
showIob = !item1.isChecked();
|
SP.putBoolean("hist_showiob", !item1.isChecked());
|
||||||
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.COB.ordinal()) {
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.COB.ordinal()) {
|
||||||
showCob = !item1.isChecked();
|
SP.putBoolean("hist_showcob", !item1.isChecked());
|
||||||
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.DEV.ordinal()) {
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.DEV.ordinal()) {
|
||||||
showDev = !item1.isChecked();
|
SP.putBoolean("hist_showdeviations", !item1.isChecked());
|
||||||
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.SEN.ordinal()) {
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.SEN.ordinal()) {
|
||||||
showRat = !item1.isChecked();
|
SP.putBoolean("hist_showratios", !item1.isChecked());
|
||||||
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.ACTPRIM.ordinal()) {
|
||||||
|
SP.putBoolean("hist_showactivityprimary", !item1.isChecked());
|
||||||
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.ACTSEC.ordinal()) {
|
||||||
|
SP.putBoolean("hist_showactivitysecondary", !item1.isChecked());
|
||||||
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal()) {
|
} else if (item1.getItemId() == OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal()) {
|
||||||
showDevslope = !item1.isChecked();
|
SP.putBoolean("hist_showdevslope", !item1.isChecked());
|
||||||
}
|
}
|
||||||
updateGUI("onGraphCheckboxesCheckedChanged");
|
updateGUI("onGraphCheckboxesCheckedChanged");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
open class NoSplashActivity : Activity() {
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
open class NoSplashAppCompatActivity : AppCompatActivity() {
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,47 +9,54 @@ import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
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.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRebuildTabs;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||||
import info.nightscout.utils.LocaleHelper;
|
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
|
||||||
import info.nightscout.utils.OKDialog;
|
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin;
|
||||||
|
|
||||||
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
MyPreferenceFragment myPreferenceFragment;
|
MyPreferenceFragment myPreferenceFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
myPreferenceFragment = new MyPreferenceFragment();
|
myPreferenceFragment = new MyPreferenceFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -61,16 +68,14 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
MainApp.bus().post(new EventPreferenceChange(key));
|
RxBus.INSTANCE.send(new EventPreferenceChange(key));
|
||||||
if (key.equals("language")) {
|
if (key.equals("language")) {
|
||||||
String lang = sharedPreferences.getString("language", "en");
|
RxBus.INSTANCE.send(new EventRebuildTabs(true));
|
||||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
|
||||||
MainApp.bus().post(new EventRefreshGui(true));
|
|
||||||
//recreate() does not update language so better close settings
|
//recreate() does not update language so better close settings
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
if (key.equals("short_tabtitles")) {
|
if (key.equals("short_tabtitles")) {
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
RxBus.INSTANCE.send(new EventRebuildTabs());
|
||||||
}
|
}
|
||||||
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
||||||
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
|
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
|
||||||
|
@ -92,7 +97,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
} else if (editTextPref.getText() != null) {
|
} else if (editTextPref.getText() != null) {
|
||||||
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
||||||
pref.setSummary(editTextPref.getText());
|
pref.setSummary(editTextPref.getText());
|
||||||
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) {
|
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && (editTextPref.getText() == null || TextUtils.isEmpty(editTextPref.getText().trim()))) {
|
||||||
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +148,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.pref_overview);
|
addPreferencesFromResource(R.xml.pref_overview);
|
||||||
|
|
||||||
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginType.BGSOURCE);
|
addPreferencesFromResourceIfEnabled(SourceDexcomPlugin.INSTANCE, PluginType.BGSOURCE);
|
||||||
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL);
|
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS);
|
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS);
|
||||||
if (Config.APS) {
|
if (Config.APS) {
|
||||||
|
@ -163,8 +168,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(InsightPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), PluginType.PUMP);
|
||||||
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
||||||
|
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||||
|
|
||||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||||
|
@ -181,7 +187,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
|
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
|
||||||
|
|
||||||
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
|
addPreferencesFromResourceIfEnabled(TidepoolPlugin.INSTANCE, PluginType.GENERAL);
|
||||||
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginType.GENERAL);
|
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
|
addPreferencesFromResourceIfEnabled(AutomationPlugin.INSTANCE, PluginType.GENERAL);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.pref_others);
|
addPreferencesFromResource(R.xml.pref_others);
|
||||||
addPreferencesFromResource(R.xml.pref_datachoices);
|
addPreferencesFromResource(R.xml.pref_datachoices);
|
||||||
|
@ -190,7 +198,26 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL);
|
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.NSCLIENT) {
|
||||||
|
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen) findPreference(getString(R.string.key_advancedsettings));
|
||||||
|
if (scrnAdvancedSettings != null) {
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights)));
|
||||||
|
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights_extended)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initSummary(getPreferenceScreen());
|
initSummary(getPreferenceScreen());
|
||||||
|
|
||||||
|
final Preference tidepoolTestLogin = findPreference(MainApp.gs(R.string.key_tidepool_test_login));
|
||||||
|
if (tidepoolTestLogin != null)
|
||||||
|
tidepoolTestLogin.setOnPreferenceClickListener(preference -> {
|
||||||
|
TidepoolUploader.INSTANCE.testLogin(getActivity());
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin
|
||||||
|
|
||||||
|
class RequestDexcomPermissionActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
|
private val requestCode = "AndroidAPS <3".map { it.toInt() }.sum()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
requestPermissions(arrayOf(SourceDexcomPlugin.PERMISSION), requestCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,24 +2,24 @@ package info.nightscout.androidaps.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.PreferencesActivity;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.utils.PasswordProtection;
|
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||||
|
|
||||||
public class SingleFragmentActivity extends AppCompatActivity {
|
public class SingleFragmentActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private PluginBase plugin;
|
private PluginBase plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_single_fragment);
|
setContentView(R.layout.activity_single_fragment);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package info.nightscout.androidaps.activities;
|
package info.nightscout.androidaps.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -18,7 +16,7 @@ import android.widget.TableLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -39,21 +37,26 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class TDDStatsActivity extends Activity {
|
public class TDDStatsActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
TextView statusView, statsMessage, totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
EditText totalBaseBasal;
|
EditText totalBaseBasal;
|
||||||
|
@ -74,13 +77,25 @@ public class TDDStatsActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> statusView.setText(event.getStatus()), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventDanaRSyncStatus.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
log.debug("EventDanaRSyncStatus: " + event.getMessage());
|
||||||
|
statusView.setText(event.getMessage());
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,7 +114,7 @@ public class TDDStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.danar_statsactivity);
|
setContentView(R.layout.danar_statsactivity);
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
|
@ -239,7 +254,7 @@ public class TDDStatsActivity extends Activity {
|
||||||
statsMessage.setText(MainApp.gs(R.string.danar_stats_warning_Message));
|
statsMessage.setText(MainApp.gs(R.string.danar_stats_warning_Message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadTDDs( new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadTDDs(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
loadDataFromDB();
|
loadDataFromDB();
|
||||||
|
@ -399,7 +414,7 @@ public class TDDStatsActivity extends Activity {
|
||||||
|
|
||||||
//cumulative TDDs
|
//cumulative TDDs
|
||||||
for (TDD record : historyList) {
|
for (TDD record : historyList) {
|
||||||
if(!historyList.isEmpty() && df.format(new Date(record.date)).equals(df.format(new Date()))) {
|
if (!historyList.isEmpty() && df.format(new Date(record.date)).equals(df.format(new Date()))) {
|
||||||
//Today should not be included
|
//Today should not be included
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -448,7 +463,7 @@ public class TDDStatsActivity extends Activity {
|
||||||
tl.setBackgroundColor(Color.TRANSPARENT);
|
tl.setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!historyList.isEmpty() && df.format(new Date(historyList.get(0).date)).equals(df.format(new Date()))) {
|
if (!historyList.isEmpty() && df.format(new Date(historyList.get(0).date)).equals(df.format(new Date()))) {
|
||||||
//Today should not be included
|
//Today should not be included
|
||||||
historyList.remove(0);
|
historyList.remove(0);
|
||||||
}
|
}
|
||||||
|
@ -519,42 +534,17 @@ public class TDDStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventDanaRSyncStatus s) {
|
|
||||||
log.debug("EventDanaRSyncStatus: " + s.message);
|
|
||||||
runOnUiThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusView.setText(s.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
|
||||||
runOnUiThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusView.setText(c.textStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isOldData(List<TDD> historyList) {
|
public static boolean isOldData(List<TDD> historyList) {
|
||||||
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
PumpInterface dana = DanaRPlugin.getPlugin();
|
||||||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
PumpInterface danaRS = DanaRSPlugin.getPlugin();
|
||||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
PumpInterface danaV2 = DanaRv2Plugin.getPlugin();
|
||||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
PumpInterface danaKorean = DanaRKoreanPlugin.getPlugin();
|
||||||
PumpInterface insight = MainApp.getSpecificPlugin(InsightPlugin.class);
|
PumpInterface insight = LocalInsightPlugin.getPlugin();
|
||||||
|
|
||||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||||
|
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday?1000 * 60 * 60 * 24:0))))));
|
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0))))));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
@ -15,13 +17,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
|
||||||
public class ConstraintChecker implements ConstraintsInterface {
|
public class ConstraintChecker implements ConstraintsInterface {
|
||||||
|
|
||||||
private MainApp mainApp;
|
|
||||||
|
|
||||||
public ConstraintChecker(MainApp mainApp) {
|
|
||||||
this.mainApp = mainApp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Constraint<Boolean> isLoopInvokationAllowed() {
|
public Constraint<Boolean> isLoopInvokationAllowed() {
|
||||||
return isLoopInvocationAllowed(new Constraint<>(true));
|
return isLoopInvocationAllowed(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
@ -50,6 +45,10 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
return isAdvancedFilteringEnabled(new Constraint<>(true));
|
return isAdvancedFilteringEnabled(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Constraint<Boolean> isSuperBolusEnabled() {
|
||||||
|
return isSuperBolusEnabled(new Constraint<>(true));
|
||||||
|
}
|
||||||
|
|
||||||
public Constraint<Double> getMaxBasalAllowed(Profile profile) {
|
public Constraint<Double> getMaxBasalAllowed(Profile profile) {
|
||||||
return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile);
|
return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile);
|
||||||
}
|
}
|
||||||
|
@ -75,9 +74,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isLoopInvocationAllowed(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -87,9 +86,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isClosedLoopAllowed(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -99,9 +98,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isAutosensModeEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -111,9 +110,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isAMAModeEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isAMAModeEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -123,9 +122,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isSMBModeEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isSMBModeEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -135,9 +134,9 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isUAMEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -147,8 +146,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isAdvancedFilteringEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -158,8 +157,19 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {
|
public Constraint<Boolean> isSuperBolusEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
|
for (PluginBase p : constraintsPlugins) {
|
||||||
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
constraint.isSuperBolusEnabled(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Constraint<Double> applyBasalConstraints(@NonNull Constraint<Double> absoluteRate, Profile profile) {
|
||||||
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -169,8 +179,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) {
|
public Constraint<Integer> applyBasalPercentConstraints(@NonNull Constraint<Integer> percentRate, Profile profile) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -180,8 +190,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
|
public Constraint<Double> applyBolusConstraints(@NonNull Constraint<Double> insulin) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -191,8 +201,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
public Constraint<Double> applyExtendedBolusConstraints(@NonNull Constraint<Double> insulin) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -202,8 +212,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
public Constraint<Integer> applyCarbsConstraints(@NonNull Constraint<Integer> carbs) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
@ -213,8 +223,8 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob) {
|
public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> maxIob) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
|
|
@ -2,15 +2,12 @@ package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.rits.cloning.Cloner;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 29.05.2017.
|
* Created by mike on 29.05.2017.
|
||||||
|
|
|
@ -1,163 +0,0 @@
|
||||||
package info.nightscout.androidaps.data;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.text.Spanned;
|
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.j256.ormlite.stmt.PreparedQuery;
|
|
||||||
import com.j256.ormlite.stmt.QueryBuilder;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
|
||||||
import info.nightscout.utils.DateUtil;
|
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
|
||||||
import info.nightscout.utils.Round;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 04.01.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class GlucoseStatus {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(GlucoseStatus.class);
|
|
||||||
public double glucose = 0d;
|
|
||||||
public double delta = 0d;
|
|
||||||
public double avgdelta = 0d;
|
|
||||||
public double short_avgdelta = 0d;
|
|
||||||
public double long_avgdelta = 0d;
|
|
||||||
public long date = 0L;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return MainApp.gs(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" +
|
|
||||||
MainApp.gs(R.string.delta) + " " + DecimalFormatter.to0Decimal(delta) + " mg/dl\n" +
|
|
||||||
MainApp.gs(R.string.short_avgdelta) + " " + DecimalFormatter.to2Decimal(short_avgdelta) + " mg/dl\n" +
|
|
||||||
MainApp.gs(R.string.long_avgdelta) + " " + DecimalFormatter.to2Decimal(long_avgdelta) + " mg/dl";
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlucoseStatus() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlucoseStatus round() {
|
|
||||||
this.glucose = Round.roundTo(this.glucose, 0.1);
|
|
||||||
this.delta = Round.roundTo(this.delta, 0.01);
|
|
||||||
this.avgdelta = Round.roundTo(this.avgdelta, 0.01);
|
|
||||||
this.short_avgdelta = Round.roundTo(this.short_avgdelta, 0.01);
|
|
||||||
this.long_avgdelta = Round.roundTo(this.long_avgdelta, 0.01);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static GlucoseStatus getGlucoseStatusData(){
|
|
||||||
return getGlucoseStatusData(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
|
|
||||||
// load 45min
|
|
||||||
long fromtime = DateUtil.now() - 60 * 1000L * 45;
|
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
|
||||||
|
|
||||||
int sizeRecords = data.size();
|
|
||||||
if (sizeRecords == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.get(0).date < DateUtil.now() - 7 * 60 * 1000L && !allowOldData) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
BgReading now = data.get(0);
|
|
||||||
long now_date = now.date;
|
|
||||||
double change;
|
|
||||||
|
|
||||||
if (sizeRecords == 1) {
|
|
||||||
GlucoseStatus status = new GlucoseStatus();
|
|
||||||
status.glucose = now.value;
|
|
||||||
status.short_avgdelta = 0d;
|
|
||||||
status.delta = 0d;
|
|
||||||
status.long_avgdelta = 0d;
|
|
||||||
status.avgdelta = 0d; // for OpenAPS MA
|
|
||||||
status.date = now_date;
|
|
||||||
return status.round();
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Double> last_deltas = new ArrayList<Double>();
|
|
||||||
ArrayList<Double> short_deltas = new ArrayList<Double>();
|
|
||||||
ArrayList<Double> long_deltas = new ArrayList<Double>();
|
|
||||||
|
|
||||||
for (int i = 1; i < data.size(); i++) {
|
|
||||||
if (data.get(i).value > 38) {
|
|
||||||
BgReading then = data.get(i);
|
|
||||||
long then_date = then.date;
|
|
||||||
double avgdelta = 0;
|
|
||||||
long minutesago;
|
|
||||||
|
|
||||||
minutesago = Math.round((now_date - then_date) / (1000d * 60));
|
|
||||||
// multiply by 5 to get the same units as delta, i.e. mg/dL/5m
|
|
||||||
change = now.value - then.value;
|
|
||||||
avgdelta = change / minutesago * 5;
|
|
||||||
|
|
||||||
// use the average of all data points in the last 2.5m for all further "now" calculations
|
|
||||||
if (0 < minutesago && minutesago < 2.5) {
|
|
||||||
now.value = (now.value + then.value) / 2;
|
|
||||||
now_date = (now_date + then_date) / 2;
|
|
||||||
// short_deltas are calculated from everything ~5-15 minutes ago
|
|
||||||
} else if (2.5 < minutesago && minutesago < 17.5) {
|
|
||||||
//console.error(minutesago, avgdelta);
|
|
||||||
short_deltas.add(avgdelta);
|
|
||||||
// last_deltas are calculated from everything ~5 minutes ago
|
|
||||||
if (2.5 < minutesago && minutesago < 7.5) {
|
|
||||||
last_deltas.add(avgdelta);
|
|
||||||
}
|
|
||||||
// long_deltas are calculated from everything ~20-40 minutes ago
|
|
||||||
} else if (17.5 < minutesago && minutesago < 42.5) {
|
|
||||||
long_deltas.add(avgdelta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlucoseStatus status = new GlucoseStatus();
|
|
||||||
status.glucose = now.value;
|
|
||||||
status.date = now_date;
|
|
||||||
|
|
||||||
status.short_avgdelta = average(short_deltas);
|
|
||||||
|
|
||||||
if (last_deltas.isEmpty()) {
|
|
||||||
status.delta = status.short_avgdelta;
|
|
||||||
} else {
|
|
||||||
status.delta = average(last_deltas);
|
|
||||||
}
|
|
||||||
|
|
||||||
status.long_avgdelta = average(long_deltas);
|
|
||||||
status.avgdelta = status.short_avgdelta; // for OpenAPS MA
|
|
||||||
|
|
||||||
return status.round();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double average(ArrayList<Double> array) {
|
|
||||||
double sum = 0d;
|
|
||||||
|
|
||||||
if (array.size() == 0)
|
|
||||||
return 0d;
|
|
||||||
|
|
||||||
for (Double value : array) {
|
|
||||||
sum += value;
|
|
||||||
}
|
|
||||||
return sum / array.size();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.util.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,7 +22,7 @@ public abstract class Intervals<T extends Interval> {
|
||||||
rawData = new LongSparseArray<T>();
|
rawData = new LongSparseArray<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Intervals reset() {
|
public synchronized Intervals<T> reset() {
|
||||||
rawData = new LongSparseArray<T>();
|
rawData = new LongSparseArray<T>();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,12 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
|
||||||
public class IobTotal {
|
public class IobTotal implements DataPointWithLabelInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(IobTotal.class);
|
private static Logger log = LoggerFactory.getLogger(IobTotal.class);
|
||||||
|
|
||||||
public double iob;
|
public double iob;
|
||||||
|
@ -133,4 +135,52 @@ public class IobTotal {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DataPoint interface
|
||||||
|
|
||||||
|
int color;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getX() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getY() {
|
||||||
|
return iob;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setY(double y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDuration() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointsWithLabelGraphSeries.Shape getShape() {
|
||||||
|
return PointsWithLabelGraphSeries.Shape.IOBPREDICTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getSize() {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IobTotal setColor(int color) {
|
||||||
|
this.color = color;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.util.LongSparseArray;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +19,7 @@ public class NonOverlappingIntervals<T extends Interval> extends Intervals<T> {
|
||||||
rawData = other.rawData.clone();
|
rawData = other.rawData.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void merge() {
|
public synchronized void merge() {
|
||||||
for (int index = 0; index < rawData.size() - 1; index++) {
|
for (int index = 0; index < rawData.size() - 1; index++) {
|
||||||
Interval i = rawData.valueAt(index);
|
Interval i = rawData.valueAt(index);
|
||||||
long startOfNewer = rawData.valueAt(index + 1).start();
|
long startOfNewer = rawData.valueAt(index + 1).start();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.support.v4.util.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -9,21 +9,22 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.MidnightTime;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.MidnightTime;
|
||||||
|
|
||||||
public class Profile {
|
public class Profile {
|
||||||
private static Logger log = LoggerFactory.getLogger(Profile.class);
|
private static Logger log = LoggerFactory.getLogger(Profile.class);
|
||||||
|
@ -166,17 +167,18 @@ public class Profile {
|
||||||
final JSONObject o = array.getJSONObject(index);
|
final JSONObject o = array.getJSONObject(index);
|
||||||
long tas = 0;
|
long tas = 0;
|
||||||
try {
|
try {
|
||||||
tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
String time = o.getString("time");
|
String time = o.getString("time");
|
||||||
tas = getShitfTimeSecs(DateUtil.toSeconds(time));
|
tas = getShitfTimeSecs(DateUtil.toSeconds(time));
|
||||||
|
} catch (JSONException e) {
|
||||||
//log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas);
|
//log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas);
|
||||||
|
tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
|
||||||
}
|
}
|
||||||
double value = o.getDouble("value") * multiplier;
|
double value = o.getDouble("value") * multiplier;
|
||||||
sparse.put(tas, value);
|
sparse.put(tas, value);
|
||||||
} catch (JSONException e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
log.error(json.toString());
|
log.error(json.toString());
|
||||||
|
FabricPrivacy.logException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +229,10 @@ public class Profile {
|
||||||
for (int index = 0; index < basal_v.size(); index++) {
|
for (int index = 0; index < basal_v.size(); index++) {
|
||||||
long secondsFromMidnight = basal_v.keyAt(index);
|
long secondsFromMidnight = basal_v.keyAt(index);
|
||||||
if (notify && secondsFromMidnight % 3600 != 0) {
|
if (notify && secondsFromMidnight % 3600 != 0) {
|
||||||
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, String.format(MainApp.gs(R.string.basalprofilenotaligned), from), Notification.NORMAL);
|
if (Config.APS) {
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, String.format(MainApp.gs(R.string.basalprofilenotaligned), from), Notification.NORMAL);
|
||||||
|
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,11 +263,11 @@ public class Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendBelowMinimumNotification(String from) {
|
protected void sendBelowMinimumNotification(String from) {
|
||||||
MainApp.bus().post(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, String.format(MainApp.gs(R.string.minimalbasalvaluereplaced), from), Notification.NORMAL)));
|
RxBus.INSTANCE.send(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, String.format(MainApp.gs(R.string.minimalbasalvaluereplaced), from), Notification.NORMAL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendAboveMaximumNotification(String from) {
|
protected void sendAboveMaximumNotification(String from) {
|
||||||
MainApp.bus().post(new EventNewNotification(new Notification(Notification.MAXIMUM_BASAL_VALUE_REPLACED, String.format(MainApp.gs(R.string.maximumbasalvaluereplaced), from), Notification.NORMAL)));
|
RxBus.INSTANCE.send(new EventNewNotification(new Notification(Notification.MAXIMUM_BASAL_VALUE_REPLACED, String.format(MainApp.gs(R.string.maximumbasalvaluereplaced), from), Notification.NORMAL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validate(LongSparseArray array) {
|
private void validate(LongSparseArray array) {
|
||||||
|
@ -401,6 +405,19 @@ public class Profile {
|
||||||
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + MainApp.gs(R.string.profile_per_unit));
|
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + MainApp.gs(R.string.profile_per_unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfileValue[] getIsfs() {
|
||||||
|
if (isf_v == null)
|
||||||
|
isf_v = convertToSparseArray(ic);
|
||||||
|
ProfileValue[] ret = new ProfileValue[isf_v.size()];
|
||||||
|
|
||||||
|
for (Integer index = 0; index < isf_v.size(); index++) {
|
||||||
|
Integer tas = (int) isf_v.keyAt(index);
|
||||||
|
double value = isf_v.valueAt(index);
|
||||||
|
ret[index] = new ProfileValue(tas, value);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public double getIc() {
|
public double getIc() {
|
||||||
return getIcTimeFromMidnight(secondsFromMidnight());
|
return getIcTimeFromMidnight(secondsFromMidnight());
|
||||||
}
|
}
|
||||||
|
@ -421,6 +438,19 @@ public class Profile {
|
||||||
return getValuesList(ic_v, null, new DecimalFormat("0.0"), MainApp.gs(R.string.profile_carbs_per_unit));
|
return getValuesList(ic_v, null, new DecimalFormat("0.0"), MainApp.gs(R.string.profile_carbs_per_unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfileValue[] getIcs() {
|
||||||
|
if (ic_v == null)
|
||||||
|
ic_v = convertToSparseArray(ic);
|
||||||
|
ProfileValue[] ret = new ProfileValue[ic_v.size()];
|
||||||
|
|
||||||
|
for (Integer index = 0; index < ic_v.size(); index++) {
|
||||||
|
Integer tas = (int) ic_v.keyAt(index);
|
||||||
|
double value = ic_v.valueAt(index);
|
||||||
|
ret[index] = new ProfileValue(tas, value);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public double getBasal() {
|
public double getBasal() {
|
||||||
return getBasalTimeFromMidnight(secondsFromMidnight());
|
return getBasalTimeFromMidnight(secondsFromMidnight());
|
||||||
}
|
}
|
||||||
|
@ -439,11 +469,11 @@ public class Profile {
|
||||||
public String getBasalList() {
|
public String getBasalList() {
|
||||||
if (basal_v == null)
|
if (basal_v == null)
|
||||||
basal_v = convertToSparseArray(basal);
|
basal_v = convertToSparseArray(basal);
|
||||||
return getValuesList(basal_v, null, new DecimalFormat("0.00"), MainApp.gs(R.string.profile_ins_units_per_hout));
|
return getValuesList(basal_v, null, new DecimalFormat("0.00"), MainApp.gs(R.string.profile_ins_units_per_hour));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BasalValue {
|
public class ProfileValue {
|
||||||
public BasalValue(int timeAsSeconds, double value) {
|
public ProfileValue(int timeAsSeconds, double value) {
|
||||||
this.timeAsSeconds = timeAsSeconds;
|
this.timeAsSeconds = timeAsSeconds;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -452,15 +482,15 @@ public class Profile {
|
||||||
public double value;
|
public double value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized BasalValue[] getBasalValues() {
|
public synchronized ProfileValue[] getBasalValues() {
|
||||||
if (basal_v == null)
|
if (basal_v == null)
|
||||||
basal_v = convertToSparseArray(basal);
|
basal_v = convertToSparseArray(basal);
|
||||||
BasalValue[] ret = new BasalValue[basal_v.size()];
|
ProfileValue[] ret = new ProfileValue[basal_v.size()];
|
||||||
|
|
||||||
for (Integer index = 0; index < basal_v.size(); index++) {
|
for (Integer index = 0; index < basal_v.size(); index++) {
|
||||||
Integer tas = (int) basal_v.keyAt(index);
|
Integer tas = (int) basal_v.keyAt(index);
|
||||||
double value = basal_v.valueAt(index);
|
double value = basal_v.valueAt(index);
|
||||||
ret[index] = new BasalValue(tas, value);
|
ret[index] = new ProfileValue(tas, value);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -501,6 +531,49 @@ public class Profile {
|
||||||
return getValueToTime(targetHigh_v, timeAsSeconds);
|
return getValueToTime(targetHigh_v, timeAsSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TargetValue {
|
||||||
|
public TargetValue(int timeAsSeconds, double low, double high) {
|
||||||
|
this.timeAsSeconds = timeAsSeconds;
|
||||||
|
this.low = low;
|
||||||
|
this.high = high;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int timeAsSeconds;
|
||||||
|
public double low;
|
||||||
|
public double high;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetValue[] getTargets() {
|
||||||
|
if (targetLow_v == null)
|
||||||
|
targetLow_v = convertToSparseArray(targetLow);
|
||||||
|
if (targetHigh_v == null)
|
||||||
|
targetHigh_v = convertToSparseArray(targetHigh);
|
||||||
|
TargetValue[] ret = new TargetValue[targetLow_v.size()];
|
||||||
|
|
||||||
|
for (Integer index = 0; index < targetLow_v.size(); index++) {
|
||||||
|
Integer tas = (int) targetLow_v.keyAt(index);
|
||||||
|
double low = targetLow_v.valueAt(index);
|
||||||
|
double high = targetHigh_v.valueAt(index);
|
||||||
|
ret[index] = new TargetValue(tas, low, high);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfileValue[] getSingleTargets() {
|
||||||
|
if (targetLow_v == null)
|
||||||
|
targetLow_v = convertToSparseArray(targetLow);
|
||||||
|
if (targetHigh_v == null)
|
||||||
|
targetHigh_v = convertToSparseArray(targetHigh);
|
||||||
|
ProfileValue[] ret = new ProfileValue[targetLow_v.size()];
|
||||||
|
|
||||||
|
for (Integer index = 0; index < targetLow_v.size(); index++) {
|
||||||
|
Integer tas = (int) targetLow_v.keyAt(index);
|
||||||
|
double target = (targetLow_v.valueAt(index) + targetHigh_v.valueAt(index)) / 2;
|
||||||
|
ret[index] = new ProfileValue(tas, target);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTargetList() {
|
public String getTargetList() {
|
||||||
if (targetLow_v == null)
|
if (targetLow_v == null)
|
||||||
targetLow_v = convertToSparseArray(targetLow);
|
targetLow_v = convertToSparseArray(targetLow);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.util.LongSparseArray;
|
import androidx.collection.LongSparseArray;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.utils.DateUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.05.2017.
|
* Created by mike on 09.05.2017.
|
||||||
|
@ -32,7 +31,7 @@ public class ProfileIntervals<T extends Interval> {
|
||||||
rawData = other.rawData.clone();
|
rawData = other.rawData.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ProfileIntervals reset() {
|
public synchronized ProfileIntervals<T> reset() {
|
||||||
rawData = new LongSparseArray<>();
|
rawData = new LongSparseArray<>();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.util.ArrayMap;
|
import androidx.collection.ArrayMap;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import android.text.Html;
|
|
||||||
import android.text.Spanned;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -11,8 +8,8 @@ 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.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
|
||||||
public class PumpEnactResult {
|
public class PumpEnactResult {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.APS);
|
private static Logger log = LoggerFactory.getLogger(L.APS);
|
||||||
|
@ -48,6 +45,11 @@ public class PumpEnactResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PumpEnactResult comment(int comment) {
|
||||||
|
this.comment = MainApp.gs(comment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PumpEnactResult duration(int duration) {
|
public PumpEnactResult duration(int duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
package info.nightscout.androidaps.data;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.utils.SP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 12.10.2016.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class QuickWizard {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(QuickWizard.class);
|
|
||||||
|
|
||||||
private JSONArray storage = new JSONArray();
|
|
||||||
|
|
||||||
public void setData(JSONArray newData) {
|
|
||||||
storage = newData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
SP.putString("QuickWizard", storage.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
|
||||||
return storage.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public QuickWizardEntry get(int position) {
|
|
||||||
try {
|
|
||||||
return new QuickWizardEntry((JSONObject) storage.get(position), position);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean isActive() {
|
|
||||||
for (int i = 0; i < storage.length(); i++) {
|
|
||||||
try {
|
|
||||||
if (new QuickWizardEntry((JSONObject) storage.get(i), i).isActive()) return true;
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QuickWizardEntry getActive() {
|
|
||||||
for (int i = 0; i < storage.length(); i++) {
|
|
||||||
QuickWizardEntry entry;
|
|
||||||
try {
|
|
||||||
entry = new QuickWizardEntry((JSONObject) storage.get(i), i);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (entry.isActive()) return entry;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QuickWizardEntry newEmptyItem() {
|
|
||||||
return new QuickWizardEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOrUpdate(QuickWizardEntry newItem) {
|
|
||||||
if (newItem.position == -1)
|
|
||||||
storage.put(newItem.storage);
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
storage.put(newItem.position, newItem.storage);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(int position) {
|
|
||||||
storage.remove(position);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package info.nightscout.androidaps.data
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.utils.SP
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
object QuickWizard {
|
||||||
|
private var storage = JSONArray()
|
||||||
|
|
||||||
|
init {
|
||||||
|
setData(JSONArray(SP.getString("QuickWizard", "[]")))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getActive(): QuickWizardEntry? {
|
||||||
|
for (i in 0 until storage.length()) {
|
||||||
|
val entry = QuickWizardEntry(storage.get(i) as JSONObject, i)
|
||||||
|
if (entry.isActive) return entry
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setData(newData: JSONArray) {
|
||||||
|
storage = newData
|
||||||
|
}
|
||||||
|
|
||||||
|
fun save() {
|
||||||
|
SP.putString("QuickWizard", storage.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun size(): Int = storage.length()
|
||||||
|
|
||||||
|
operator fun get(position: Int): QuickWizardEntry =
|
||||||
|
QuickWizardEntry(storage.get(position) as JSONObject, position)
|
||||||
|
|
||||||
|
|
||||||
|
fun newEmptyItem(): QuickWizardEntry {
|
||||||
|
return QuickWizardEntry()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addOrUpdate(newItem: QuickWizardEntry) {
|
||||||
|
if (newItem.position == -1)
|
||||||
|
storage.put(newItem.storage)
|
||||||
|
else
|
||||||
|
storage.put(newItem.position, newItem.storage)
|
||||||
|
save()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun remove(position: Int) {
|
||||||
|
storage.remove(position)
|
||||||
|
save()
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,13 +11,14 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.utils.BolusWizard;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 25.12.2017.
|
* Created by mike on 25.12.2017.
|
||||||
|
@ -49,7 +50,7 @@ public class QuickWizardEntry {
|
||||||
useTemptarget: 0
|
useTemptarget: 0
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public QuickWizardEntry() {
|
QuickWizardEntry() {
|
||||||
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
||||||
try {
|
try {
|
||||||
storage = new JSONObject(emptyData);
|
storage = new JSONObject(emptyData);
|
||||||
|
@ -59,18 +60,17 @@ public class QuickWizardEntry {
|
||||||
position = -1;
|
position = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuickWizardEntry(JSONObject entry, int position) {
|
QuickWizardEntry(JSONObject entry, int position) {
|
||||||
storage = entry;
|
storage = entry;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isActive() {
|
Boolean isActive() {
|
||||||
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BolusWizard doCalc(Profile profile, TempTarget tempTarget, BgReading lastBG, boolean _synchronized) {
|
public BolusWizard doCalc(Profile profile, String profileName, BgReading lastBG, boolean _synchronized) {
|
||||||
BolusWizard wizard = new BolusWizard();
|
final TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
|
|
||||||
//BG
|
//BG
|
||||||
double bg = 0;
|
double bg = 0;
|
||||||
if (lastBG != null && useBG() == YES) {
|
if (lastBG != null && useBG() == YES) {
|
||||||
|
@ -85,11 +85,6 @@ public class QuickWizardEntry {
|
||||||
cob = cobInfo.displayCob;
|
cob = cobInfo.displayCob;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temp target
|
|
||||||
if (useTempTarget() == NO) {
|
|
||||||
tempTarget = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bolus IOB
|
// Bolus IOB
|
||||||
boolean bolusIOB = false;
|
boolean bolusIOB = false;
|
||||||
if (useBolusIOB() == YES) {
|
if (useBolusIOB() == YES) {
|
||||||
|
@ -129,8 +124,7 @@ public class QuickWizardEntry {
|
||||||
trend = true;
|
trend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard.doCalc(profile, tempTarget, carbs(), cob, bg, 0d, bolusIOB, basalIOB, superBolus, trend);
|
return new BolusWizard(profile, profileName, tempTarget, carbs(), cob, bg, 0d, 100, true, useCOB() == YES, bolusIOB, basalIOB, superBolus, useTempTarget() == YES, trend, "QuickWizard");
|
||||||
return wizard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buttonText() {
|
public String buttonText() {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.db;
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
|
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
@ -14,15 +12,13 @@ import java.util.Objects;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SP;
|
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS)
|
||||||
public class BgReading implements DataPointWithLabelInterface {
|
public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
@ -220,8 +216,8 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
@Override
|
@Override
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||||
Double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
Double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
||||||
Double highLine = OverviewPlugin.getPlugin().determineHighLine(units);
|
Double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
||||||
int color = MainApp.gc(R.color.inrange);
|
int color = MainApp.gc(R.color.inrange);
|
||||||
if (isPrediction())
|
if (isPrediction())
|
||||||
return getPredectionColor();
|
return getPredectionColor();
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,14 +25,14 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.utils.Translator;
|
import info.nightscout.androidaps.utils.Translator;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
|
||||||
public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
|
@ -90,16 +89,26 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
return System.currentTimeMillis() - date;
|
return System.currentTimeMillis() - date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getHoursFromStart() {
|
public double getHoursFromStart() {
|
||||||
return (System.currentTimeMillis() - date) / (60 * 60 * 1000);
|
return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String age(boolean useShortText) {
|
||||||
|
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
||||||
|
|
||||||
|
String days = " " + MainApp.gs(R.string.days) + " ";
|
||||||
|
String hours = " " + MainApp.gs(R.string.hours) + " ";
|
||||||
|
|
||||||
|
if (useShortText) {
|
||||||
|
days = "d";
|
||||||
|
hours = "h";
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff.get(TimeUnit.DAYS) + days + diff.get(TimeUnit.HOURS) + hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String age() {
|
public String age() {
|
||||||
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
return age(OverviewFragment.shorttextmode);
|
||||||
if (OverviewFragment.shorttextmode)
|
|
||||||
return diff.get(TimeUnit.DAYS) + "d" + diff.get(TimeUnit.HOURS) + "h";
|
|
||||||
else
|
|
||||||
return diff.get(TimeUnit.DAYS) + " " + MainApp.gs(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.gs(R.string.hours);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOlderThan(double hours) {
|
public boolean isOlderThan(double hours) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.db;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.DatabaseUtils;
|
import android.database.DatabaseUtils;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||||
import com.j256.ormlite.dao.CloseableIterator;
|
import com.j256.ormlite.dao.CloseableIterator;
|
||||||
|
@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
@ -29,13 +31,14 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
|
@ -44,16 +47,19 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID;
|
||||||
import info.nightscout.utils.JsonHelper;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset;
|
||||||
import info.nightscout.utils.PercentageSplitter;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
import info.nightscout.androidaps.utils.PercentageSplitter;
|
||||||
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Helper contains all resource to provide a central DB management functionality. Only methods handling
|
* This Helper contains all resource to provide a central DB management functionality. Only methods handling
|
||||||
|
@ -76,8 +82,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||||
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
||||||
public static final String DATABASE_TDDS = "TDDs";
|
public static final String DATABASE_TDDS = "TDDs";
|
||||||
|
public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets";
|
||||||
|
public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs";
|
||||||
|
public static final String DATABASE_INSIGHT_PUMP_IDS = "InsightPumpIDs";
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 9;
|
private static final int DATABASE_VERSION = 11;
|
||||||
|
|
||||||
public static Long earliestDataChange = null;
|
public static Long earliestDataChange = null;
|
||||||
|
|
||||||
|
@ -122,6 +131,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TDD.class);
|
TableUtils.createTableIfNotExists(connectionSource, TDD.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||||
|
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||||
|
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")");
|
||||||
|
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||||
|
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't create database", e);
|
log.error("Can't create database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -134,11 +150,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
this.oldVersion = oldVersion;
|
this.oldVersion = oldVersion;
|
||||||
this.newVersion = newVersion;
|
this.newVersion = newVersion;
|
||||||
|
|
||||||
if (oldVersion == 7 && newVersion == 8) {
|
if (oldVersion < 7) {
|
||||||
log.debug("Upgrading database from v7 to v8");
|
|
||||||
} else if (oldVersion == 8 && newVersion == 9) {
|
|
||||||
log.debug("Upgrading database from v8 to v9");
|
|
||||||
} 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, BgReading.class, true);
|
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
||||||
|
@ -149,6 +161,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
||||||
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
||||||
onCreate(database, connectionSource);
|
onCreate(database, connectionSource);
|
||||||
|
} else if (oldVersion < 10) {
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||||
|
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||||
|
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")");
|
||||||
|
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||||
|
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")");
|
||||||
|
} else if (oldVersion < 11) {
|
||||||
|
database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\"");
|
||||||
|
database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\"");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't drop databases", e);
|
log.error("Can't drop databases", e);
|
||||||
|
@ -220,7 +243,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
new java.util.TimerTask() {
|
new java.util.TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.bus().post(new EventRefreshOverview("resetDatabases"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("resetDatabases"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
3000
|
3000
|
||||||
|
@ -327,6 +350,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return getDao(ProfileSwitch.class);
|
return getDao(ProfileSwitch.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dao<InsightPumpID, Long> getDaoInsightPumpID() throws SQLException {
|
||||||
|
return getDao(InsightPumpID.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dao<InsightBolusID, Long> getDaoInsightBolusID() throws SQLException {
|
||||||
|
return getDao(InsightBolusID.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dao<InsightHistoryOffset, String> getDaoInsightHistoryOffset() throws SQLException {
|
||||||
|
return getDao(InsightHistoryOffset.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static long roundDateToSec(long date) {
|
public static long roundDateToSec(long date) {
|
||||||
long rounded = date - date % 1000;
|
long rounded = date - date % 1000;
|
||||||
if (rounded != date)
|
if (rounded != date)
|
||||||
|
@ -377,7 +412,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventNewBg");
|
log.debug("Firing EventNewBg");
|
||||||
MainApp.bus().post(new EventNewBG(bgReading));
|
RxBus.INSTANCE.send(new EventNewBG(bgReading));
|
||||||
scheduledBgPost = null;
|
scheduledBgPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,24 +431,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BgReading lastBg() {
|
public static BgReading lastBg() {
|
||||||
List<BgReading> bgList = null;
|
List<BgReading> bgList = IobCobCalculatorPlugin.getPlugin().getBgReadings();
|
||||||
|
|
||||||
try {
|
if (bgList == null)
|
||||||
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
|
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
|
||||||
queryBuilder.orderBy("date", false);
|
|
||||||
queryBuilder.limit(1L);
|
|
||||||
queryBuilder.where().ge("value", 39).and().eq("isValid", true);
|
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
|
||||||
bgList = daoBgReadings.query(preparedQuery);
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
if (bgList != null && bgList.size() > 0)
|
|
||||||
return bgList.get(0);
|
|
||||||
else
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
for (int i = 0; i < bgList.size(); i++)
|
||||||
|
if (bgList.get(i).value >= 39)
|
||||||
|
return bgList.get(i);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -448,7 +474,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return new ArrayList<BgReading>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BgReading> getBgreadingsDataFromTime(long start, long end, boolean ascending) {
|
public List<BgReading> getBgreadingsDataFromTime(long start, long end, boolean ascending) {
|
||||||
|
@ -465,7 +491,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return new ArrayList<BgReading>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||||
|
@ -511,6 +537,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return tddList;
|
return tddList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TDD> getTDDsForLastXDays(int days) {
|
||||||
|
List<TDD> tddList;
|
||||||
|
GregorianCalendar gc = new GregorianCalendar();
|
||||||
|
gc.add(Calendar.DAY_OF_YEAR, (-1) * days);
|
||||||
|
|
||||||
|
try {
|
||||||
|
QueryBuilder<TDD, String> queryBuilder = getDaoTDD().queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", false);
|
||||||
|
Where<TDD, String> where = queryBuilder.where();
|
||||||
|
where.ge("date", gc.getTimeInMillis());
|
||||||
|
PreparedQuery<TDD> preparedQuery = queryBuilder.prepare();
|
||||||
|
tddList = getDaoTDD().query(preparedQuery);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
tddList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
return tddList;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------- DbRequests handling -------------------
|
// ------------- DbRequests handling -------------------
|
||||||
|
|
||||||
|
@ -573,7 +617,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------- TREATMENT HANDLING -------------------
|
// -------------------- TEMPTARGET HANDLING -------------------
|
||||||
|
|
||||||
public static void updateEarliestDataChange(long newDate) {
|
public static void updateEarliestDataChange(long newDate) {
|
||||||
if (earliestDataChange == null) {
|
if (earliestDataChange == null) {
|
||||||
|
@ -604,6 +648,23 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<TempTarget>();
|
return new ArrayList<TempTarget>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TempTarget> getTemptargetsDataFromTime(long from, long to, boolean ascending) {
|
||||||
|
try {
|
||||||
|
Dao<TempTarget, Long> daoTempTargets = getDaoTempTargets();
|
||||||
|
List<TempTarget> tempTargets;
|
||||||
|
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.between("date", from, to);
|
||||||
|
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
|
||||||
|
tempTargets = daoTempTargets.query(preparedQuery);
|
||||||
|
return tempTargets;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<TempTarget>();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean createOrUpdate(TempTarget tempTarget) {
|
public boolean createOrUpdate(TempTarget tempTarget) {
|
||||||
try {
|
try {
|
||||||
TempTarget old;
|
TempTarget old;
|
||||||
|
@ -676,7 +737,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventTempTargetChange");
|
log.debug("Firing EventTempTargetChange");
|
||||||
MainApp.bus().post(new EventTempTargetChange());
|
RxBus.INSTANCE.send(new EventTempTargetChange());
|
||||||
scheduledTemTargetPost = null;
|
scheduledTemTargetPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -710,7 +771,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
|
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
.date(trJson.getLong("mills"))
|
.date(trJson.getLong("mills"))
|
||||||
.duration(trJson.getInt("duration"))
|
.duration(JsonHelper.safeGetInt(trJson, "duration"))
|
||||||
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
||||||
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
||||||
.reason(JsonHelper.safeGetString(trJson, "reason", ""))
|
.reason(JsonHelper.safeGetString(trJson, "reason", ""))
|
||||||
|
@ -829,6 +890,31 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search by date (in case its standard record that has become pump record)
|
||||||
|
QueryBuilder<TemporaryBasal, Long> queryBuilder2 = getDaoTemporaryBasal().queryBuilder();
|
||||||
|
Where where2 = queryBuilder2.where();
|
||||||
|
where2.eq("date", tempBasal.date);
|
||||||
|
PreparedQuery<TemporaryBasal> preparedQuery2 = queryBuilder2.prepare();
|
||||||
|
List<TemporaryBasal> trList2 = getDaoTemporaryBasal().query(preparedQuery2);
|
||||||
|
|
||||||
|
if (trList2.size() > 0) {
|
||||||
|
old = trList2.get(0);
|
||||||
|
|
||||||
|
old.copyFromPump(tempBasal);
|
||||||
|
old.source = Source.PUMP;
|
||||||
|
|
||||||
|
if (L.isEnabled(L.DATABASE))
|
||||||
|
log.debug("TEMPBASAL: Updated record with Pump Data : " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
|
|
||||||
|
getDaoTemporaryBasal().update(old);
|
||||||
|
|
||||||
|
updateEarliestDataChange(tempBasal.date);
|
||||||
|
scheduleTemporaryBasalChange();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
|
@ -927,15 +1013,31 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<TemporaryBasal>();
|
return new ArrayList<TemporaryBasal>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long from, long to, boolean ascending) {
|
||||||
|
try {
|
||||||
|
List<TemporaryBasal> tempbasals;
|
||||||
|
QueryBuilder<TemporaryBasal, Long> queryBuilder = getDaoTemporaryBasal().queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.between("date", from, to);
|
||||||
|
PreparedQuery<TemporaryBasal> preparedQuery = queryBuilder.prepare();
|
||||||
|
tempbasals = getDaoTemporaryBasal().query(preparedQuery);
|
||||||
|
return tempbasals;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<TemporaryBasal>();
|
||||||
|
}
|
||||||
|
|
||||||
private static void scheduleTemporaryBasalChange() {
|
private static void scheduleTemporaryBasalChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventTempBasalChange");
|
log.debug("Firing EventTempBasalChange");
|
||||||
MainApp.bus().post(new EventReloadTempBasalData());
|
RxBus.INSTANCE.send(new EventReloadTempBasalData());
|
||||||
MainApp.bus().post(new EventTempBasalChange());
|
RxBus.INSTANCE.send(new EventTempBasalChange());
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
RxBus.INSTANCE.send(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
scheduledTemBasalsPost = null;
|
scheduledTemBasalsPost = null;
|
||||||
}
|
}
|
||||||
|
@ -1053,6 +1155,29 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TemporaryBasal findTempBasalByPumpId(Long pumpId) {
|
||||||
|
try {
|
||||||
|
QueryBuilder<TemporaryBasal, Long> queryBuilder = null;
|
||||||
|
queryBuilder = getDaoTemporaryBasal().queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", false);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("pumpId", pumpId);
|
||||||
|
PreparedQuery<TemporaryBasal> preparedQuery = queryBuilder.prepare();
|
||||||
|
List<TemporaryBasal> list = getDaoTemporaryBasal().query(preparedQuery);
|
||||||
|
|
||||||
|
if (list.size() > 0)
|
||||||
|
return list.get(0);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------ ExtendedBolus handling ---------------
|
// ------------ ExtendedBolus handling ---------------
|
||||||
|
|
||||||
public boolean createOrUpdate(ExtendedBolus extendedBolus) {
|
public boolean createOrUpdate(ExtendedBolus extendedBolus) {
|
||||||
|
@ -1149,6 +1274,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExtendedBolus getExtendedBolusByPumpId(long pumpId) {
|
||||||
|
try {
|
||||||
|
return getDaoExtendedBolus().queryBuilder()
|
||||||
|
.where().eq("pumpId", pumpId)
|
||||||
|
.queryForFirst();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void delete(ExtendedBolus extendedBolus) {
|
public void delete(ExtendedBolus extendedBolus) {
|
||||||
try {
|
try {
|
||||||
getDaoExtendedBolus().delete(extendedBolus);
|
getDaoExtendedBolus().delete(extendedBolus);
|
||||||
|
@ -1234,9 +1370,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventExtendedBolusChange");
|
log.debug("Firing EventExtendedBolusChange");
|
||||||
MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
RxBus.INSTANCE.send(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
RxBus.INSTANCE.send(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
scheduledExtendedBolusPost = null;
|
scheduledExtendedBolusPost = null;
|
||||||
}
|
}
|
||||||
|
@ -1320,6 +1456,23 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CareportalEvent> getCareportalEvents(long start, long end, boolean ascending) {
|
||||||
|
try {
|
||||||
|
List<CareportalEvent> careportalEvents;
|
||||||
|
QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.between("date", start, end);
|
||||||
|
PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
|
||||||
|
careportalEvents = getDaoCareportalEvents().query(preparedQuery);
|
||||||
|
preprocessOpenAPSOfflineEvents(careportalEvents);
|
||||||
|
return careportalEvents;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public void preprocessOpenAPSOfflineEvents(List<CareportalEvent> list) {
|
public void preprocessOpenAPSOfflineEvents(List<CareportalEvent> list) {
|
||||||
OverlappingIntervals offlineEvents = new OverlappingIntervals();
|
OverlappingIntervals offlineEvents = new OverlappingIntervals();
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
@ -1423,7 +1576,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing scheduleCareportalEventChange");
|
log.debug("Firing scheduleCareportalEventChange");
|
||||||
MainApp.bus().post(new EventCareportalEventChange());
|
RxBus.INSTANCE.send(new EventCareportalEventChange());
|
||||||
scheduledCareportalEventPost = null;
|
scheduledCareportalEventPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,6 +1626,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ProfileSwitch> getProfileSwitchEventsFromTime(long from, long to, boolean ascending) {
|
||||||
|
try {
|
||||||
|
Dao<ProfileSwitch, Long> daoProfileSwitch = getDaoProfileSwitch();
|
||||||
|
List<ProfileSwitch> profileSwitches;
|
||||||
|
QueryBuilder<ProfileSwitch, Long> queryBuilder = daoProfileSwitch.queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
queryBuilder.limit(100L);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.between("date", from, to);
|
||||||
|
PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare();
|
||||||
|
profileSwitches = daoProfileSwitch.query(preparedQuery);
|
||||||
|
return profileSwitches;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean createOrUpdate(ProfileSwitch profileSwitch) {
|
public boolean createOrUpdate(ProfileSwitch profileSwitch) {
|
||||||
try {
|
try {
|
||||||
ProfileSwitch old;
|
ProfileSwitch old;
|
||||||
|
@ -1547,9 +1718,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventProfileSwitchChange");
|
log.debug("Firing EventProfileNeedsUpdate");
|
||||||
MainApp.bus().post(new EventReloadProfileSwitchData());
|
RxBus.INSTANCE.send(new EventReloadProfileSwitchData());
|
||||||
MainApp.bus().post(new EventProfileSwitchChange());
|
RxBus.INSTANCE.send(new EventProfileNeedsUpdate());
|
||||||
scheduledProfileSwitchEventPost = null;
|
scheduledProfileSwitchEventPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1656,5 +1827,67 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------- Insight history handling ---------------
|
||||||
|
|
||||||
|
public void createOrUpdate(InsightHistoryOffset offset) {
|
||||||
|
try {
|
||||||
|
getDaoInsightHistoryOffset().createOrUpdate(offset);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public InsightHistoryOffset getInsightHistoryOffset(String pumpSerial) {
|
||||||
|
try {
|
||||||
|
return getDaoInsightHistoryOffset().queryForId(pumpSerial);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createOrUpdate(InsightBolusID bolusID) {
|
||||||
|
try {
|
||||||
|
getDaoInsightBolusID().createOrUpdate(bolusID);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public InsightBolusID getInsightBolusID(String pumpSerial, int bolusID, long timestamp) {
|
||||||
|
try {
|
||||||
|
return getDaoInsightBolusID().queryBuilder()
|
||||||
|
.where().eq("pumpSerial", pumpSerial)
|
||||||
|
.and().eq("bolusID", bolusID)
|
||||||
|
.and().between("timestamp", timestamp - 259200000, timestamp + 259200000)
|
||||||
|
.queryForFirst();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createOrUpdate(InsightPumpID pumpID) {
|
||||||
|
try {
|
||||||
|
getDaoInsightPumpID().createOrUpdate(pumpID);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public InsightPumpID getPumpStoppedEvent(String pumpSerial, long before) {
|
||||||
|
try {
|
||||||
|
return getDaoInsightPumpID().queryBuilder()
|
||||||
|
.orderBy("timestamp", false)
|
||||||
|
.where().eq("pumpSerial", pumpSerial)
|
||||||
|
.and().in("eventType", "PumpStopped", "PumpPaused")
|
||||||
|
.and().lt("timestamp", before)
|
||||||
|
.queryForFirst();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- Food handling ---------------
|
// ---------------- Food handling ---------------
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
public interface DbObjectBase {
|
||||||
|
|
||||||
|
long getDate();
|
||||||
|
|
||||||
|
long getPumpId();
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,6 @@ 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.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -19,17 +18,19 @@ import java.util.Objects;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
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.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
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.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 21.05.2017.
|
* Created by mike on 21.05.2017.
|
||||||
|
@ -220,7 +221,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
IobTotal result = new IobTotal(time);
|
IobTotal result = new IobTotal(time);
|
||||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||||
|
|
||||||
int realDuration = getDurationToTime(time);
|
double realDuration = getDurationToTime(time);
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
double dia_ago = time - dia * 60 * 60 * 1000;
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
|
@ -248,6 +249,56 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||||
|
IobTotal result = new IobTotal(time);
|
||||||
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||||
|
|
||||||
|
double realDuration = getDurationToTime(time);
|
||||||
|
double netBasalAmount = 0d;
|
||||||
|
|
||||||
|
double sensitivityRatio = lastAutosensResult.ratio;
|
||||||
|
double normalTarget = 100;
|
||||||
|
|
||||||
|
if (exercise_mode && isTempTarget && profile.getTarget() >= normalTarget + 5) {
|
||||||
|
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||||
|
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||||
|
double c = half_basal_exercise_target - normalTarget;
|
||||||
|
sensitivityRatio = c / (c + profile.getTarget() - normalTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (realDuration > 0) {
|
||||||
|
double netBasalRate;
|
||||||
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
|
double spacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
|
||||||
|
for (long j = 0L; j < aboutFiveMinIntervals; j++) {
|
||||||
|
// find middle of the interval
|
||||||
|
long calcdate = (long) (date + j * spacing * 60 * 1000 + 0.5d * spacing * 60 * 1000);
|
||||||
|
|
||||||
|
double basalRate = profile.getBasal(calcdate);
|
||||||
|
double basalRateCorrection = basalRate * (sensitivityRatio - 1);
|
||||||
|
|
||||||
|
|
||||||
|
netBasalRate = absoluteRate() - basalRateCorrection;
|
||||||
|
|
||||||
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
|
double tempBolusSize = netBasalRate * spacing / 60d;
|
||||||
|
|
||||||
|
Treatment tempBolusPart = new Treatment();
|
||||||
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, dia);
|
||||||
|
result.iob += aIOB.iobContrib;
|
||||||
|
result.activity += aIOB.activityContrib;
|
||||||
|
result.extendedBolusInsulin += tempBolusPart.insulin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRealDuration() {
|
public int getRealDuration() {
|
||||||
return getDurationToTime(System.currentTimeMillis());
|
return getDurationToTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package info.nightscout.androidaps.db;
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
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.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -19,14 +20,16 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES)
|
||||||
public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
|
@ -79,12 +82,12 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileSwitch source(int source) {
|
public ProfileSwitch source(int source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileSwitch duration(int duration) {
|
public ProfileSwitch duration(int duration) {
|
||||||
this.durationInMinutes = duration;
|
this.durationInMinutes = duration;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +107,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
/**
|
/**
|
||||||
* Note: the name returned here is used as the PS name when uploading to NS. When such a PS is retrieved
|
* Note: the name returned here is used as the PS name when uploading to NS. When such a PS is retrieved
|
||||||
* again from NS, the added parts must be removed again, see
|
* again from NS, the added parts must be removed again, see
|
||||||
* {@link info.nightscout.utils.PercentageSplitter#pureName}
|
* {@link info.nightscout.androidaps.utils.PercentageSplitter#pureName}
|
||||||
*/
|
*/
|
||||||
public String getCustomizedName() {
|
public String getCustomizedName() {
|
||||||
String name = profileName;
|
String name = profileName;
|
||||||
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
|
if (LocalProfilePlugin.LOCAL_PROFILE.equals(name)) {
|
||||||
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
|
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
|
||||||
}
|
}
|
||||||
if (isCPP) {
|
if (isCPP) {
|
||||||
|
@ -157,7 +160,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
// -------- Interval interface ---------
|
// -------- Interval interface ---------
|
||||||
|
|
||||||
Long cuttedEnd = null;
|
private Long cuttedEnd = null;
|
||||||
|
|
||||||
public long durationInMsec() {
|
public long durationInMsec() {
|
||||||
return durationInMinutes * 60 * 1000L;
|
return durationInMinutes * 60 * 1000L;
|
||||||
|
@ -213,16 +216,17 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
|
|
||||||
boolean isValid = getProfileObject() != null && getProfileObject().isValid(DateUtil.dateAndTimeString(date));
|
boolean isValid = getProfileObject() != null && getProfileObject().isValid(DateUtil.dateAndTimeString(date));
|
||||||
if (!isValid)
|
ProfileSwitch active = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
||||||
|
long activeProfileSwitchDate = active != null ? active.date : -1L;
|
||||||
|
if (!isValid && date == activeProfileSwitchDate)
|
||||||
createNotificationInvalidProfile(DateUtil.dateAndTimeString(date));
|
createNotificationInvalidProfile(DateUtil.dateAndTimeString(date));
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createNotificationInvalidProfile(String detail) {
|
private void createNotificationInvalidProfile(String detail) {
|
||||||
Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, String.format(MainApp.gs(R.string.zerovalueinprofile), detail), Notification.LOW, 5);
|
Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, String.format(MainApp.gs(R.string.zerovalueinprofile), detail), Notification.LOW, 5);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEvent5minBack(List<ProfileSwitch> list, long time, boolean zeroDurationOnly) {
|
public static boolean isEvent5minBack(List<ProfileSwitch> list, long time, boolean zeroDurationOnly) {
|
||||||
|
@ -291,6 +295,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
return Color.CYAN;
|
return Color.CYAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProfileSwitch{" +
|
return "ProfileSwitch{" +
|
||||||
"date=" + date +
|
"date=" + date +
|
||||||
|
|
|
@ -6,9 +6,8 @@ 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.Objects;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 20.09.2017.
|
* Created by mike on 20.09.2017.
|
||||||
|
@ -45,4 +44,16 @@ public class TDD {
|
||||||
this.basal = basal;
|
this.basal = basal;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TDD [" +
|
||||||
|
"date=" + date +
|
||||||
|
"date(str)=" + DateTimeUtil.toStringFromTimeInMillis(date) +
|
||||||
|
", bolus=" + bolus +
|
||||||
|
", basal=" + basal +
|
||||||
|
", total=" + total +
|
||||||
|
']';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,16 @@ 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.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
||||||
public class TempTarget implements Interval {
|
public class TempTarget implements Interval {
|
||||||
|
@ -192,4 +194,11 @@ public class TempTarget implements Interval {
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String friendlyDescription(String units) {
|
||||||
|
return Profile.toTargetRangeString(low, high, Constants.MGDL, units) +
|
||||||
|
units +
|
||||||
|
"@" + MainApp.gs(R.string.mins, durationInMinutes) +
|
||||||
|
(reason != null && !reason.equals("") ? "(" + reason + ")" : "");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
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.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
@ -16,19 +15,20 @@ 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.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 21.05.2017.
|
* Created by mike on 21.05.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
||||||
public class TemporaryBasal implements Interval {
|
public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
|
@ -157,6 +157,14 @@ public class TemporaryBasal implements Interval {
|
||||||
netExtendedRate = t.netExtendedRate;
|
netExtendedRate = t.netExtendedRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void copyFromPump(TemporaryBasal t) {
|
||||||
|
durationInMinutes = t.durationInMinutes;
|
||||||
|
isAbsolute = t.isAbsolute;
|
||||||
|
percentRate = t.percentRate;
|
||||||
|
absoluteRate = t.absoluteRate;
|
||||||
|
pumpId = t.pumpId;
|
||||||
|
}
|
||||||
|
|
||||||
// -------- Interval interface ---------
|
// -------- Interval interface ---------
|
||||||
|
|
||||||
Long cuttedEnd = null;
|
Long cuttedEnd = null;
|
||||||
|
@ -234,7 +242,7 @@ public class TemporaryBasal implements Interval {
|
||||||
double netBasalAmount = 0d;
|
double netBasalAmount = 0d;
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
double netBasalRate = 0d;
|
double netBasalRate;
|
||||||
double dia = profile.getDia();
|
double dia = profile.getDia();
|
||||||
double dia_ago = time - dia * 60 * 60 * 1000;
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
|
@ -244,10 +252,8 @@ public class TemporaryBasal implements Interval {
|
||||||
// find middle of the interval
|
// find middle of the interval
|
||||||
long calcdate = (long) (date + j * tempBolusSpacing * 60 * 1000 + 0.5d * tempBolusSpacing * 60 * 1000);
|
long calcdate = (long) (date + j * tempBolusSpacing * 60 * 1000 + 0.5d * tempBolusSpacing * 60 * 1000);
|
||||||
|
|
||||||
Double basalRate = profile.getBasal(calcdate);
|
double basalRate = profile.getBasal(calcdate);
|
||||||
|
|
||||||
if (basalRate == null)
|
|
||||||
continue;
|
|
||||||
if (isAbsolute) {
|
if (isAbsolute) {
|
||||||
netBasalRate = absoluteRate - basalRate;
|
netBasalRate = absoluteRate - basalRate;
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,6 +283,73 @@ public class TemporaryBasal implements Interval {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||||
|
|
||||||
|
if (isFakeExtended) {
|
||||||
|
log.error("iobCalc should only be called on Extended boluses separately");
|
||||||
|
return new IobTotal(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
IobTotal result = new IobTotal(time);
|
||||||
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||||
|
|
||||||
|
double realDuration = getDurationToTime(time);
|
||||||
|
double netBasalAmount = 0d;
|
||||||
|
|
||||||
|
double sensitivityRatio = lastAutosensResult.ratio;
|
||||||
|
double normalTarget = 100;
|
||||||
|
|
||||||
|
if (exercise_mode && isTempTarget && profile.getTarget() >= normalTarget + 5) {
|
||||||
|
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||||
|
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||||
|
double c = half_basal_exercise_target - normalTarget;
|
||||||
|
sensitivityRatio = c / (c + profile.getTarget() - normalTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (realDuration > 0) {
|
||||||
|
double netBasalRate;
|
||||||
|
double dia = profile.getDia();
|
||||||
|
double dia_ago = time - dia * 60 * 60 * 1000;
|
||||||
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
|
double tempBolusSpacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
|
||||||
|
for (long j = 0L; j < aboutFiveMinIntervals; j++) {
|
||||||
|
// find middle of the interval
|
||||||
|
long calcdate = (long) (date + j * tempBolusSpacing * 60 * 1000 + 0.5d * tempBolusSpacing * 60 * 1000);
|
||||||
|
|
||||||
|
double basalRate = profile.getBasal(calcdate);
|
||||||
|
basalRate *= sensitivityRatio;
|
||||||
|
|
||||||
|
if (isAbsolute) {
|
||||||
|
netBasalRate = absoluteRate - basalRate;
|
||||||
|
} else {
|
||||||
|
double abs = percentRate / 100d * profile.getBasal(calcdate);
|
||||||
|
netBasalRate = abs - basalRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
|
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
||||||
|
netBasalAmount += tempBolusSize;
|
||||||
|
|
||||||
|
Treatment tempBolusPart = new Treatment();
|
||||||
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, dia);
|
||||||
|
result.basaliob += aIOB.iobContrib;
|
||||||
|
result.activity += aIOB.activityContrib;
|
||||||
|
result.netbasalinsulin += tempBolusPart.insulin;
|
||||||
|
if (tempBolusPart.insulin > 0) {
|
||||||
|
result.hightempinsulin += tempBolusPart.insulin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.netRatio = netBasalRate; // ratio at the end of interval
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.netInsulin = netBasalAmount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRealDuration() {
|
public int getRealDuration() {
|
||||||
return getDurationToTime(System.currentTimeMillis());
|
return getDurationToTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -332,8 +405,10 @@ public class TemporaryBasal implements Interval {
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
|
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
if (profile == null)
|
||||||
|
return "null";
|
||||||
Double currentBasalRate = profile.getBasal();
|
Double currentBasalRate = profile.getBasal();
|
||||||
double rate = (currentBasalRate == null) ? 0d : (currentBasalRate + netExtendedRate);
|
double rate = currentBasalRate + netExtendedRate;
|
||||||
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h (" + DecimalFormatter.to2Decimal(netExtendedRate) + "E) @" +
|
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h (" + DecimalFormatter.to2Decimal(netExtendedRate) + "E) @" +
|
||||||
DateUtil.timeString(date) +
|
DateUtil.timeString(date) +
|
||||||
" " + getRealDuration() + "/" + durationInMinutes + "'";
|
" " + getRealDuration() + "/" + durationInMinutes + "'";
|
||||||
|
@ -351,12 +426,14 @@ public class TemporaryBasal implements Interval {
|
||||||
public String toStringShort() {
|
public String toStringShort() {
|
||||||
if (isAbsolute || isFakeExtended) {
|
if (isAbsolute || isFakeExtended) {
|
||||||
|
|
||||||
double rate = 0d;
|
double rate;
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
Double currentBasalRate = profile.getBasal();
|
if (profile == null)
|
||||||
rate = (currentBasalRate == null) ? 0d : (currentBasalRate + netExtendedRate);
|
return "null";
|
||||||
} else if (isAbsolute) {
|
double currentBasalRate = profile.getBasal();
|
||||||
|
rate = currentBasalRate + netExtendedRate;
|
||||||
|
} else {
|
||||||
rate = absoluteRate;
|
rate = absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,24 +453,25 @@ public class TemporaryBasal implements Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCalcuatedPercentageIfNeeded() {
|
private String getCalcuatedPercentageIfNeeded() {
|
||||||
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
return "null";
|
||||||
|
|
||||||
if (isAbsolute || isFakeExtended) {
|
if (isAbsolute || isFakeExtended) {
|
||||||
|
|
||||||
double rate = 0d;
|
double rate;
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
double currentBasalRate = profile.getBasal();
|
||||||
Double currentBasalRate = profile.getBasal();
|
rate = currentBasalRate + netExtendedRate;
|
||||||
rate = (currentBasalRate == null) ? 0d : (currentBasalRate + netExtendedRate);
|
} else {
|
||||||
} else if (isAbsolute) {
|
|
||||||
rate = absoluteRate;
|
rate = absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
double basal = profile.getBasal();
|
||||||
if (profile != null) {
|
if (basal != 0) {
|
||||||
double basal = profile.getBasal();
|
return Math.round(rate * 100d / basal) + "% ";
|
||||||
if (basal != 0) {
|
|
||||||
return Math.round(rate * 100d / basal) + "% ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,14 +479,18 @@ public class TemporaryBasal implements Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toStringVeryShort() {
|
public String toStringVeryShort() {
|
||||||
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
return "null";
|
||||||
|
|
||||||
if (isAbsolute || isFakeExtended) {
|
if (isAbsolute || isFakeExtended) {
|
||||||
|
|
||||||
double rate = 0d;
|
double rate;
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
double currentBasalRate = profile.getBasal();
|
||||||
Double currentBasalRate = profile.getBasal();
|
rate = currentBasalRate + netExtendedRate;
|
||||||
rate = (currentBasalRate == null) ? 0d : (currentBasalRate + netExtendedRate);
|
} else {
|
||||||
} else if (isAbsolute) {
|
|
||||||
rate = absoluteRate;
|
rate = absoluteRate;
|
||||||
}
|
}
|
||||||
return DecimalFormatter.to2Decimal(rate) + "U/h ";
|
return DecimalFormatter.to2Decimal(rate) + "U/h ";
|
||||||
|
@ -417,4 +499,13 @@ public class TemporaryBasal implements Interval {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDate() {
|
||||||
|
return this.date;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getPumpId() {
|
||||||
|
return this.pumpId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/** Base class for all events posted on the event bus. */
|
|
||||||
public abstract class Event {
|
|
||||||
static {
|
|
||||||
ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return ReflectionToStringBuilder.toString(this);
|
|
||||||
}
|
|
||||||
}
|
|
18
app/src/main/java/info/nightscout/androidaps/events/Event.kt
Normal file
18
app/src/main/java/info/nightscout/androidaps/events/Event.kt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ReflectionToStringBuilder
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle
|
||||||
|
|
||||||
|
/** Base class for all events posted on the event bus. */
|
||||||
|
abstract class Event {
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return ReflectionToStringBuilder.toString(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
init {
|
||||||
|
ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/** Base class for events to update the UI, mostly a specific tab. */
|
|
||||||
public class EventAcceptOpenLoopChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventAcceptOpenLoopChange : Event()
|
|
@ -1,7 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 07.07.2016.
|
|
||||||
*/
|
|
||||||
public class EventAppExit extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventAppExit : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 23.01.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventAppInitialized extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventAppInitialized : Event()
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 07/02/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventBolusRequested extends Event {
|
|
||||||
private double amount;
|
|
||||||
|
|
||||||
public EventBolusRequested (double amount){
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAmount(double amount) {
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventBolusRequested(var amount: Double) : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 25.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventCareportalEventChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventCareportalEventChange : Event()
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
public class EventChargingState {
|
|
||||||
|
|
||||||
public boolean isCharging = false;
|
|
||||||
|
|
||||||
public EventChargingState() {}
|
|
||||||
|
|
||||||
public EventChargingState(boolean isCharging) {
|
|
||||||
this.isCharging = isCharging;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventChargingState(val isCharging: Boolean) : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 17.02.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventConfigBuilderChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventConfigBuilderChange : Event()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventCustomActionsChanged : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 13.02.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventCustomCalculationFinished extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventCustomCalculationFinished : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 15.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventExtendedBolusChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventExtendedBolusChange : EventLoop()
|
|
@ -1,36 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by jamorham on 07/02/2018.
|
|
||||||
*
|
|
||||||
* Event to indicate that an app feature is being used, for example bolus wizard being opened
|
|
||||||
*
|
|
||||||
* The purpose this has been created for is to enable opportunistic connection to the pump
|
|
||||||
* so that it is already connected before the user wishes to enact a pump function
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventFeatureRunning extends Event {
|
|
||||||
|
|
||||||
private Feature feature = Feature.UNKNOWN;
|
|
||||||
|
|
||||||
public EventFeatureRunning() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventFeatureRunning(Feature feature) {
|
|
||||||
this.feature = feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Feature getFeature() {
|
|
||||||
return feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Feature {
|
|
||||||
UNKNOWN,
|
|
||||||
MAIN,
|
|
||||||
WIZARD,
|
|
||||||
|
|
||||||
JUST_ADD_MORE_HERE
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.09.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventFoodDatabaseChanged extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventFoodDatabaseChanged : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 13.12.2016.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventInitializationChanged extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventInitializationChanged : Event()
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import android.location.Location
|
||||||
|
|
||||||
|
class EventLocationChange(var location: Location) : Event()
|
|
@ -1,5 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
|
||||||
public abstract class EventLoop extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
||||||
|
abstract class EventLoop : Event()
|
|
@ -1,17 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
|
|
||||||
import info.nightscout.utils.StringUtils;
|
|
||||||
|
|
||||||
public class EventNetworkChange extends Event {
|
|
||||||
|
|
||||||
public boolean mobileConnected = false;
|
|
||||||
public boolean wifiConnected = false;
|
|
||||||
|
|
||||||
public String ssid = "";
|
|
||||||
public boolean roaming = false;
|
|
||||||
|
|
||||||
public String getSsid() {
|
|
||||||
return StringUtils.removeSurroundingQuotes(ssid);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.utils.StringUtils
|
||||||
|
|
||||||
|
class EventNetworkChange : Event() {
|
||||||
|
|
||||||
|
var mobileConnected = false
|
||||||
|
var wifiConnected = false
|
||||||
|
|
||||||
|
var ssid = ""
|
||||||
|
var roaming = false
|
||||||
|
|
||||||
|
fun connectedSsid(): String {
|
||||||
|
return StringUtils.removeSurroundingQuotes(ssid)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 05.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventNewBG extends EventLoop {
|
|
||||||
@Nullable
|
|
||||||
public final BgReading bgReading;
|
|
||||||
|
|
||||||
public EventNewBG(BgReading bgReading) {
|
|
||||||
this.bgReading = bgReading;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.db.BgReading
|
||||||
|
|
||||||
|
class EventNewBG(val bgReading: BgReading?) : EventLoop()
|
|
@ -1,7 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 04.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventNewBasalProfile extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventNewBasalProfile : Event()
|
|
@ -1,35 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event which is published with data fetched from NightScout specific for the
|
|
||||||
* Food-class.
|
|
||||||
*
|
|
||||||
* Payload is the from NS retrieved JSON-String which should be handled by all
|
|
||||||
* subscriber.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventNsFood 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 Bundle payload;
|
|
||||||
|
|
||||||
public EventNsFood(int mode, Bundle payload) {
|
|
||||||
this.mode = mode;
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMode() {
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bundle getPayload() {
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event which is published with data fetched from NightScout specific for the
|
||||||
|
* Food-class.
|
||||||
|
*
|
||||||
|
* Payload is the from NS retrieved JSON-String which should be handled by all
|
||||||
|
* subscriber.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class EventNsFood(val mode: Int, val payload: Bundle) : Event() {
|
||||||
|
companion object {
|
||||||
|
val ADD = 0
|
||||||
|
val UPDATE = 1
|
||||||
|
val REMOVE = 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event which is published with data fetched from NightScout specific for the
|
||||||
|
* Treatment-class.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Payload is the from NS retrieved JSON-String which should be handled by all
|
||||||
|
* subscriber.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class EventNsTreatment(val mode: Int, val payload: JSONObject) : Event() {
|
||||||
|
companion object {
|
||||||
|
val ADD = 0
|
||||||
|
val UPDATE = 1
|
||||||
|
val REMOVE = 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,25 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 19.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventPreferenceChange extends Event {
|
|
||||||
public String changedKey;
|
|
||||||
public EventPreferenceChange(String key) {
|
|
||||||
changedKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPreferenceChange(int resourceID) {
|
|
||||||
changedKey = MainApp.gs(resourceID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChanged(int id) {
|
|
||||||
return changedKey.equals(MainApp.gs(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChanged(String id) {
|
|
||||||
return changedKey.equals(id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
|
||||||
|
class EventPreferenceChange : Event {
|
||||||
|
private var changedKey: String? = null
|
||||||
|
|
||||||
|
constructor(key: String) {
|
||||||
|
changedKey = key
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(resourceID: Int) {
|
||||||
|
changedKey = MainApp.gs(resourceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isChanged(id: Int): Boolean {
|
||||||
|
return changedKey == MainApp.gs(id)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventProfileNeedsUpdate : Event()
|
|
@ -1,4 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
public class EventProfileStoreChanged extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventProfileStoreChanged : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 02.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventProfileSwitchChange extends Event {
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 19.02.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventPumpStatusChanged extends Event {
|
|
||||||
public static final int CONNECTING = 0;
|
|
||||||
public static final int CONNECTED = 1;
|
|
||||||
public static final int HANDSHAKING = 2;
|
|
||||||
public static final int PERFORMING = 3;
|
|
||||||
public static final int DISCONNECTING = 4;
|
|
||||||
public static final int DISCONNECTED = 5;
|
|
||||||
|
|
||||||
public int sStatus = DISCONNECTED;
|
|
||||||
public int sSecondsElapsed = 0;
|
|
||||||
public String sPerfomingAction = "";
|
|
||||||
|
|
||||||
public static String error = "";
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
error = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status, int secondsElapsed) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
error = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status, String error) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(String action) {
|
|
||||||
sStatus = PERFORMING;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
sPerfomingAction = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String textStatus() {
|
|
||||||
if (sStatus == CONNECTING)
|
|
||||||
return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed);
|
|
||||||
else if (sStatus == HANDSHAKING)
|
|
||||||
return MainApp.gs(R.string.handshaking);
|
|
||||||
else if (sStatus == CONNECTED)
|
|
||||||
return MainApp.gs(R.string.connected);
|
|
||||||
else if (sStatus == PERFORMING)
|
|
||||||
return sPerfomingAction;
|
|
||||||
else if (sStatus == DISCONNECTING)
|
|
||||||
return MainApp.gs(R.string.disconnecting);
|
|
||||||
else if (sStatus == DISCONNECTED)
|
|
||||||
return "";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
class EventPumpStatusChanged : EventStatus {
|
||||||
|
|
||||||
|
enum class Status {
|
||||||
|
CONNECTING,
|
||||||
|
CONNECTED,
|
||||||
|
HANDSHAKING,
|
||||||
|
PERFORMING,
|
||||||
|
DISCONNECTING,
|
||||||
|
DISCONNECTED
|
||||||
|
}
|
||||||
|
|
||||||
|
var sStatus: Status = Status.DISCONNECTED
|
||||||
|
var sSecondsElapsed = 0
|
||||||
|
var sPerfomingAction = ""
|
||||||
|
var error = ""
|
||||||
|
|
||||||
|
constructor(status: Status) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
error = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(status: Status, secondsElapsed: Int) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = secondsElapsed
|
||||||
|
error = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(status: Status, error: String) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
this.error = error
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(action: String) {
|
||||||
|
sStatus = Status.PERFORMING
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
sPerfomingAction = action
|
||||||
|
}
|
||||||
|
|
||||||
|
// status for startup wizard
|
||||||
|
override fun getStatus(): String {
|
||||||
|
if (sStatus == Status.CONNECTING)
|
||||||
|
return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed)
|
||||||
|
else if (sStatus == Status.HANDSHAKING)
|
||||||
|
return MainApp.gs(R.string.handshaking)
|
||||||
|
else if (sStatus == Status.CONNECTED)
|
||||||
|
return MainApp.gs(R.string.connected)
|
||||||
|
else if (sStatus == Status.PERFORMING)
|
||||||
|
return sPerfomingAction
|
||||||
|
else if (sStatus == Status.DISCONNECTING)
|
||||||
|
return MainApp.gs(R.string.disconnecting)
|
||||||
|
else if (sStatus == Status.DISCONNECTED)
|
||||||
|
return ""
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventRebuildTabs @JvmOverloads constructor(var recreate: Boolean = false) : Event()
|
|
@ -1,14 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 13.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventRefreshGui extends Event {
|
|
||||||
public boolean recreate = false;
|
|
||||||
public EventRefreshGui(boolean recreate) {
|
|
||||||
this.recreate = recreate;
|
|
||||||
}
|
|
||||||
public EventRefreshGui(){
|
|
||||||
this(false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 16.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventRefreshOverview extends Event {
|
|
||||||
public String from;
|
|
||||||
|
|
||||||
public EventRefreshOverview(String from) {
|
|
||||||
this.from = from;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventRefreshOverview(var from: String) : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 12.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadProfileSwitchData extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventReloadProfileSwitchData : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 29.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadTempBasalData extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventReloadTempBasalData : Event()
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 29.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadTreatmentData extends Event {
|
|
||||||
public Object next;
|
|
||||||
|
|
||||||
public EventReloadTreatmentData(Object next) {
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue