Merge branch 'dev' of github.com:MilosKozak/AndroidAPS into skip-neutral-temps
This commit is contained in:
commit
81ea43b218
1354 changed files with 32834 additions and 19587 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,7 +8,6 @@
|
||||||
build/
|
build/
|
||||||
.idea/*
|
.idea/*
|
||||||
!.idea/codeStyles/
|
!.idea/codeStyles/
|
||||||
app/src/main/jniLibs
|
|
||||||
full/
|
full/
|
||||||
debug/
|
debug/
|
||||||
release/
|
release/
|
||||||
|
|
|
@ -25,12 +25,10 @@ jacoco {
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
ormLiteVersion = "4.46"
|
|
||||||
powermockVersion = "1.7.3"
|
powermockVersion = "1.7.3"
|
||||||
dexmakerVersion = "1.2"
|
dexmakerVersion = "1.2"
|
||||||
retrofit2Version = '2.8.1'
|
retrofit2Version = '2.8.1'
|
||||||
okhttp3Version = '4.5.0'
|
okhttp3Version = '4.6.0'
|
||||||
coroutinesVersion = '1.3.5'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,11 +124,11 @@ android {
|
||||||
ndkVersion "21.1.6352462"
|
ndkVersion "21.1.6352462"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 23
|
minSdkVersion 24
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
version "2.6.5-dev"
|
version "2.6.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", "REMOTE", '"' + generateGitRemote() + '"'
|
||||||
|
@ -160,6 +158,7 @@ android {
|
||||||
}
|
}
|
||||||
firebaseDisable {
|
firebaseDisable {
|
||||||
System.setProperty("disableFirebase", "true")
|
System.setProperty("disableFirebase", "true")
|
||||||
|
ext.enableCrashlytics = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
@ -242,12 +241,17 @@ allprojects {
|
||||||
dependencies {
|
dependencies {
|
||||||
wearApp project(':wear')
|
wearApp project(':wear')
|
||||||
|
|
||||||
|
implementation project(':core')
|
||||||
|
implementation project(':dana')
|
||||||
|
implementation project(':danars')
|
||||||
|
implementation project(':danar')
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
|
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
|
||||||
implementation "com.google.android.gms:play-services-location:17.0.0"
|
implementation "com.google.android.gms:play-services-location:17.0.0"
|
||||||
implementation 'com.google.firebase:firebase-core:17.3.0'
|
implementation 'com.google.firebase:firebase-core:17.4.0'
|
||||||
implementation 'com.google.firebase:firebase-auth:19.3.0'
|
implementation 'com.google.firebase:firebase-auth:19.3.1'
|
||||||
implementation 'com.google.firebase:firebase-database:19.2.1'
|
implementation 'com.google.firebase:firebase-database:19.3.0'
|
||||||
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
|
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
|
||||||
transitive = true;
|
transitive = true;
|
||||||
}
|
}
|
||||||
|
@ -260,9 +264,11 @@ dependencies {
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||||
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
||||||
implementation "androidx.preference:preference-ktx:1.1.0"
|
implementation "androidx.preference:preference-ktx:1.1.1"
|
||||||
|
implementation "androidx.activity:activity:${activityVersion}"
|
||||||
|
implementation "androidx.activity:activity-ktx:${activityVersion}"
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'com.google.android.material:material:1.1.0'
|
implementation 'com.google.android.material:material:1.1.0'
|
||||||
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
|
|
||||||
|
|
||||||
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
||||||
|
|
||||||
|
@ -271,13 +277,13 @@ dependencies {
|
||||||
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.9"
|
implementation 'org.apache.commons:commons-lang3:3.10'
|
||||||
implementation 'org.slf4j:slf4j-api:1.7.30'
|
implementation 'org.slf4j:slf4j-api:1.7.30'
|
||||||
// Graphview cannot be upgraded
|
// 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.2.2"
|
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
|
||||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||||
|
implementation(name: "com.atech-software.android.library.wizardpager-1.1.1", ext: "aar")
|
||||||
|
|
||||||
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"
|
||||||
|
@ -287,28 +293,28 @@ dependencies {
|
||||||
exclude group: "org.json", module: "json"
|
exclude group: "org.json", module: "json"
|
||||||
}
|
}
|
||||||
implementation "com.google.code.gson:gson:2.8.6"
|
implementation "com.google.code.gson:gson:2.8.6"
|
||||||
implementation ("com.google.guava:guava:24.1-jre") {
|
implementation('com.google.guava:guava:29.0-jre') {
|
||||||
exclude group: "com.google.code.findbugs", module: "jsr305"
|
exclude group: "com.google.code.findbugs", module: "jsr305"
|
||||||
}
|
}
|
||||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
|
|
||||||
implementation "net.danlew:android.joda:2.10.3"
|
implementation 'net.danlew:android.joda:2.10.6'
|
||||||
|
|
||||||
implementation 'org.mozilla:rhino:1.7.11'
|
implementation 'org.mozilla:rhino:1.7.12'
|
||||||
|
|
||||||
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
|
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
|
||||||
|
|
||||||
implementation 'com.github.kenglxn.QRGen:android:2.6.0'
|
implementation 'com.github.kenglxn.QRGen:android:2.6.0'
|
||||||
implementation 'com.eatthepath:java-otp:0.2.0'
|
implementation 'com.eatthepath:java-otp:0.2.0'
|
||||||
|
|
||||||
testImplementation "junit:junit:4.12"
|
testImplementation "junit:junit:4.13"
|
||||||
testImplementation "org.json:json:20190722"
|
testImplementation "org.json:json:20190722"
|
||||||
testImplementation "org.mockito:mockito-core:2.8.47"
|
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.10.5"
|
testImplementation 'joda-time:joda-time:2.10.6'
|
||||||
testImplementation('com.google.truth:truth:1.0.1') {
|
testImplementation('com.google.truth:truth:1.0.1') {
|
||||||
exclude group: "com.google.guava", module: "guava"
|
exclude group: "com.google.guava", module: "guava"
|
||||||
exclude group: "com.google.code.findbugs", module: "jsr305"
|
exclude group: "com.google.code.findbugs", module: "jsr305"
|
||||||
|
@ -329,52 +335,28 @@ dependencies {
|
||||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit2Version"
|
implementation "com.squareup.retrofit2:converter-gson:$retrofit2Version"
|
||||||
|
|
||||||
// Phone checker
|
// Phone checker
|
||||||
implementation 'com.scottyab:rootbeer-lib:0.0.7'
|
implementation 'com.scottyab:rootbeer-lib:0.0.8'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0-alpha03'
|
androidTestImplementation 'androidx.test:rules:1.3.0-beta01'
|
||||||
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2'
|
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
|
|
||||||
/* Dagger2 - We are going to use dagger.android which includes
|
/* Dagger2 - We are going to use dagger.android which includes
|
||||||
* support for Activity and fragment injection so we need to include
|
* support for Activity and fragment injection so we need to include
|
||||||
* the following dependencies */
|
* the following dependencies */
|
||||||
implementation 'com.google.dagger:dagger-android:2.25.2'
|
implementation "com.google.dagger:dagger-android:$dagger_version"
|
||||||
implementation 'com.google.dagger:dagger-android-support:2.25.2'
|
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.25.2'
|
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
||||||
annotationProcessor 'com.google.dagger:dagger-android-processor:2.25.2'
|
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||||
kapt 'com.google.dagger:dagger-android-processor:2.25.2'
|
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||||
|
|
||||||
/* Dagger2 - default dependency */
|
/* Dagger2 - default dependency */
|
||||||
kapt 'com.google.dagger:dagger-compiler:2.25.2'
|
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
task copyLibs(dependsOn: downloadAndUnzipFile, type: Copy) {
|
|
||||||
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
|
|
||||||
def target = file("src/main/jniLibs/")
|
|
||||||
|
|
||||||
from src
|
|
||||||
into target
|
|
||||||
}
|
|
||||||
|
|
||||||
task full_clean(type: Delete) {
|
|
||||||
delete file("src/main/jniLibs")
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
// Run 'adb' shell command to clear application data of main app for 'debug' variant
|
// Run 'adb' shell command to clear application data of main app for 'debug' variant
|
||||||
task clearMainAppData(type: Exec) {
|
task clearMainAppData(type: Exec) {
|
||||||
|
@ -406,8 +388,6 @@ tasks.whenTaskAdded { task ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
clean.dependsOn full_clean
|
|
||||||
preBuild.dependsOn copyLibs
|
|
||||||
|
|
||||||
printf('--------------\n')
|
printf('--------------\n')
|
||||||
printf('isMaster: %s\n', isMaster().toString())
|
printf('isMaster: %s\n', isMaster().toString())
|
||||||
|
|
Binary file not shown.
|
@ -8,16 +8,15 @@ import androidx.test.rule.GrantPermissionRule
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.logging.L
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
|
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.androidaps.plugins.source.RandomBgPlugin
|
import info.nightscout.androidaps.plugins.source.RandomBgPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
@ -30,7 +29,6 @@ import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
|
@ -44,7 +42,7 @@ class RealPumpTest {
|
||||||
|
|
||||||
private val validProfile = "{\"dia\":\"6\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"10\"},{\"time\":\"2:00\",\"value\":\"11\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"0.1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
private val validProfile = "{\"dia\":\"6\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"10\"},{\"time\":\"2:00\",\"value\":\"11\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"0.1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
||||||
|
|
||||||
@Inject lateinit var pump : DanaRv2Plugin
|
@Inject lateinit var pump : info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
@Inject lateinit var randomBgPlugin :RandomBgPlugin
|
@Inject lateinit var randomBgPlugin :RandomBgPlugin
|
||||||
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
|
|
@ -58,15 +58,6 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activities.PreferencesActivity" />
|
<activity android:name=".activities.PreferencesActivity" />
|
||||||
<activity
|
|
||||||
android:name=".activities.BolusProgressHelperActivity"
|
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
|
||||||
<activity
|
|
||||||
android:name=".activities.ErrorHelperActivity"
|
|
||||||
android:theme="@style/Theme.AppCompat.Translucent" />
|
|
||||||
<activity android:name=".plugins.pump.danaR.activities.DanaRHistoryActivity" />
|
|
||||||
<activity android:name=".plugins.pump.danaR.activities.DanaRUserOptionsActivity" />
|
|
||||||
<activity android:name=".activities.TDDStatsActivity" />
|
|
||||||
<activity android:name=".plugins.general.overview.activities.QuickWizardListActivity">
|
<activity android:name=".plugins.general.overview.activities.QuickWizardListActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity" />
|
||||||
|
@ -74,14 +65,7 @@
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".plugins.pump.danaRS.activities.BLEScanActivity">
|
<activity android:name=".plugins.general.maintenance.activities.PrefImportListActivity" />
|
||||||
<intent-filter>
|
|
||||||
<action android:name="info.nightscout.androidaps.plugins.PumpDanaRS.activities.BLEScanActivity" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity android:name=".plugins.pump.danaRS.activities.PairingHelperActivity" />
|
|
||||||
<activity android:name=".historyBrowser.HistoryBrowseActivity" />
|
<activity android:name=".historyBrowser.HistoryBrowseActivity" />
|
||||||
<activity android:name=".activities.SurveyActivity" />
|
<activity android:name=".activities.SurveyActivity" />
|
||||||
<activity android:name=".activities.StatsActivity" />
|
<activity android:name=".activities.StatsActivity" />
|
||||||
|
@ -148,22 +132,6 @@
|
||||||
<service
|
<service
|
||||||
android:name=".services.LocationService"
|
android:name=".services.LocationService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<service
|
|
||||||
android:name=".plugins.pump.danaR.services.DanaRExecutionService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="false" />
|
|
||||||
<service
|
|
||||||
android:name=".plugins.pump.danaRKorean.services.DanaRKoreanExecutionService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="false" />
|
|
||||||
<service
|
|
||||||
android:name=".plugins.pump.danaRv2.services.DanaRv2ExecutionService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="false" />
|
|
||||||
<service
|
|
||||||
android:name=".plugins.pump.danaRS.services.DanaRSService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="true" />
|
|
||||||
<service
|
<service
|
||||||
android:name=".plugins.general.wear.wearintegration.WatchUpdaterService"
|
android:name=".plugins.general.wear.wearintegration.WatchUpdaterService"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
@ -299,6 +267,17 @@
|
||||||
|
|
||||||
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
||||||
|
|
||||||
|
<!-- Omnipod service and activities -->
|
||||||
|
<service
|
||||||
|
android:name=".plugins.pump.omnipod.service.RileyLinkOmnipodService"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true" />
|
||||||
|
|
||||||
|
<activity android:name=".plugins.pump.omnipod.dialogs.PodManagementActivity" />
|
||||||
|
<activity android:name=".plugins.pump.omnipod.dialogs.PodHistoryActivity" />
|
||||||
|
<activity android:name="com.atech.android.library.wizardpager.WizardPagerActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package info.nightscout.androidaps;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 07.06.2016.
|
|
||||||
*/
|
|
||||||
public class Config {
|
|
||||||
public static int SUPPORTEDNSVERSION = 1002; // 0.10.00
|
|
||||||
|
|
||||||
public static final boolean APS = BuildConfig.FLAVOR.equals("full");
|
|
||||||
|
|
||||||
public static final boolean NSCLIENT = BuildConfig.FLAVOR.equals("nsclient") || BuildConfig.FLAVOR.equals("nsclient2");
|
|
||||||
public static final boolean PUMPCONTROL = BuildConfig.FLAVOR.equals("pumpcontrol");
|
|
||||||
|
|
||||||
public static final boolean PUMPDRIVERS = BuildConfig.FLAVOR.equals("full") || BuildConfig.FLAVOR.equals("pumpcontrol");
|
|
||||||
}
|
|
15
app/src/main/java/info/nightscout/androidaps/Config.kt
Normal file
15
app/src/main/java/info/nightscout/androidaps/Config.kt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package info.nightscout.androidaps
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.ConfigInterface
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class Config @Inject constructor(): ConfigInterface{
|
||||||
|
|
||||||
|
override val SUPPORTEDNSVERSION = 1002 // 0.10.00
|
||||||
|
override val APS = BuildConfig.FLAVOR == "full"
|
||||||
|
override val NSCLIENT = BuildConfig.FLAVOR == "nsclient" || BuildConfig.FLAVOR == "nsclient2"
|
||||||
|
override val PUMPCONTROL = BuildConfig.FLAVOR == "pumpcontrol"
|
||||||
|
override val PUMPDRIVERS = BuildConfig.FLAVOR == "full" || BuildConfig.FLAVOR == "pumpcontrol"
|
||||||
|
}
|
|
@ -41,11 +41,12 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||||
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission
|
import info.nightscout.androidaps.utils.AndroidPermission
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper
|
import info.nightscout.androidaps.utils.LocaleHelper
|
||||||
|
@ -53,11 +54,15 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
|
import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.resources.IconsProvider
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
||||||
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
@ -77,6 +82,10 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
@Inject lateinit var iconsProvider: IconsProvider
|
||||||
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
|
||||||
|
@Inject lateinit var config: Config
|
||||||
|
|
||||||
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
|
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
|
||||||
private var pluginPreferencesMenuItem: MenuItem? = null
|
private var pluginPreferencesMenuItem: MenuItem? = null
|
||||||
|
@ -107,7 +116,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
//Check here if loop plugin is disabled. Else check via constraints
|
//Check here if loop plugin is disabled. Else check via constraints
|
||||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) versionCheckerUtils.triggerCheckVersion()
|
if (!loopPlugin.isEnabled(PluginType.LOOP)) versionCheckerUtils.triggerCheckVersion()
|
||||||
fabricPrivacy.setUserStats()
|
setUserStats()
|
||||||
setupViews()
|
setupViews()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRebuildTabs::class.java)
|
.toObservable(EventRebuildTabs::class.java)
|
||||||
|
@ -129,7 +138,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
androidPermission.notifyForStoragePermission(this)
|
androidPermission.notifyForStoragePermission(this)
|
||||||
androidPermission.notifyForBatteryOptimizationPermission(this)
|
androidPermission.notifyForBatteryOptimizationPermission(this)
|
||||||
if (Config.PUMPDRIVERS) {
|
if (config.PUMPDRIVERS) {
|
||||||
androidPermission.notifyForLocationPermissions(this)
|
androidPermission.notifyForLocationPermissions(this)
|
||||||
androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin)
|
androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin)
|
||||||
androidPermission.notifyForSystemWindowPermissions(this)
|
androidPermission.notifyForSystemWindowPermissions(this)
|
||||||
|
@ -153,12 +162,9 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
||||||
Runnable {
|
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }),
|
||||||
OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() })
|
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) })
|
||||||
},
|
)
|
||||||
Runnable {
|
|
||||||
OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() })
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setWakeLock() {
|
private fun setWakeLock() {
|
||||||
|
@ -190,6 +196,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main_pager.adapter = pageAdapter
|
main_pager.adapter = pageAdapter
|
||||||
|
main_pager.offscreenPageLimit = 8 // This may cause more memory consumption
|
||||||
checkPluginPreferences(main_pager)
|
checkPluginPreferences(main_pager)
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
|
@ -283,7 +290,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS)
|
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS)
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION)
|
.setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION)
|
||||||
.setIcon(resourceHelper.getIcon())
|
.setIcon(iconsProvider.getIcon())
|
||||||
.setMessage(messageSpanned)
|
.setMessage(messageSpanned)
|
||||||
.setPositiveButton(resourceHelper.gs(R.string.ok), null)
|
.setPositiveButton(resourceHelper.gs(R.string.ok), null)
|
||||||
.create().also {
|
.create().also {
|
||||||
|
@ -323,4 +330,35 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
return actionBarDrawerToggle.onOptionsItemSelected(item)
|
return actionBarDrawerToggle.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Correct place for calling setUserStats() would be probably MainApp
|
||||||
|
// but we need to have it called at least once a day. Thus this location
|
||||||
|
|
||||||
|
private fun setUserStats() {
|
||||||
|
if (!fabricPrivacy.fabricEnabled()) return
|
||||||
|
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
|
||||||
|
// Size is limited to 36 chars
|
||||||
|
val remote = BuildConfig.REMOTE.toLowerCase(Locale.getDefault())
|
||||||
|
.replace("https://", "")
|
||||||
|
.replace("http://", "")
|
||||||
|
.replace(".git", "")
|
||||||
|
.replace(".com/", ":")
|
||||||
|
.replace(".org/", ":")
|
||||||
|
.replace(".net/", ":")
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled)
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("Language", sp.getString(R.string.key_language, Locale.getDefault().language))
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("Version", BuildConfig.VERSION)
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("HEAD", BuildConfig.HEAD)
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("Remote", remote)
|
||||||
|
val hashes: List<String> = signatureVerifierPlugin.shortHashes()
|
||||||
|
if (hashes.isNotEmpty()) fabricPrivacy.firebaseAnalytics.setUserProperty("Hash", hashes[0])
|
||||||
|
activePlugin.activePump.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Pump", it::class.java.simpleName) }
|
||||||
|
if (!config.NSCLIENT && !config.PUMPCONTROL)
|
||||||
|
activePlugin.activeAPS.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
|
||||||
|
activePlugin.activeBgSource.let { fabricPrivacy.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
|
||||||
|
fabricPrivacy.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName)
|
||||||
|
activePlugin.activeSensitivity.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
|
||||||
|
activePlugin.activeInsulin.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@ import android.content.res.Resources;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
import androidx.annotation.StringRes;
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
|
@ -21,6 +20,7 @@ import javax.inject.Inject;
|
||||||
import dagger.android.AndroidInjector;
|
import dagger.android.AndroidInjector;
|
||||||
import dagger.android.DaggerApplication;
|
import dagger.android.DaggerApplication;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
import info.nightscout.androidaps.db.StaticInjector;
|
||||||
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
@ -52,11 +52,14 @@ public class MainApp extends DaggerApplication {
|
||||||
@Inject ActivityMonitor activityMonitor;
|
@Inject ActivityMonitor activityMonitor;
|
||||||
@Inject VersionCheckerUtils versionCheckersUtils;
|
@Inject VersionCheckerUtils versionCheckersUtils;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@Inject NSUpload nsUpload;
|
||||||
|
|
||||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||||
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
||||||
@Inject List<PluginBase> plugins;
|
@Inject List<PluginBase> plugins;
|
||||||
|
|
||||||
|
@Inject StaticInjector staticInjector; // TODO avoid , here fake only to initialize
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
@ -92,7 +95,7 @@ public class MainApp extends DaggerApplication {
|
||||||
pluginStore.setPlugins(plugins);
|
pluginStore.setPlugins(plugins);
|
||||||
configBuilderPlugin.initialize();
|
configBuilderPlugin.initialize();
|
||||||
|
|
||||||
NSUpload.uploadAppStart();
|
nsUpload.uploadAppStart();
|
||||||
|
|
||||||
new Thread(() -> keepAliveManager.setAlarm(this)).start();
|
new Thread(() -> keepAliveManager.setAlarm(this)).start();
|
||||||
doMigrations();
|
doMigrations();
|
||||||
|
@ -100,7 +103,6 @@ public class MainApp extends DaggerApplication {
|
||||||
|
|
||||||
|
|
||||||
private void doMigrations() {
|
private void doMigrations() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,6 +113,7 @@ public class MainApp extends DaggerApplication {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private void registerLocalBroadcastReceiver() {
|
private void registerLocalBroadcastReceiver() {
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intents.ACTION_NEW_TREATMENT);
|
filter.addAction(Intents.ACTION_NEW_TREATMENT);
|
||||||
|
@ -145,16 +148,6 @@ public class MainApp extends DaggerApplication {
|
||||||
registerReceiver(new BTReceiver(), filter);
|
registerReceiver(new BTReceiver(), filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String gs(@StringRes int id) {
|
|
||||||
return sResources.getString(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static MainApp instance() {
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DatabaseHelper getDbHelper() {
|
public static DatabaseHelper getDbHelper() {
|
||||||
return sDatabaseHelper;
|
return sDatabaseHelper;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,9 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
|
@ -35,10 +34,10 @@ import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
|
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
|
@ -66,13 +65,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var pluginStore: PluginStore
|
@Inject lateinit var pluginStore: PluginStore
|
||||||
|
@Inject lateinit var config: Config
|
||||||
|
|
||||||
@Inject lateinit var automationPlugin: AutomationPlugin
|
@Inject lateinit var automationPlugin: AutomationPlugin
|
||||||
@Inject lateinit var danaRPlugin: DanaRPlugin
|
@Inject lateinit var danaRPlugin: DanaRPlugin
|
||||||
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||||
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
|
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||||
@Inject lateinit var careportalPlugin: CareportalPlugin
|
|
||||||
@Inject lateinit var comboPlugin: ComboPlugin
|
@Inject lateinit var comboPlugin: ComboPlugin
|
||||||
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
|
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
|
||||||
@Inject lateinit var loopPlugin: LoopPlugin
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@ -100,6 +99,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
@Inject lateinit var passwordCheck: PasswordCheck
|
@Inject lateinit var passwordCheck: PasswordCheck
|
||||||
@Inject lateinit var nsSettingStatus: NSSettingsStatus
|
@Inject lateinit var nsSettingStatus: NSSettingsStatus
|
||||||
|
|
||||||
|
// TODO why?
|
||||||
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||||
|
|
||||||
override fun androidInjector(): AndroidInjector<Any> = androidInjector
|
override fun androidInjector(): AndroidInjector<Any> = androidInjector
|
||||||
|
@ -159,21 +159,20 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
addPreferencesFromResourceIfEnabled(tomatoPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(tomatoPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(careportalPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(loopPlugin, rootKey, config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(loopPlugin, rootKey, Config.APS)
|
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, Config.APS)
|
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS)
|
|
||||||
addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !Config.NSCLIENT)
|
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !config.NSCLIENT)
|
||||||
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
|
||||||
|
@ -279,7 +278,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
for (plugin in pluginStore.plugins) {
|
for (plugin in pluginStore.plugins) {
|
||||||
pref?.let { pref-> pref.getKey()?.let { plugin.updatePreferenceSummary(pref) }}
|
pref?.let { it.key?.let { plugin.updatePreferenceSummary(pref) }}
|
||||||
}
|
}
|
||||||
|
|
||||||
val hmacPasswords = arrayOf(
|
val hmacPasswords = arrayOf(
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.activities
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.ActivityMonitor
|
import info.nightscout.androidaps.utils.ActivityMonitor
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.stats.TddCalculator
|
import info.nightscout.androidaps.utils.stats.TddCalculator
|
||||||
import info.nightscout.androidaps.utils.stats.TirCalculator
|
import info.nightscout.androidaps.utils.stats.TirCalculator
|
||||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.dialogs.ProfileViewerDialog
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.ActivityMonitor
|
import info.nightscout.androidaps.utils.ActivityMonitor
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.InstanceId
|
import info.nightscout.androidaps.utils.InstanceId
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,72 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import com.j256.ormlite.dao.CloseableIterator;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
||||||
|
|
||||||
|
@Inject DatabaseHelperProvider() {}
|
||||||
|
|
||||||
|
@NotNull @Override public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||||
|
return MainApp.getDbHelper().getAllBgreadingsDataFromTime(mills, ascending);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void createOrUpdate(@NotNull CareportalEvent careportalEvent) {
|
||||||
|
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void createOrUpdate(@NotNull DanaRHistoryRecord record) {
|
||||||
|
MainApp.getDbHelper().createOrUpdate(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
|
||||||
|
return MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public List<TDD> getTDDs() {
|
||||||
|
return MainApp.getDbHelper().getTDDs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public long size(@NotNull String table) {
|
||||||
|
return MainApp.getDbHelper().size(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void create(@NotNull DbRequest record) {
|
||||||
|
try {
|
||||||
|
MainApp.getDbHelper().create(record);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void deleteAllDbRequests() {
|
||||||
|
MainApp.getDbHelper().deleteAllDbRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int deleteDbRequest(@NotNull String id) {
|
||||||
|
return MainApp.getDbHelper().deleteDbRequest(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void deleteDbRequestbyMongoId(@NotNull String action, @NotNull String _id) {
|
||||||
|
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public CloseableIterator<DbRequest> getDbRequestInterator() {
|
||||||
|
return MainApp.getDbHelper().getDbRequestInterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public long roundDateToSec(long date) {
|
||||||
|
return MainApp.getDbHelper().roundDateToSec(date);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalAdapterAM
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
|
|
||||||
|
@ -17,12 +17,10 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
abstract class APSModule {
|
abstract class APSModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun loggerCallbackInjector(): LoggerCallback
|
@ContributesAndroidInjector abstract fun loggerCallbackInjector(): LoggerCallback
|
||||||
@ContributesAndroidInjector abstract fun apsResultInjector(): APSResult
|
|
||||||
@ContributesAndroidInjector abstract fun determineBasalResultSMBInjector(): DetermineBasalResultSMB
|
@ContributesAndroidInjector abstract fun determineBasalResultSMBInjector(): DetermineBasalResultSMB
|
||||||
@ContributesAndroidInjector abstract fun determineBasalResultAMAInjector(): DetermineBasalResultAMA
|
@ContributesAndroidInjector abstract fun determineBasalResultAMAInjector(): DetermineBasalResultAMA
|
||||||
@ContributesAndroidInjector abstract fun determineBasalAdapterAMAJSInjector(): DetermineBasalAdapterAMAJS
|
@ContributesAndroidInjector abstract fun determineBasalAdapterAMAJSInjector(): DetermineBasalAdapterAMAJS
|
||||||
@ContributesAndroidInjector abstract fun determineBasalAdapterSMBJSInjector(): DetermineBasalAdapterSMBJS
|
@ContributesAndroidInjector abstract fun determineBasalAdapterSMBJSInjector(): DetermineBasalAdapterSMBJS
|
||||||
@ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensData
|
|
||||||
@ContributesAndroidInjector abstract fun iobCobThreadInjector(): IobCobThread
|
@ContributesAndroidInjector abstract fun iobCobThreadInjector(): IobCobThread
|
||||||
@ContributesAndroidInjector abstract fun iobCobOref1ThreadInjector(): IobCobOref1Thread
|
@ContributesAndroidInjector abstract fun iobCobOref1ThreadInjector(): IobCobOref1Thread
|
||||||
}
|
}
|
|
@ -6,14 +6,11 @@ import info.nightscout.androidaps.MainActivity
|
||||||
import info.nightscout.androidaps.activities.*
|
import info.nightscout.androidaps.activities.*
|
||||||
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity
|
||||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
|
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.activities.BLEScanActivity
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity
|
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
|
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
|
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
|
||||||
|
@ -24,11 +21,6 @@ import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class ActivitiesModule {
|
abstract class ActivitiesModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesBLEScanActivity(): BLEScanActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaRHistoryActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaRUserOptionsActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributeErrorHelperActivity(): ErrorHelperActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributesHistoryBrowseActivity(): HistoryBrowseActivity
|
@ContributesAndroidInjector abstract fun contributesHistoryBrowseActivity(): HistoryBrowseActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightAlertActivity(): InsightAlertActivity
|
@ContributesAndroidInjector abstract fun contributesInsightAlertActivity(): InsightAlertActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightPairingActivity(): InsightPairingActivity
|
@ContributesAndroidInjector abstract fun contributesInsightPairingActivity(): InsightPairingActivity
|
||||||
|
@ -36,7 +28,6 @@ abstract class ActivitiesModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity
|
@ContributesAndroidInjector abstract fun contributesLogSettingActivity(): LogSettingActivity
|
||||||
@ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity
|
@ContributesAndroidInjector abstract fun contributeMainActivity(): MainActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity
|
@ContributesAndroidInjector abstract fun contributesMedtronicHistoryActivity(): MedtronicHistoryActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesPairingHelperActivity(): PairingHelperActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity
|
@ContributesAndroidInjector abstract fun contributesPreferencesActivity(): PreferencesActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity
|
@ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity
|
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity
|
||||||
|
@ -47,5 +38,5 @@ abstract class ActivitiesModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorOtpActivity(): SmsCommunicatorOtpActivity
|
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorOtpActivity(): SmsCommunicatorOtpActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
@ContributesAndroidInjector abstract fun contributesPrefImportListActivity(): PrefImportListActivity
|
||||||
}
|
}
|
|
@ -5,54 +5,18 @@ import dagger.Component
|
||||||
import dagger.android.AndroidInjectionModule
|
import dagger.android.AndroidInjectionModule
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.core.di.CoreModule
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.dana.di.DanaModule
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.danar.di.DanaRModule
|
||||||
import info.nightscout.androidaps.db.BgReading
|
import info.nightscout.androidaps.danars.di.DanaRSModule
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
|
||||||
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
|
||||||
import info.nightscout.androidaps.queue.commands.*
|
|
||||||
import info.nightscout.androidaps.setupwizard.SWEventListener
|
|
||||||
import info.nightscout.androidaps.setupwizard.SWScreen
|
|
||||||
import info.nightscout.androidaps.setupwizard.elements.*
|
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Component(
|
@Component(
|
||||||
modules = [
|
modules = [
|
||||||
AndroidInjectionModule::class,
|
AndroidInjectionModule::class,
|
||||||
|
PluginsModule::class,
|
||||||
|
SkinsModule::class,
|
||||||
ActivitiesModule::class,
|
ActivitiesModule::class,
|
||||||
FragmentsModule::class,
|
FragmentsModule::class,
|
||||||
AppModule::class,
|
AppModule::class,
|
||||||
|
@ -67,7 +31,12 @@ import javax.inject.Singleton
|
||||||
PreferencesModule::class,
|
PreferencesModule::class,
|
||||||
OverviewModule::class,
|
OverviewModule::class,
|
||||||
DataClassesModule::class,
|
DataClassesModule::class,
|
||||||
SMSModule::class
|
SMSModule::class,
|
||||||
|
UIModule::class,
|
||||||
|
CoreModule::class,
|
||||||
|
DanaModule::class,
|
||||||
|
DanaRModule::class,
|
||||||
|
DanaRSModule::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
interface AppComponent : AndroidInjector<MainApp> {
|
interface AppComponent : AndroidInjector<MainApp> {
|
||||||
|
|
|
@ -1,124 +1,41 @@
|
||||||
package info.nightscout.androidaps.dependencyInjection
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.android.ContributesAndroidInjector
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.db.DatabaseHelperProvider
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.db.BgReading
|
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLoggerProduction
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
|
||||||
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.actions.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetPreamble
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.*
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUITask
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
import info.nightscout.androidaps.queue.commands.*
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import info.nightscout.androidaps.setupwizard.SWEventListener
|
|
||||||
import info.nightscout.androidaps.setupwizard.SWScreen
|
|
||||||
import info.nightscout.androidaps.setupwizard.elements.*
|
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SPImplementation
|
|
||||||
import info.nightscout.androidaps.utils.storage.FileStorage
|
import info.nightscout.androidaps.utils.storage.FileStorage
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module(includes = [AppModule.AppBindings::class, PluginsModule::class])
|
@Module(includes = [
|
||||||
|
AppModule.AppBindings::class
|
||||||
|
])
|
||||||
open class AppModule {
|
open class AppModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
fun providesPlugins(configInterface: ConfigInterface,
|
||||||
fun provideSharedPreferences(context: Context, resourceHelper: ResourceHelper): SP {
|
@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
|
||||||
return SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), resourceHelper)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideProfileFunction(injector: HasAndroidInjector, aapsLogger: AAPSLogger, sp: SP, resourceHelper: ResourceHelper, activePlugin: ActivePluginProvider, fabricPrivacy: FabricPrivacy): ProfileFunction {
|
|
||||||
return ProfileFunctionImplementation(injector, aapsLogger, sp, resourceHelper, activePlugin, fabricPrivacy)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideResources(mainApp: MainApp): ResourceHelper {
|
|
||||||
return ResourceHelperImplementation(mainApp)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideAAPSLogger(): AAPSLogger {
|
|
||||||
return AAPSLoggerProduction()
|
|
||||||
/* if (BuildConfig.DEBUG) {
|
|
||||||
AAPSLoggerDebug()
|
|
||||||
} else {
|
|
||||||
AAPSLoggerProduction()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
|
|
||||||
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
||||||
@PluginsModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
@PluginsModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
||||||
@PluginsModule.NSClient nsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
|
||||||
@PluginsModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>)
|
@PluginsModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>)
|
||||||
: List<@JvmSuppressWildcards PluginBase> {
|
: List<@JvmSuppressWildcards PluginBase> {
|
||||||
val plugins = allConfigs.toMutableMap()
|
val plugins = allConfigs.toMutableMap()
|
||||||
if (Config.PUMPDRIVERS) plugins += pumpDrivers.get()
|
if (configInterface.PUMPDRIVERS) plugins += pumpDrivers.get()
|
||||||
if (Config.APS) plugins += aps.get()
|
if (configInterface.APS) plugins += aps.get()
|
||||||
if (!Config.NSCLIENT) plugins += notNsClient.get()
|
if (!configInterface.NSCLIENT) plugins += notNsClient.get()
|
||||||
if (Config.NSCLIENT) plugins += nsClient.get()
|
|
||||||
return plugins.toList().sortedBy { it.first }.map { it.second }
|
return plugins.toList().sortedBy { it.first }.map { it.second }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +50,13 @@ open class AppModule {
|
||||||
|
|
||||||
@Binds fun bindContext(mainApp: MainApp): Context
|
@Binds fun bindContext(mainApp: MainApp): Context
|
||||||
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
||||||
|
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
||||||
@Binds
|
@Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||||
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
@Binds fun bindConfigInterface(config: Config): ConfigInterface
|
||||||
|
@Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilderInterface
|
||||||
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
@Binds fun bindTreatmentInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||||
|
@Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
|
||||||
|
@Binds fun bindUploadQueueInterface(uploadQueue: UploadQueue): UploadQueueInterface
|
||||||
|
@Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
import info.nightscout.androidaps.queue.commands.*
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
|
|
||||||
|
@ -10,8 +9,6 @@ import info.nightscout.androidaps.queue.commands.*
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class CommandQueueModule {
|
abstract class CommandQueueModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResult
|
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun commandQueueInjector(): CommandQueue
|
@ContributesAndroidInjector abstract fun commandQueueInjector(): CommandQueue
|
||||||
@ContributesAndroidInjector abstract fun commandBolusInjector(): CommandBolus
|
@ContributesAndroidInjector abstract fun commandBolusInjector(): CommandBolus
|
||||||
@ContributesAndroidInjector abstract fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
|
@ContributesAndroidInjector abstract fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
|
||||||
|
|
|
@ -3,14 +3,10 @@ package info.nightscout.androidaps.dependencyInjection
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.db.*
|
||||||
import info.nightscout.androidaps.db.BgReading
|
import info.nightscout.androidaps.interfaces.ProfileStore
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.general.food.FoodService
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
||||||
|
@ -19,18 +15,11 @@ import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class DataClassesModule {
|
abstract class DataClassesModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun profileInjector(): Profile
|
|
||||||
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
|
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
|
||||||
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStore
|
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun bgReadingInjector(): BgReading
|
|
||||||
@ContributesAndroidInjector abstract fun treatmentInjector(): Treatment
|
|
||||||
@ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch
|
|
||||||
@ContributesAndroidInjector abstract fun temporaryBasalInjector(): TemporaryBasal
|
|
||||||
@ContributesAndroidInjector abstract fun careportalEventInjector(): CareportalEvent
|
|
||||||
@ContributesAndroidInjector abstract fun extendedBolusInjector(): ExtendedBolus
|
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun DatabaseHelperInjector(): DatabaseHelper
|
||||||
@ContributesAndroidInjector abstract fun treatmentServiceInjector(): TreatmentService
|
@ContributesAndroidInjector abstract fun treatmentServiceInjector(): TreatmentService
|
||||||
|
@ContributesAndroidInjector abstract fun foodServiceInjector(): FoodService
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
|
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
|
||||||
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry
|
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry
|
||||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBFragment
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||||
import info.nightscout.androidaps.plugins.general.actions.ActionsFragment
|
import info.nightscout.androidaps.plugins.general.actions.ActionsFragment
|
||||||
import info.nightscout.androidaps.plugins.general.automation.AutomationFragment
|
import info.nightscout.androidaps.plugins.general.automation.AutomationFragment
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseActionDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseActionDialog
|
||||||
|
@ -18,8 +18,6 @@ import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTrigg
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditActionDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditActionDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditTriggerDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditTriggerDialog
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
|
||||||
import info.nightscout.androidaps.plugins.general.food.FoodFragment
|
import info.nightscout.androidaps.plugins.general.food.FoodFragment
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment
|
||||||
|
@ -34,10 +32,11 @@ import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.combo.ComboFragment
|
import info.nightscout.androidaps.plugins.pump.combo.ComboFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusHistoryFragment
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusHistoryFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment
|
import info.nightscout.androidaps.danars.dialogs.PairingProgressDialog
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
|
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.RileyLinkStatusDeviceMedtronic
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
||||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
||||||
|
@ -53,13 +52,11 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesActionsFragment(): ActionsFragment
|
@ContributesAndroidInjector abstract fun contributesActionsFragment(): ActionsFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesAutomationFragment(): AutomationFragment
|
@ContributesAndroidInjector abstract fun contributesAutomationFragment(): AutomationFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
|
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesCareportalFragment(): CareportalFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesComboFragment(): ComboFragment
|
@ContributesAndroidInjector abstract fun contributesComboFragment(): ComboFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaRFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
|
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesInsulinFragment(): InsulinFragment
|
@ContributesAndroidInjector abstract fun contributesInsulinFragment(): InsulinFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
|
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
|
||||||
|
@ -71,6 +68,7 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
|
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
|
||||||
|
@ContributesAndroidInjector abstract fun contributesOmnipodFragment(): OmnipodFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
||||||
|
@ -87,7 +85,6 @@ abstract class FragmentsModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
|
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
|
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
|
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
|
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
|
||||||
|
@ -98,17 +95,13 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesChooseActionDialog(): ChooseActionDialog
|
@ContributesAndroidInjector abstract fun contributesChooseActionDialog(): ChooseActionDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesChooseTriggerDialog(): ChooseTriggerDialog
|
@ContributesAndroidInjector abstract fun contributesChooseTriggerDialog(): ChooseTriggerDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesNewNSTreatmentDialog(): NewNSTreatmentDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesProfileSwitchDialog(): ProfileSwitchDialog
|
@ContributesAndroidInjector abstract fun contributesProfileSwitchDialog(): ProfileSwitchDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesProfileViewerDialog(): ProfileViewerDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog
|
@ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
|
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog
|
@ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class OmnipodModule {
|
||||||
|
|
||||||
|
// Activities
|
||||||
|
@ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity
|
||||||
|
@ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
||||||
|
@ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask
|
||||||
|
@ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager
|
||||||
|
@ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction
|
||||||
|
@ContributesAndroidInjector abstract fun podSessionState(): PodSessionState
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,16 +2,8 @@ package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package info.nightscout.androidaps.dependencyInjection
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Lazy
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
|
||||||
import dagger.multibindings.IntKey
|
import dagger.multibindings.IntKey
|
||||||
import dagger.multibindings.IntoMap
|
import dagger.multibindings.IntoMap
|
||||||
import dagger.multibindings.IntoSet
|
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||||
|
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
|
||||||
|
@ -21,7 +21,6 @@ import info.nightscout.androidaps.plugins.constraints.storage.StorageConstraintP
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
|
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin
|
import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.food.FoodPlugin
|
import info.nightscout.androidaps.plugins.general.food.FoodPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
|
@ -38,10 +37,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
||||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
|
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
|
@ -164,12 +159,6 @@ abstract class PluginsModule {
|
||||||
@IntKey(170)
|
@IntKey(170)
|
||||||
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
|
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
|
||||||
|
|
||||||
@Binds
|
|
||||||
@NSClient
|
|
||||||
@IntoMap
|
|
||||||
@IntKey(180)
|
|
||||||
abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@APS
|
@APS
|
||||||
@IntoMap
|
@IntoMap
|
||||||
|
@ -230,7 +219,6 @@ abstract class PluginsModule {
|
||||||
@IntKey(280)
|
@IntKey(280)
|
||||||
abstract fun bindSmsCommunicatorPlugin(plugin: SmsCommunicatorPlugin): PluginBase
|
abstract fun bindSmsCommunicatorPlugin(plugin: SmsCommunicatorPlugin): PluginBase
|
||||||
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@APS
|
@APS
|
||||||
@IntoMap
|
@IntoMap
|
||||||
|
@ -360,9 +348,6 @@ abstract class PluginsModule {
|
||||||
@Qualifier
|
@Qualifier
|
||||||
annotation class NotNSClient
|
annotation class NotNSClient
|
||||||
|
|
||||||
@Qualifier
|
|
||||||
annotation class NSClient
|
|
||||||
|
|
||||||
@Qualifier
|
@Qualifier
|
||||||
annotation class APS
|
annotation class APS
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.dependencyInjection
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
import info.nightscout.androidaps.utils.CryptoUtil
|
||||||
|
@ -15,4 +16,5 @@ abstract class PreferencesModule {
|
||||||
@ContributesAndroidInjector abstract fun importExportPrefsInjector(): ImportExportPrefs
|
@ContributesAndroidInjector abstract fun importExportPrefsInjector(): ImportExportPrefs
|
||||||
@ContributesAndroidInjector abstract fun encryptedPrefsFormatInjector(): EncryptedPrefsFormat
|
@ContributesAndroidInjector abstract fun encryptedPrefsFormatInjector(): EncryptedPrefsFormat
|
||||||
@ContributesAndroidInjector abstract fun classicPrefsFormatInjector(): ClassicPrefsFormat
|
@ContributesAndroidInjector abstract fun classicPrefsFormatInjector(): ClassicPrefsFormat
|
||||||
|
@ContributesAndroidInjector abstract fun prefImportListProviderInjector(): PrefFileListProvider
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@ abstract class ReceiversModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesChargingStateReceiver(): ChargingStateReceiver
|
@ContributesAndroidInjector abstract fun contributesChargingStateReceiver(): ChargingStateReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesDataReceiver(): DataReceiver
|
@ContributesAndroidInjector abstract fun contributesDataReceiver(): DataReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesKeepAliveReceiver(): KeepAliveReceiver
|
@ContributesAndroidInjector abstract fun contributesKeepAliveReceiver(): KeepAliveReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesNetworkChangeReceiver(): NetworkChangeReceiver
|
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
|
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
|
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
||||||
|
|
|
@ -7,14 +7,10 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Dismiss
|
||||||
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
|
import info.nightscout.androidaps.plugins.general.persistentNotification.DummyService
|
||||||
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
|
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.services.AbstractDanaRExecutionService
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.services.DanaRSService
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.services.DanaRv2ExecutionService
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
|
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService
|
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService
|
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService
|
||||||
import info.nightscout.androidaps.services.AlarmSoundService
|
import info.nightscout.androidaps.services.AlarmSoundService
|
||||||
import info.nightscout.androidaps.services.DataService
|
import info.nightscout.androidaps.services.DataService
|
||||||
import info.nightscout.androidaps.services.LocationService
|
import info.nightscout.androidaps.services.LocationService
|
||||||
|
@ -23,20 +19,16 @@ import info.nightscout.androidaps.services.LocationService
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class ServicesModule {
|
abstract class ServicesModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesAbstractDanaRExecutionService(): AbstractDanaRExecutionService
|
|
||||||
@ContributesAndroidInjector abstract fun contributesAlarmSoundService(): AlarmSoundService
|
@ContributesAndroidInjector abstract fun contributesAlarmSoundService(): AlarmSoundService
|
||||||
@ContributesAndroidInjector abstract fun contributesDataService(): DataService
|
@ContributesAndroidInjector abstract fun contributesDataService(): DataService
|
||||||
@ContributesAndroidInjector abstract fun contributesDismissNotificationService(): DismissNotificationService
|
@ContributesAndroidInjector abstract fun contributesDismissNotificationService(): DismissNotificationService
|
||||||
@ContributesAndroidInjector abstract fun contributesDummyService(): DummyService
|
@ContributesAndroidInjector abstract fun contributesDummyService(): DummyService
|
||||||
@ContributesAndroidInjector abstract fun contributesLocationService(): LocationService
|
@ContributesAndroidInjector abstract fun contributesLocationService(): LocationService
|
||||||
@ContributesAndroidInjector abstract fun contributesNSClientService(): NSClientService
|
@ContributesAndroidInjector abstract fun contributesNSClientService(): NSClientService
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRSService(): DanaRSService
|
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRv2ExecutionService(): DanaRv2ExecutionService
|
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRExecutionService(): DanaRExecutionService
|
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRKoreanExecutionService(): DanaRKoreanExecutionService
|
|
||||||
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): WatchUpdaterService
|
@ContributesAndroidInjector abstract fun contributesWatchUpdaterService(): WatchUpdaterService
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightAlertService(): InsightAlertService
|
@ContributesAndroidInjector abstract fun contributesInsightAlertService(): InsightAlertService
|
||||||
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
|
@ContributesAndroidInjector abstract fun contributesInsightConnectionService(): InsightConnectionService
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService
|
@ContributesAndroidInjector abstract fun contributesRileyLinkService(): RileyLinkService
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService
|
@ContributesAndroidInjector abstract fun contributesRileyLinkMedtronicService(): RileyLinkMedtronicService
|
||||||
|
@ContributesAndroidInjector abstract fun contributesRileyLinkOmnipodService(): RileyLinkOmnipodService
|
||||||
}
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import dagger.multibindings.IntKey
|
||||||
|
import dagger.multibindings.IntoMap
|
||||||
|
import info.nightscout.androidaps.skins.SkinButtonsOn
|
||||||
|
import info.nightscout.androidaps.skins.SkinClassic
|
||||||
|
import info.nightscout.androidaps.skins.SkinInterface
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
|
@Module
|
||||||
|
open class SkinsModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Skin
|
||||||
|
@IntoMap
|
||||||
|
@IntKey(0)
|
||||||
|
fun bindsSkinClassic(skinClassic: SkinClassic): SkinInterface = skinClassic
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Skin
|
||||||
|
@IntoMap
|
||||||
|
@IntKey(10)
|
||||||
|
fun bindsSkinButtonsOn(skinButtonsOn: SkinButtonsOn): SkinInterface = skinButtonsOn
|
||||||
|
|
||||||
|
@Qualifier
|
||||||
|
annotation class Skin
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package info.nightscout.androidaps.dependencyInjection
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.androidaps.skins.SkinListPreference
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class UIModule {
|
||||||
|
@ContributesAndroidInjector abstract fun skinListPreferenceInjector(): SkinListPreference
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
PreferenceActivity is an Example how to make an Activity injectable.
|
|
||||||
We might undo that as we don't actually have us inject things.
|
|
||||||
|
|
||||||
MyPreferencesFragment is an injectable Fragment. Here we actually have Dagger2 provide us an InsulinOrefFreePeakPlugin instance.
|
|
||||||
|
|
||||||
If we use multiple Fragments, we should generate a base-class. Then we only have to add a "provides***Fragment" to the FragmentsModule and derive from that class.
|
|
||||||
|
|
||||||
InsulinOrefFreePeakPlugin is an example how to get things injected via the constructor.
|
|
||||||
You could call "new InsulinOrefFreePeakPlugin(new SPImpl(SPImpl(PreferenceManager.getDefaultSharedPreferences(context))), new ResourceHelper())"... but Dagger will resolve that for you in MainApp. :)
|
|
||||||
|
|
||||||
SPImpl is an example how to bind an implementation to an Interface via Dagger.
|
|
||||||
|
|
||||||
ResourceHelper is an example how to generate simple classes that Dagger can auto-resolve how to inject them. No need for a provider here.
|
|
||||||
ResourceHelper might have a weak reference at some point and not a static dependency on MainApp... but at least we reduced the static dependencies within a plugin.
|
|
||||||
|
|
||||||
In order to Test: Any dependency of InsulinOrefFreePeakPlugin is passed via the constructor. Instead of static mocking MainApp you now can Mock ResourceHelper with a very small interface.
|
|
|
@ -9,7 +9,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
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.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
|
|
@ -16,7 +16,7 @@ import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.CarbsGenerator
|
import info.nightscout.androidaps.plugins.treatments.CarbsGenerator
|
||||||
|
@ -40,6 +40,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
||||||
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var carbsGenerator: CarbsGenerator
|
@Inject lateinit var carbsGenerator: CarbsGenerator
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -170,7 +171,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
eventTime -= eventTime % 1000
|
eventTime -= eventTime % 1000
|
||||||
val time = eventTime + timeOffset * 1000 * 60
|
val time = eventTime + timeOffset * 1000 * 60
|
||||||
if (timeOffset != 0)
|
if (timeOffset != 0)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time))
|
||||||
val duration = overview_carbs_duration.value.toInt()
|
val duration = overview_carbs_duration.value.toInt()
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour))
|
actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour))
|
||||||
|
@ -184,7 +185,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
|
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
|
||||||
|
|
||||||
if (eventTimeChanged)
|
if (eventTimeChanged)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) {
|
if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
|
@ -233,7 +234,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time duration: $duration")
|
aapsLogger.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time duration: $duration")
|
||||||
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
|
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
|
||||||
NSUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null)
|
}, null)
|
||||||
|
|
|
@ -15,13 +15,13 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.Translator
|
import info.nightscout.androidaps.utils.Translator
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import kotlinx.android.synthetic.main.dialog_care.*
|
import kotlinx.android.synthetic.main.dialog_care.*
|
||||||
import kotlinx.android.synthetic.main.notes.*
|
import kotlinx.android.synthetic.main.notes.*
|
||||||
|
@ -36,6 +36,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var mainApp: MainApp
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var translator: Translator
|
@Inject lateinit var translator: Translator
|
||||||
|
|
||||||
enum class EventType {
|
enum class EventType {
|
||||||
|
@ -43,10 +44,13 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
SENSOR_INSERT,
|
SENSOR_INSERT,
|
||||||
BATTERY_CHANGE,
|
BATTERY_CHANGE,
|
||||||
NOTE,
|
NOTE,
|
||||||
EXERCISE
|
EXERCISE,
|
||||||
|
QUESTION,
|
||||||
|
ANNOUNCEMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
private var options: EventType = EventType.BGCHECK
|
private var options: EventType = EventType.BGCHECK
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
private var event: Int = R.string.none
|
private var event: Int = R.string.none
|
||||||
|
|
||||||
|
@ -84,6 +88,8 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
EventType.BATTERY_CHANGE -> R.drawable.icon_cp_pump_battery
|
EventType.BATTERY_CHANGE -> R.drawable.icon_cp_pump_battery
|
||||||
EventType.NOTE -> R.drawable.icon_cp_note
|
EventType.NOTE -> R.drawable.icon_cp_note
|
||||||
EventType.EXERCISE -> R.drawable.icon_cp_exercise
|
EventType.EXERCISE -> R.drawable.icon_cp_exercise
|
||||||
|
EventType.QUESTION -> R.drawable.icon_cp_question
|
||||||
|
EventType.ANNOUNCEMENT -> R.drawable.icon_cp_announcement
|
||||||
})
|
})
|
||||||
actions_care_title.text = resourceHelper.gs(when (options) {
|
actions_care_title.text = resourceHelper.gs(when (options) {
|
||||||
EventType.BGCHECK -> R.string.careportal_bgcheck
|
EventType.BGCHECK -> R.string.careportal_bgcheck
|
||||||
|
@ -91,9 +97,13 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
EventType.BATTERY_CHANGE -> R.string.careportal_pumpbatterychange
|
EventType.BATTERY_CHANGE -> R.string.careportal_pumpbatterychange
|
||||||
EventType.NOTE -> R.string.careportal_note
|
EventType.NOTE -> R.string.careportal_note
|
||||||
EventType.EXERCISE -> R.string.careportal_exercise
|
EventType.EXERCISE -> R.string.careportal_exercise
|
||||||
|
EventType.QUESTION -> R.string.careportal_question
|
||||||
|
EventType.ANNOUNCEMENT -> R.string.careportal_announcement
|
||||||
})
|
})
|
||||||
|
|
||||||
when (options) {
|
when (options) {
|
||||||
|
EventType.QUESTION,
|
||||||
|
EventType.ANNOUNCEMENT,
|
||||||
EventType.BGCHECK -> {
|
EventType.BGCHECK -> {
|
||||||
action_care_duration_layout.visibility = View.GONE
|
action_care_duration_layout.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
@ -133,7 +143,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
actions_care_duration.setParams(savedInstanceState?.getDouble("actions_care_duration")
|
actions_care_duration.setParams(savedInstanceState?.getDouble("actions_care_duration")
|
||||||
?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, ok)
|
?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, ok)
|
||||||
if (options == EventType.NOTE)
|
if (options == EventType.NOTE || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT)
|
||||||
notes_layout?.visibility = View.VISIBLE // independent to preferences
|
notes_layout?.visibility = View.VISIBLE // independent to preferences
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +153,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
val json = JSONObject()
|
val json = JSONObject()
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
if (options == EventType.BGCHECK) {
|
if (options == EventType.BGCHECK || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT) {
|
||||||
val type =
|
val type =
|
||||||
when {
|
when {
|
||||||
actions_care_meter.isChecked -> "Finger"
|
actions_care_meter.isChecked -> "Finger"
|
||||||
|
@ -167,7 +177,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
eventTime -= eventTime % 1000
|
eventTime -= eventTime % 1000
|
||||||
|
|
||||||
if (eventTimeChanged)
|
if (eventTimeChanged)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
json.put("created_at", DateUtil.toISOString(eventTime))
|
json.put("created_at", DateUtil.toISOString(eventTime))
|
||||||
json.put("mills", eventTime)
|
json.put("mills", eventTime)
|
||||||
|
@ -177,6 +187,8 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
EventType.BATTERY_CHANGE -> CareportalEvent.PUMPBATTERYCHANGE
|
EventType.BATTERY_CHANGE -> CareportalEvent.PUMPBATTERYCHANGE
|
||||||
EventType.NOTE -> CareportalEvent.NOTE
|
EventType.NOTE -> CareportalEvent.NOTE
|
||||||
EventType.EXERCISE -> CareportalEvent.EXERCISE
|
EventType.EXERCISE -> CareportalEvent.EXERCISE
|
||||||
|
EventType.QUESTION -> CareportalEvent.QUESTION
|
||||||
|
EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT
|
||||||
})
|
})
|
||||||
json.put("units", profileFunction.getUnits())
|
json.put("units", profileFunction.getUnits())
|
||||||
if (enteredBy.isNotEmpty())
|
if (enteredBy.isNotEmpty())
|
||||||
|
@ -193,11 +205,13 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
EventType.BATTERY_CHANGE -> CareportalEvent.PUMPBATTERYCHANGE
|
EventType.BATTERY_CHANGE -> CareportalEvent.PUMPBATTERYCHANGE
|
||||||
EventType.NOTE -> CareportalEvent.NOTE
|
EventType.NOTE -> CareportalEvent.NOTE
|
||||||
EventType.EXERCISE -> CareportalEvent.EXERCISE
|
EventType.EXERCISE -> CareportalEvent.EXERCISE
|
||||||
|
EventType.QUESTION -> CareportalEvent.QUESTION
|
||||||
|
EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT
|
||||||
}
|
}
|
||||||
careportalEvent.json = json.toString()
|
careportalEvent.json = json.toString()
|
||||||
aapsLogger.debug("USER ENTRY: CAREPORTAL ${careportalEvent.eventType} json: ${careportalEvent.json}")
|
aapsLogger.debug("USER ENTRY: CAREPORTAL ${careportalEvent.eventType} json: ${careportalEvent.json}")
|
||||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||||
NSUpload.uploadCareportalEntryToNS(json)
|
nsUpload.uploadCareportalEntryToNS(json)
|
||||||
}, null)
|
}, null)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -24,6 +24,7 @@ import javax.inject.Inject
|
||||||
abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
var eventTime = DateUtil.now()
|
var eventTime = DateUtil.now()
|
||||||
var eventTimeChanged = false
|
var eventTimeChanged = false
|
||||||
|
@ -57,7 +58,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
||||||
eventTime = savedInstanceState?.getLong("eventTime") ?: DateUtil.now()
|
eventTime = savedInstanceState?.getLong("eventTime") ?: DateUtil.now()
|
||||||
eventTimeChanged = savedInstanceState?.getBoolean("eventTimeChanged") ?: false
|
eventTimeChanged = savedInstanceState?.getBoolean("eventTimeChanged") ?: false
|
||||||
overview_eventdate?.text = DateUtil.dateString(eventTime)
|
overview_eventdate?.text = DateUtil.dateString(eventTime)
|
||||||
overview_eventtime?.text = DateUtil.timeString(eventTime)
|
overview_eventtime?.text = dateUtil.timeString(eventTime)
|
||||||
|
|
||||||
// create an OnDateSetListener
|
// create an OnDateSetListener
|
||||||
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
|
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
|
||||||
|
@ -92,7 +93,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
|
||||||
cal.set(Calendar.SECOND, seconds++) // randomize seconds to prevent creating record of the same time, if user choose time manually
|
cal.set(Calendar.SECOND, seconds++) // randomize seconds to prevent creating record of the same time, if user choose time manually
|
||||||
eventTime = cal.timeInMillis
|
eventTime = cal.timeInMillis
|
||||||
eventTimeChanged = true
|
eventTimeChanged = true
|
||||||
overview_eventtime?.text = DateUtil.timeString(eventTime)
|
overview_eventtime?.text = dateUtil.timeString(eventTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
overview_eventtime?.setOnClickListener {
|
overview_eventtime?.setOnClickListener {
|
||||||
|
|
|
@ -23,9 +23,10 @@ import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.SafeParse
|
import info.nightscout.androidaps.utils.SafeParse
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import kotlinx.android.synthetic.main.dialog_fill.*
|
import kotlinx.android.synthetic.main.dialog_fill.*
|
||||||
import kotlinx.android.synthetic.main.notes.*
|
import kotlinx.android.synthetic.main.notes.*
|
||||||
import kotlinx.android.synthetic.main.okcancel.*
|
import kotlinx.android.synthetic.main.okcancel.*
|
||||||
|
@ -39,9 +40,9 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var ctx: Context
|
@Inject lateinit var ctx: Context
|
||||||
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
@ -112,7 +113,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
eventTime -= eventTime % 1000
|
eventTime -= eventTime % 1000
|
||||||
|
|
||||||
if (eventTimeChanged)
|
if (eventTimeChanged)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) {
|
if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
|
@ -123,12 +124,12 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
if (siteChange) {
|
if (siteChange) {
|
||||||
aapsLogger.debug("USER ENTRY: SITE CHANGE")
|
aapsLogger.debug("USER ENTRY: SITE CHANGE")
|
||||||
generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
||||||
}
|
}
|
||||||
if (insulinChange) {
|
if (insulinChange) {
|
||||||
// add a second for case of both checked
|
// add a second for case of both checked
|
||||||
aapsLogger.debug("USER ENTRY: INSULIN CHANGE")
|
aapsLogger.debug("USER ENTRY: INSULIN CHANGE")
|
||||||
generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
||||||
}
|
}
|
||||||
}, null)
|
}, null)
|
||||||
}
|
}
|
||||||
|
@ -161,28 +162,4 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateCareportalEvent(eventType: String, time: Long, notes: String) {
|
|
||||||
val careportalEvent = CareportalEvent(injector)
|
|
||||||
careportalEvent.source = Source.USER
|
|
||||||
careportalEvent.date = time
|
|
||||||
careportalEvent.json = generateJson(eventType, time, notes).toString()
|
|
||||||
careportalEvent.eventType = eventType
|
|
||||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
|
||||||
NSUpload.uploadEvent(eventType, time, notes)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject {
|
|
||||||
val data = JSONObject()
|
|
||||||
try {
|
|
||||||
data.put("eventType", careportalEvent)
|
|
||||||
data.put("created_at", DateUtil.toISOString(time))
|
|
||||||
data.put("mills", time)
|
|
||||||
data.put("enteredBy", sp.getString("careportal_enteredby", resourceHelper.gs(R.string.app_name)))
|
|
||||||
if (notes.isNotEmpty()) data.put("notes", notes)
|
|
||||||
} catch (ignored: JSONException) {
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
@ -145,7 +145,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
val timeOffset = overview_insulin_time.value.toInt()
|
val timeOffset = overview_insulin_time.value.toInt()
|
||||||
val time = DateUtil.now() + T.mins(timeOffset.toLong()).msecs()
|
val time = DateUtil.now() + T.mins(timeOffset.toLong()).msecs()
|
||||||
if (timeOffset != 0)
|
if (timeOffset != 0)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time))
|
||||||
|
|
||||||
val notes = notes.text.toString()
|
val notes = notes.text.toString()
|
||||||
if (notes.isNotEmpty())
|
if (notes.isNotEmpty())
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
|
@ -98,7 +98,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
if (notes.isNotEmpty())
|
if (notes.isNotEmpty())
|
||||||
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
|
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
|
||||||
if (eventTimeChanged)
|
if (eventTimeChanged)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
@ -89,19 +89,19 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
if (isPercentPump) {
|
if (isPercentPump) {
|
||||||
val basalPercentInput = SafeParse.stringToInt(actions_tempbasal_basalpercentinput.text)
|
val basalPercentInput = SafeParse.stringToInt(actions_tempbasal_basalpercentinput.text)
|
||||||
percent = constraintChecker.applyBasalPercentConstraints(Constraint(basalPercentInput), profile).value()
|
percent = constraintChecker.applyBasalPercentConstraints(Constraint(basalPercentInput), profile).value()
|
||||||
actions.add(resourceHelper.gs(R.string.pump_tempbasal_label) + ": $percent%")
|
actions.add(resourceHelper.gs(R.string.tempbasal_label) + ": $percent%")
|
||||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, durationInMinutes))
|
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, durationInMinutes))
|
||||||
if (percent != basalPercentInput) actions.add(resourceHelper.gs(R.string.constraintapllied))
|
if (percent != basalPercentInput) actions.add(resourceHelper.gs(R.string.constraintapllied))
|
||||||
} else {
|
} else {
|
||||||
val basalAbsoluteInput = SafeParse.stringToDouble(actions_tempbasal_basalabsoluteinput.text)
|
val basalAbsoluteInput = SafeParse.stringToDouble(actions_tempbasal_basalabsoluteinput.text)
|
||||||
absolute = constraintChecker.applyBasalConstraints(Constraint(basalAbsoluteInput), profile).value()
|
absolute = constraintChecker.applyBasalConstraints(Constraint(basalAbsoluteInput), profile).value()
|
||||||
actions.add(resourceHelper.gs(R.string.pump_tempbasal_label) + ": " + resourceHelper.gs(R.string.pump_basebasalrate, absolute))
|
actions.add(resourceHelper.gs(R.string.tempbasal_label) + ": " + resourceHelper.gs(R.string.pump_basebasalrate, absolute))
|
||||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, durationInMinutes))
|
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, durationInMinutes))
|
||||||
if (abs(absolute - basalAbsoluteInput) > 0.01)
|
if (abs(absolute - basalAbsoluteInput) > 0.01)
|
||||||
actions.add("<font color='" + resourceHelper.gc(R.color.warning) + "'>" + resourceHelper.gs(R.string.constraintapllied) + "</font>")
|
actions.add("<font color='" + resourceHelper.gc(R.color.warning) + "'>" + resourceHelper.gs(R.string.constraintapllied) + "</font>")
|
||||||
}
|
}
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.pump_tempbasal_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
val callback: Callback = object : Callback() {
|
val callback: Callback = object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -14,9 +14,8 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
@ -123,13 +122,13 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
val duration = overview_temptarget_duration.value.toInt()
|
val duration = overview_temptarget_duration.value.toInt()
|
||||||
if (target != 0.0 && duration != 0) {
|
if (target != 0.0 && duration != 0) {
|
||||||
actions.add(resourceHelper.gs(R.string.reason) + ": " + reason)
|
actions.add(resourceHelper.gs(R.string.reason) + ": " + reason)
|
||||||
actions.add(resourceHelper.gs(R.string.nsprofileview_target_label) + ": " + Profile.toCurrentUnitsString(profileFunction, target) + " " + resourceHelper.gs(unitResId))
|
actions.add(resourceHelper.gs(R.string.target_label) + ": " + Profile.toCurrentUnitsString(profileFunction, target) + " " + resourceHelper.gs(unitResId))
|
||||||
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
|
actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration))
|
||||||
} else {
|
} else {
|
||||||
actions.add(resourceHelper.gs(R.string.stoptemptarget))
|
actions.add(resourceHelper.gs(R.string.stoptemptarget))
|
||||||
}
|
}
|
||||||
if (eventTimeChanged)
|
if (eventTimeChanged)
|
||||||
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.view.WindowManager
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
|
|
||||||
class EventTreatmentChange(val treatment: Treatment?) : EventLoop()
|
class EventTreatmentChange(val treatment: Treatment?) : EventLoop()
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
|
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
|
@ -54,6 +54,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var overviewMenus: OverviewMenus
|
@Inject lateinit var overviewMenus: OverviewMenus
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
cal.set(Calendar.MONTH, monthOfYear)
|
cal.set(Calendar.MONTH, monthOfYear)
|
||||||
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth)
|
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth)
|
||||||
start = cal.timeInMillis
|
start = cal.timeInMillis
|
||||||
historybrowse_date?.text = DateUtil.dateAndTimeString(start)
|
historybrowse_date?.text = dateUtil.dateAndTimeString(start)
|
||||||
updateGUI("onClickDate")
|
updateGUI("onClickDate")
|
||||||
runCalculation("onClickDate")
|
runCalculation("onClickDate")
|
||||||
}
|
}
|
||||||
|
@ -236,7 +237,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
val lowLine = defaultValueHelper.determineLowLine()
|
val lowLine = defaultValueHelper.determineLowLine()
|
||||||
val highLine = defaultValueHelper.determineHighLine()
|
val highLine = defaultValueHelper.determineHighLine()
|
||||||
historybrowse_date?.text = DateUtil.dateAndTimeString(start)
|
historybrowse_date?.text = dateUtil.dateAndTimeString(start)
|
||||||
historybrowse_zoom?.text = rangeToDisplay.toString()
|
historybrowse_zoom?.text = rangeToDisplay.toString()
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
@ -248,7 +249,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
val fromTime: Long = start + T.secs(100).msecs()
|
val fromTime: Long = start + T.secs(100).msecs()
|
||||||
val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs()
|
val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
aapsLogger.debug(LTag.UI, "Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime))
|
aapsLogger.debug(LTag.UI, "Period: " + dateUtil.dateAndTimeString(fromTime) + " - " + dateUtil.dateAndTimeString(toTime))
|
||||||
val pointer = System.currentTimeMillis()
|
val pointer = System.currentTimeMillis()
|
||||||
|
|
||||||
// **** In range Area ****
|
// **** In range Area ****
|
||||||
|
|
|
@ -2,19 +2,22 @@ package info.nightscout.androidaps.historyBrowser
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class IobCobStaticCalculatorPlugin @Inject constructor(
|
class IobCobStaticCalculatorPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
|
@ -27,9 +30,10 @@ class IobCobStaticCalculatorPlugin @Inject constructor(
|
||||||
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
||||||
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
||||||
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
||||||
fabricPrivacy: FabricPrivacy
|
fabricPrivacy: FabricPrivacy,
|
||||||
|
dateUtil: DateUtil
|
||||||
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
||||||
activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy) {
|
activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
||||||
|
|
||||||
override fun onStart() { // do not attach to rxbus
|
override fun onStart() { // do not attach to rxbus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
package info.nightscout.androidaps.logging
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 2019-12-27.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class AAPSLoggerDebug : AAPSLogger {
|
|
||||||
|
|
||||||
override fun debug(message: String) {
|
|
||||||
Log.d(LTag.CORE.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun debug(enable: Boolean, tag: LTag, message: String) {
|
|
||||||
if (enable) Log.d(LTag.CORE.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun debug(tag: LTag, message: String) {
|
|
||||||
Log.d(tag.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
|
||||||
Log.d(tag.tag, String.format(format, arguments))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun warn(tag: LTag, message: String) {
|
|
||||||
Log.w(tag.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
|
|
||||||
Log.w(tag.tag, String.format(format, arguments))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun info(tag: LTag, message: String) {
|
|
||||||
Log.i(tag.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
|
||||||
Log.i(tag.tag, String.format(format, arguments))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String) {
|
|
||||||
Log.e(tag.tag, message)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(message: String) {
|
|
||||||
Log.e(LTag.CORE.tag, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(message: String, throwable: Throwable) {
|
|
||||||
Log.e(LTag.CORE.tag, message, throwable)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(format: String, vararg arguments: Any?) {
|
|
||||||
Log.e(LTag.CORE.tag, String.format(format, arguments))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(tag: LTag, message: String, throwable: Throwable) {
|
|
||||||
Log.e(tag.tag, message, throwable)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
|
|
||||||
Log.e(tag.tag, String.format(format, arguments))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package info.nightscout.androidaps.logging
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
object L {
|
|
||||||
private var logElements: MutableList<LogElement> = ArrayList()
|
|
||||||
|
|
||||||
const val CORE = "CORE"
|
|
||||||
const val BGSOURCE = "BGSOURCE"
|
|
||||||
const val DATASERVICE = "DATASERVICE"
|
|
||||||
const val DATABASE = "DATABASE"
|
|
||||||
const val DATAFOOD = "DATAFOOD"
|
|
||||||
const val DATATREATMENTS = "DATATREATMENTS"
|
|
||||||
const val NSCLIENT = "NSCLIENT"
|
|
||||||
const val PUMP = "PUMP"
|
|
||||||
const val PUMPCOMM = "PUMPCOMM"
|
|
||||||
const val PUMPBTCOMM = "PUMPBTCOMM"
|
|
||||||
|
|
||||||
init {
|
|
||||||
LTag.values().forEach { logElements.add(LogElement(it)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun findByName(name: String): LogElement {
|
|
||||||
for (element in logElements) {
|
|
||||||
if (element.name == name) return element
|
|
||||||
}
|
|
||||||
return LogElement(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun isEnabled(name: String): Boolean {
|
|
||||||
return findByName(name).enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getLogElements(): List<LogElement> {
|
|
||||||
return logElements
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resetToDefaults() {
|
|
||||||
for (element in logElements) {
|
|
||||||
element.resetToDefault()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class LogElement {
|
|
||||||
var name: String
|
|
||||||
var defaultValue: Boolean
|
|
||||||
var enabled: Boolean
|
|
||||||
private var requiresRestart = false
|
|
||||||
|
|
||||||
internal constructor(tag: LTag) {
|
|
||||||
this.name = tag.tag
|
|
||||||
this.defaultValue = tag.defaultValue
|
|
||||||
this.requiresRestart = tag.requiresRestart
|
|
||||||
//TODO: remove after getting rid of old logging style "if (L.isEnabled(...))"
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
enabled = PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean(getSPName(), defaultValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal constructor(defaultValue: Boolean) {
|
|
||||||
name = "NONEXISTING"
|
|
||||||
this.defaultValue = defaultValue
|
|
||||||
enabled = defaultValue
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSPName(): String = "log_$name"
|
|
||||||
|
|
||||||
fun enable(enabled: Boolean) {
|
|
||||||
this.enabled = enabled
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).edit().putBoolean(getSPName(), enabled).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resetToDefault() {
|
|
||||||
enable(defaultValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import org.mozilla.javascript.ScriptableObject;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.db.StaticInjector;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class LoggerCallback extends ScriptableObject {
|
||||||
//empty constructor needed for Rhino
|
//empty constructor needed for Rhino
|
||||||
errorBuffer = new StringBuffer();
|
errorBuffer = new StringBuffer();
|
||||||
logBuffer = new StringBuffer();
|
logBuffer = new StringBuffer();
|
||||||
MainApp.instance().androidInjector().inject(this);
|
StaticInjector.Companion.getInstance().androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ class LoopFragment : DaggerFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var loopPlugin: LoopPlugin
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -81,12 +82,12 @@ class LoopFragment : DaggerFragment() {
|
||||||
loop_request?.text = it.request?.toSpanned() ?: ""
|
loop_request?.text = it.request?.toSpanned() ?: ""
|
||||||
loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: ""
|
loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: ""
|
||||||
loop_source?.text = it.source ?: ""
|
loop_source?.text = it.source ?: ""
|
||||||
loop_lastrun?.text = DateUtil.dateAndTimeString(it.lastAPSRun)
|
loop_lastrun?.text = dateUtil.dateAndTimeString(it.lastAPSRun)
|
||||||
?: ""
|
?: ""
|
||||||
loop_smbrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest)
|
loop_smbrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest)
|
||||||
loop_smbexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact)
|
loop_smbexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact)
|
||||||
loop_tbrrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest)
|
loop_tbrrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest)
|
||||||
loop_tbrexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBREnact)
|
loop_tbrexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBREnact)
|
||||||
|
|
||||||
loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
|
loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
|
||||||
?: ""
|
?: ""
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -41,9 +42,11 @@ import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
import info.nightscout.androidaps.interfaces.LoopInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
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.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
@ -53,7 +56,6 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -65,15 +67,15 @@ import info.nightscout.androidaps.queue.commands.Command;
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoopPlugin extends PluginBase {
|
public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
@ -89,6 +91,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
private final ReceiverStatusStore receiverStatusStore;
|
private final ReceiverStatusStore receiverStatusStore;
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
|
private final NSUpload nsUpload;
|
||||||
private final HardLimits hardLimits;
|
private final HardLimits hardLimits;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
@ -101,21 +104,15 @@ public class LoopPlugin extends PluginBase {
|
||||||
private boolean isSuperBolus;
|
private boolean isSuperBolus;
|
||||||
private boolean isDisconnected;
|
private boolean isDisconnected;
|
||||||
|
|
||||||
public class LastRun {
|
@Nullable private LastRun lastRun = null;
|
||||||
public APSResult request = null;
|
|
||||||
public APSResult constraintsProcessed = null;
|
@Nullable @Override public LastRun getLastRun() {
|
||||||
public PumpEnactResult tbrSetByPump = null;
|
return lastRun;
|
||||||
public PumpEnactResult smbSetByPump = null;
|
|
||||||
public String source = null;
|
|
||||||
public long lastAPSRun = DateUtil.now();
|
|
||||||
public long lastTBREnact = 0;
|
|
||||||
public long lastSMBEnact = 0;
|
|
||||||
public long lastTBRRequest = 0;
|
|
||||||
public long lastSMBRequest = 0;
|
|
||||||
public long lastOpenModeAccept;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable public LastRun lastRun = null;
|
@Override public void setLastRun(@Nullable LastRun lastRun) {
|
||||||
|
this.lastRun = lastRun;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public LoopPlugin(
|
public LoopPlugin(
|
||||||
|
@ -135,6 +132,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
||||||
ReceiverStatusStore receiverStatusStore,
|
ReceiverStatusStore receiverStatusStore,
|
||||||
FabricPrivacy fabricPrivacy,
|
FabricPrivacy fabricPrivacy,
|
||||||
|
NSUpload nsUpload,
|
||||||
HardLimits hardLimits
|
HardLimits hardLimits
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
|
@ -161,6 +159,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
this.receiverStatusStore = receiverStatusStore;
|
this.receiverStatusStore = receiverStatusStore;
|
||||||
this.fabricPrivacy = fabricPrivacy;
|
this.fabricPrivacy = fabricPrivacy;
|
||||||
|
this.nsUpload = nsUpload;
|
||||||
this.hardLimits = hardLimits;
|
this.hardLimits = hardLimits;
|
||||||
|
|
||||||
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
|
@ -292,7 +291,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLGS(){
|
public boolean isLGS() {
|
||||||
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
||||||
Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value();
|
Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value();
|
||||||
String APSmode = sp.getString(R.string.key_aps_mode, "open");
|
String APSmode = sp.getString(R.string.key_aps_mode, "open");
|
||||||
|
@ -403,18 +402,18 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastRun == null) lastRun = new LastRun();
|
if (lastRun == null) lastRun = new LastRun();
|
||||||
lastRun.request = result;
|
lastRun.setRequest(result);
|
||||||
lastRun.constraintsProcessed = resultAfterConstraints;
|
lastRun.setConstraintsProcessed(resultAfterConstraints);
|
||||||
lastRun.lastAPSRun = DateUtil.now();
|
lastRun.setLastAPSRun(DateUtil.now());
|
||||||
lastRun.source = ((PluginBase) usedAPS).getName();
|
lastRun.setSource(((PluginBase) usedAPS).getName());
|
||||||
lastRun.tbrSetByPump = null;
|
lastRun.setTbrSetByPump(null);
|
||||||
lastRun.smbSetByPump = null;
|
lastRun.setSmbSetByPump(null);
|
||||||
lastRun.lastTBREnact = 0;
|
lastRun.setLastTBREnact(0);
|
||||||
lastRun.lastTBRRequest = 0;
|
lastRun.setLastTBRRequest(0);
|
||||||
lastRun.lastSMBEnact = 0;
|
lastRun.setLastSMBEnact(0);
|
||||||
lastRun.lastSMBRequest = 0;
|
lastRun.setLastSMBRequest(0);
|
||||||
|
|
||||||
NSUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore);
|
nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
|
|
||||||
if (isSuspended()) {
|
if (isSuspended()) {
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
||||||
|
@ -437,27 +436,27 @@ public class LoopPlugin extends PluginBase {
|
||||||
final PumpEnactResult waiting = new PumpEnactResult(getInjector());
|
final PumpEnactResult waiting = new PumpEnactResult(getInjector());
|
||||||
waiting.queued = true;
|
waiting.queued = true;
|
||||||
if (resultAfterConstraints.tempBasalRequested)
|
if (resultAfterConstraints.tempBasalRequested)
|
||||||
lastRun.tbrSetByPump = waiting;
|
lastRun.setTbrSetByPump(waiting);
|
||||||
if (resultAfterConstraints.bolusRequested)
|
if (resultAfterConstraints.bolusRequested)
|
||||||
lastRun.smbSetByPump = waiting;
|
lastRun.setSmbSetByPump(waiting);
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
fabricPrivacy.logCustom("APSRequest");
|
fabricPrivacy.logCustom("APSRequest");
|
||||||
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (result.enacted || result.success) {
|
if (result.enacted || result.success) {
|
||||||
lastRun.tbrSetByPump = result;
|
lastRun.setTbrSetByPump(result);
|
||||||
lastRun.lastTBRRequest = lastRun.lastAPSRun;
|
lastRun.setLastTBRRequest(lastRun.getLastAPSRun());
|
||||||
lastRun.lastTBREnact = DateUtil.now();
|
lastRun.setLastTBREnact(DateUtil.now());
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
applySMBRequest(resultAfterConstraints, new Callback() {
|
applySMBRequest(resultAfterConstraints, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//Callback is only called if a bolus was acutally requested
|
//Callback is only called if a bolus was acutally requested
|
||||||
if (result.enacted || result.success) {
|
if (result.enacted || result.success) {
|
||||||
lastRun.smbSetByPump = result;
|
lastRun.setTbrSetByPump(result);
|
||||||
lastRun.lastSMBRequest = lastRun.lastAPSRun;
|
lastRun.setLastTBRRequest(lastRun.getLastAPSRun());
|
||||||
lastRun.lastSMBEnact = DateUtil.now();
|
lastRun.setLastTBREnact(DateUtil.now());
|
||||||
} else {
|
} else {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
|
@ -472,8 +471,8 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
lastRun.tbrSetByPump = null;
|
lastRun.setTbrSetByPump(null);
|
||||||
lastRun.smbSetByPump = null;
|
lastRun.setSmbSetByPump(null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (resultAfterConstraints.isChangeRequested() && allowNotification) {
|
if (resultAfterConstraints.isChangeRequested() && allowNotification) {
|
||||||
|
@ -531,15 +530,15 @@ public class LoopPlugin extends PluginBase {
|
||||||
public void acceptChangeRequest() {
|
public void acceptChangeRequest() {
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
final LoopPlugin lp = this;
|
final LoopPlugin lp = this;
|
||||||
applyTBRRequest(lastRun.constraintsProcessed, profile, new Callback() {
|
applyTBRRequest(lastRun.getConstraintsProcessed(), profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (result.enacted) {
|
if (result.enacted) {
|
||||||
lastRun.tbrSetByPump = result;
|
lastRun.setTbrSetByPump(result);
|
||||||
lastRun.lastTBRRequest = lastRun.lastAPSRun;
|
lastRun.setLastTBRRequest(lastRun.getLastAPSRun());
|
||||||
lastRun.lastTBREnact = DateUtil.now();
|
lastRun.setLastTBREnact(DateUtil.now());
|
||||||
lastRun.lastOpenModeAccept = DateUtil.now();
|
lastRun.setLastOpenModeAccept(DateUtil.now());
|
||||||
NSUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore);
|
nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventAcceptOpenLoopChange());
|
rxBus.send(new EventAcceptOpenLoopChange());
|
||||||
|
@ -773,6 +772,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
event.eventType = CareportalEvent.OPENAPSOFFLINE;
|
event.eventType = CareportalEvent.OPENAPSOFFLINE;
|
||||||
event.json = data.toString();
|
event.json = data.toString();
|
||||||
MainApp.getDbHelper().createOrUpdate(event);
|
MainApp.getDbHelper().createOrUpdate(event);
|
||||||
NSUpload.uploadOpenAPSOffline(event);
|
nsUpload.uploadOpenAPSOffline(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback;
|
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
|
|
@ -32,6 +32,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
|
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
|
@ -96,7 +97,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
||||||
openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug
|
openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug
|
||||||
}
|
}
|
||||||
if (openAPSAMAPlugin.lastAPSRun != 0L) {
|
if (openAPSAMAPlugin.lastAPSRun != 0L) {
|
||||||
openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun)
|
openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun)
|
||||||
}
|
}
|
||||||
openAPSAMAPlugin.lastAutosensResult?.let {
|
openAPSAMAPlugin.lastAutosensResult?.let {
|
||||||
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
||||||
|
|
|
@ -27,8 +27,8 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback;
|
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
|
|
@ -33,6 +33,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
|
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
|
@ -99,7 +100,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (openAPSSMBPlugin.lastAPSRun != 0L) {
|
if (openAPSSMBPlugin.lastAPSRun != 0L) {
|
||||||
openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun)
|
openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun)
|
||||||
}
|
}
|
||||||
openAPSSMBPlugin.lastAutosensResult?.let {
|
openAPSSMBPlugin.lastAutosensResult?.let {
|
||||||
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
||||||
|
|
|
@ -30,8 +30,8 @@ import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.bus
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
|
||||||
import io.reactivex.Observable
|
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import io.reactivex.subjects.PublishSubject
|
|
||||||
|
|
||||||
class RxBus {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic
|
|
||||||
@Deprecated("Get via Dagger. Will be removed once fully transitioned to Dagger")
|
|
||||||
var INSTANCE: RxBus = RxBus()//TODO: remove as soon as Dagger is fully set up
|
|
||||||
}
|
|
||||||
|
|
||||||
private val publisher = PublishSubject.create<Event>()
|
|
||||||
|
|
||||||
fun send(event: Event) {
|
|
||||||
publisher.onNext(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listen should return an Observable and not the publisher
|
|
||||||
// Using ofType we filter only events that match that class type
|
|
||||||
fun <T> toObservable(eventType: Class<T>): Observable<T> =
|
|
||||||
publisher
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.ofType(eventType)
|
|
||||||
}
|
|
|
@ -36,7 +36,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
.shortName(R.string.configbuilder_shortname)
|
.shortName(R.string.configbuilder_shortname)
|
||||||
.description(R.string.description_config_builder),
|
.description(R.string.description_config_builder),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
) {
|
), ConfigBuilderInterface {
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
(activePlugin as PluginStore).loadDefaults()
|
(activePlugin as PluginStore).loadDefaults()
|
||||||
|
@ -52,7 +52,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
storeSettings("setAlwaysEnabledPluginsEnabled")
|
storeSettings("setAlwaysEnabledPluginsEnabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun storeSettings(from: String) {
|
override fun storeSettings(from: String) {
|
||||||
activePlugin.pluginsList
|
activePlugin.pluginsList
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
||||||
activePlugin.verifySelectionInCategories()
|
activePlugin.verifySelectionInCategories()
|
||||||
|
|
|
@ -9,7 +9,8 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PluginStore @Inject constructor(
|
class PluginStore @Inject constructor(
|
||||||
val aapsLogger: AAPSLogger
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val config: Config
|
||||||
) : ActivePluginProvider {
|
) : ActivePluginProvider {
|
||||||
|
|
||||||
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
||||||
|
@ -68,7 +69,7 @@ class PluginStore @Inject constructor(
|
||||||
var pluginsInCategory: ArrayList<PluginBase>?
|
var pluginsInCategory: ArrayList<PluginBase>?
|
||||||
|
|
||||||
// PluginType.APS
|
// PluginType.APS
|
||||||
if (!Config.NSCLIENT && !Config.PUMPCONTROL) {
|
if (!config.NSCLIENT && !config.PUMPCONTROL) {
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.APS)
|
pluginsInCategory = getSpecificPluginsList(PluginType.APS)
|
||||||
activeAPS = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
activeAPS = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
||||||
if (activeAPS == null) {
|
if (activeAPS == null) {
|
||||||
|
|
|
@ -22,8 +22,8 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventNtpStatus
|
import info.nightscout.androidaps.events.EventNtpStatus
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui
|
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
||||||
|
@ -49,6 +49,8 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var objectivesPlugin: ObjectivesPlugin
|
@Inject lateinit var objectivesPlugin: ObjectivesPlugin
|
||||||
@Inject lateinit var receiverStatusStore: ReceiverStatusStore
|
@Inject lateinit var receiverStatusStore: ReceiverStatusStore
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var sntpClient: SntpClient
|
||||||
|
|
||||||
private val objectivesAdapter = ObjectivesAdapter()
|
private val objectivesAdapter = ObjectivesAdapter()
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
@ -212,7 +214,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
bundle.putInt("currentTask", taskPosition)
|
bundle.putInt("currentTask", taskPosition)
|
||||||
dialog.arguments = bundle
|
dialog.arguments = bundle
|
||||||
ObjectivesExamDialog.objective = objective
|
ObjectivesExamDialog.objective = objective
|
||||||
fragmentManager?.let { dialog.show(it, "ObjectivesFragment") }
|
dialog.show(childFragmentManager, "ObjectivesFragment")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// horizontal line
|
// horizontal line
|
||||||
|
@ -221,7 +223,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2)
|
holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
holder.accomplished.text = resourceHelper.gs(R.string.accomplished, DateUtil.dateAndTimeString(objective.accomplishedOn))
|
holder.accomplished.text = resourceHelper.gs(R.string.accomplished, dateUtil.dateAndTimeString(objective.accomplishedOn))
|
||||||
holder.accomplished.setTextColor(-0x3e3e3f)
|
holder.accomplished.setTextColor(-0x3e3e3f)
|
||||||
holder.verify.setOnClickListener {
|
holder.verify.setOnClickListener {
|
||||||
receiverStatusStore.updateNetworkStatus()
|
receiverStatusStore.updateNetworkStatus()
|
||||||
|
@ -236,7 +238,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
Thread {
|
Thread {
|
||||||
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
|
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
|
||||||
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
|
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
|
||||||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
sntpClient.ntpTime(object : SntpClient.Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
|
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||||
SystemClock.sleep(300)
|
SystemClock.sleep(300)
|
||||||
|
@ -275,7 +277,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
Thread {
|
Thread {
|
||||||
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
|
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
|
||||||
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
|
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
|
||||||
SntpClient.ntpTime(object : SntpClient.Callback() {
|
sntpClient.ntpTime(object : SntpClient.Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
|
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
|
||||||
SystemClock.sleep(300)
|
SystemClock.sleep(300)
|
||||||
|
|
|
@ -24,13 +24,14 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val activePlugin: ActivePluginProvider,
|
private val activePlugin: ActivePluginProvider,
|
||||||
private val sp: SP
|
private val sp: SP,
|
||||||
|
private val config: Config
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.fragmentClass(ObjectivesFragment::class.qualifiedName)
|
.fragmentClass(ObjectivesFragment::class.qualifiedName)
|
||||||
.alwaysEnabled(Config.APS)
|
.alwaysEnabled(config.APS)
|
||||||
.showInList(Config.APS)
|
.showInList(config.APS)
|
||||||
.pluginName(R.string.objectives)
|
.pluginName(R.string.objectives)
|
||||||
.shortName(R.string.objectives_shortname)
|
.shortName(R.string.objectives_shortname)
|
||||||
.description(R.string.description_objectives),
|
.description(R.string.description_objectives),
|
||||||
|
|
|
@ -21,6 +21,7 @@ import javax.inject.Inject
|
||||||
class ObjectivesExamDialog : DaggerDialogFragment() {
|
class ObjectivesExamDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var objective: Objective? = null
|
var objective: Objective? = null
|
||||||
|
@ -76,7 +77,7 @@ class ObjectivesExamDialog : DaggerDialogFragment() {
|
||||||
objectives_exam_hints.addView(h.generate(context))
|
objectives_exam_hints.addView(h.generate(context))
|
||||||
}
|
}
|
||||||
// Disabled to
|
// Disabled to
|
||||||
objectives_exam_disabledto.text = resourceHelper.gs(R.string.answerdisabledto, DateUtil.timeString(task.disabledTo))
|
objectives_exam_disabledto.text = resourceHelper.gs(R.string.answerdisabledto, dateUtil.timeString(task.disabledTo))
|
||||||
objectives_exam_disabledto.visibility = if (task.isEnabledAnswer) View.GONE else View.VISIBLE
|
objectives_exam_disabledto.visibility = if (task.isEnabledAnswer) View.GONE else View.VISIBLE
|
||||||
// Buttons
|
// Buttons
|
||||||
objectives_exam_verify.isEnabled = !task.answered && task.isEnabledAnswer
|
objectives_exam_verify.isEnabled = !task.answered && task.isEnabledAnswer
|
||||||
|
|
|
@ -41,7 +41,7 @@ class PhoneCheckerPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
phoneRooted = RootBeer(context).isRootedWithoutBusyBoxCheck()
|
phoneRooted = RootBeer(context).isRooted()
|
||||||
devMode = isDevModeEnabled()
|
devMode = isDevModeEnabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,6 +47,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
private HardLimits hardLimits;
|
private HardLimits hardLimits;
|
||||||
private BuildHelper buildHelper;
|
private BuildHelper buildHelper;
|
||||||
private TreatmentsPlugin treatmentsPlugin;
|
private TreatmentsPlugin treatmentsPlugin;
|
||||||
|
private Config config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SafetyPlugin(
|
public SafetyPlugin(
|
||||||
|
@ -62,7 +63,8 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
ActivePluginProvider activePlugin,
|
ActivePluginProvider activePlugin,
|
||||||
HardLimits hardLimits,
|
HardLimits hardLimits,
|
||||||
BuildHelper buildHelper,
|
BuildHelper buildHelper,
|
||||||
TreatmentsPlugin treatmentsPlugin
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
|
Config config
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
|
@ -83,6 +85,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
this.hardLimits = hardLimits;
|
this.hardLimits = hardLimits;
|
||||||
this.buildHelper = buildHelper;
|
this.buildHelper = buildHelper;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +162,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
absoluteRate.setIfGreater(getAapsLogger(), 0d, String.format(getResourceHelper().gs(R.string.limitingbasalratio), 0d, getResourceHelper().gs(R.string.itmustbepositivevalue)), this);
|
absoluteRate.setIfGreater(getAapsLogger(), 0d, String.format(getResourceHelper().gs(R.string.limitingbasalratio), 0d, getResourceHelper().gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
if (Config.APS) {
|
if (config.getAPS()) {
|
||||||
double maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1d);
|
double maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1d);
|
||||||
if (maxBasal < profile.getMaxDailyBasal()) {
|
if (maxBasal < profile.getMaxDailyBasal()) {
|
||||||
maxBasal = profile.getMaxDailyBasal();
|
maxBasal = profile.getMaxDailyBasal();
|
||||||
|
|
|
@ -116,6 +116,14 @@ class VersionCheckerUtils @Inject constructor(
|
||||||
private fun String?.toNumberList() =
|
private fun String?.toNumberList() =
|
||||||
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
||||||
|
|
||||||
|
fun versionDigits(versionString: String?): IntArray {
|
||||||
|
val digits = mutableListOf<Int>()
|
||||||
|
versionString?.numericVersionPart().toNumberList()?.let {
|
||||||
|
digits.addAll(it.take(4))
|
||||||
|
}
|
||||||
|
return digits.toIntArray()
|
||||||
|
}
|
||||||
|
|
||||||
fun findVersion(file: String?): String? {
|
fun findVersion(file: String?): String? {
|
||||||
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
|
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
|
||||||
return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull()
|
return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull()
|
||||||
|
|
|
@ -20,19 +20,20 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.SingleClickButton
|
import info.nightscout.androidaps.utils.SingleClickButton
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.actions_fragment.*
|
import kotlinx.android.synthetic.main.actions_fragment.*
|
||||||
|
@ -53,6 +54,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
@Inject lateinit var config: Config
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -68,19 +70,19 @@ class ActionsFragment : DaggerFragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
actions_profileswitch.setOnClickListener {
|
actions_profileswitch.setOnClickListener {
|
||||||
fragmentManager?.let { ProfileSwitchDialog().show(it, "Actions") }
|
ProfileSwitchDialog().show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_temptarget.setOnClickListener {
|
actions_temptarget.setOnClickListener {
|
||||||
fragmentManager?.let { TempTargetDialog().show(it, "Actions") }
|
TempTargetDialog().show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_extendedbolus.setOnClickListener {
|
actions_extendedbolus.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable {
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable {
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop),
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop),
|
||||||
Runnable {
|
Runnable {
|
||||||
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
|
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
||||||
}, null)
|
}, null)
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions_extendedbolus_cancel.setOnClickListener {
|
actions_extendedbolus_cancel.setOnClickListener {
|
||||||
|
@ -101,7 +103,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions_settempbasal.setOnClickListener {
|
actions_settempbasal.setOnClickListener {
|
||||||
fragmentManager?.let { TempBasalDialog().show(it, "Actions") }
|
TempBasalDialog().show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_canceltempbasal.setOnClickListener {
|
actions_canceltempbasal.setOnClickListener {
|
||||||
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
||||||
|
@ -122,25 +124,31 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
actions_fill.setOnClickListener {
|
actions_fill.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { fragmentManager?.let { FillDialog().show(it, "FillDialog") } })
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { FillDialog().show(childFragmentManager, "FillDialog") }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
||||||
actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
||||||
actions_bgcheck.setOnClickListener {
|
actions_bgcheck.setOnClickListener {
|
||||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(it, "Actions") }
|
CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_cgmsensorinsert.setOnClickListener {
|
actions_cgmsensorinsert.setOnClickListener {
|
||||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(it, "Actions") }
|
CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_pumpbatterychange.setOnClickListener {
|
actions_pumpbatterychange.setOnClickListener {
|
||||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(it, "Actions") }
|
CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_note.setOnClickListener {
|
actions_note.setOnClickListener {
|
||||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(it, "Actions") }
|
CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
actions_exercise.setOnClickListener {
|
actions_exercise.setOnClickListener {
|
||||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(it, "Actions") }
|
CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(childFragmentManager, "Actions")
|
||||||
|
}
|
||||||
|
actions_question.setOnClickListener {
|
||||||
|
CareDialog().setOptions(CareDialog.EventType.QUESTION, R.string.careportal_question).show(childFragmentManager, "Actions")
|
||||||
|
}
|
||||||
|
actions_announcement.setOnClickListener {
|
||||||
|
CareDialog().setOptions(CareDialog.EventType.ANNOUNCEMENT, R.string.careportal_announcement).show(childFragmentManager, "Actions")
|
||||||
}
|
}
|
||||||
|
|
||||||
sp.putBoolean(R.string.key_objectiveuseactions, true)
|
sp.putBoolean(R.string.key_objectiveuseactions, true)
|
||||||
|
@ -190,13 +198,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
|
|
||||||
actions_temptarget?.visibility = (profile != null).toVisibility()
|
actions_temptarget?.visibility = (profile != null).toVisibility()
|
||||||
actions_canceltempbasal.visibility = (profile == null).toVisibility()
|
actions_historybrowser.visibility = (profile != null).toVisibility()
|
||||||
actions_settempbasal.visibility = (profile == null).toVisibility()
|
|
||||||
actions_fill.visibility = (profile == null).toVisibility()
|
|
||||||
actions_extendedbolus.visibility = (profile == null).toVisibility()
|
|
||||||
actions_extendedbolus_cancel.visibility = (profile == null).toVisibility()
|
|
||||||
actions_historybrowser.visibility = (profile == null).toVisibility()
|
|
||||||
actions_tddstats.visibility = (profile == null).toVisibility()
|
|
||||||
|
|
||||||
val basalProfileEnabled = buildHelper.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
val basalProfileEnabled = buildHelper.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
||||||
|
|
||||||
|
@ -238,7 +240,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE
|
if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE
|
||||||
else View.VISIBLE
|
else View.VISIBLE
|
||||||
|
|
||||||
actions_temptarget?.visibility = Config.APS.toVisibility()
|
actions_temptarget?.visibility = config.APS.toVisibility()
|
||||||
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
||||||
checkPumpCustomActions()
|
checkPumpCustomActions()
|
||||||
|
|
|
@ -15,12 +15,13 @@ import javax.inject.Singleton
|
||||||
class ActionsPlugin @Inject constructor(
|
class ActionsPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper
|
resourceHelper: ResourceHelper,
|
||||||
|
config: Config
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(ActionsFragment::class.qualifiedName)
|
.fragmentClass(ActionsFragment::class.qualifiedName)
|
||||||
.enableByDefault(Config.APS || Config.PUMPCONTROL)
|
.enableByDefault(config.APS || config.PUMPCONTROL)
|
||||||
.visibleByDefault(Config.APS || Config.PUMPCONTROL)
|
.visibleByDefault(config.APS || config.PUMPCONTROL)
|
||||||
.pluginName(R.string.actions)
|
.pluginName(R.string.actions)
|
||||||
.shortName(R.string.actions_shortname)
|
.shortName(R.string.actions_shortname)
|
||||||
.description(R.string.description_actions),
|
.description(R.string.description_actions),
|
||||||
|
|
|
@ -72,7 +72,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
args.putString("event", AutomationEvent(mainApp).toJSON())
|
args.putString("event", AutomationEvent(mainApp).toJSON())
|
||||||
args.putInt("position", -1) // New event
|
args.putInt("position", -1) // New event
|
||||||
dialog.arguments = args
|
dialog.arguments = args
|
||||||
fragmentManager?.let { dialog.show(it, "EditEventDialog") }
|
dialog.show(childFragmentManager, "EditEventDialog")
|
||||||
}
|
}
|
||||||
|
|
||||||
val callback: ItemTouchHelper.Callback = SimpleItemTouchHelperCallback(eventListAdapter)
|
val callback: ItemTouchHelper.Callback = SimpleItemTouchHelperCallback(eventListAdapter)
|
||||||
|
@ -182,7 +182,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
args.putString("event", event.toJSON())
|
args.putString("event", event.toJSON())
|
||||||
args.putInt("position", position)
|
args.putInt("position", position)
|
||||||
dialog.arguments = args
|
dialog.arguments = args
|
||||||
fragmentManager?.let { dialog.show(it, "EditEventDialog") }
|
dialog.show(childFragmentManager, "EditEventDialog")
|
||||||
}
|
}
|
||||||
// Start a drag whenever the handle view it touched
|
// Start a drag whenever the handle view it touched
|
||||||
holder.iconSort.setOnTouchListener { v: View, motionEvent: MotionEvent ->
|
holder.iconSort.setOnTouchListener { v: View, motionEvent: MotionEvent ->
|
||||||
|
|
|
@ -37,7 +37,6 @@ import io.reactivex.schedulers.Schedulers
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
@ -52,7 +51,8 @@ class AutomationPlugin @Inject constructor(
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val constraintChecker: ConstraintChecker,
|
private val constraintChecker: ConstraintChecker,
|
||||||
aapsLogger: AAPSLogger
|
aapsLogger: AAPSLogger,
|
||||||
|
private val dateUtil: DateUtil
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(AutomationFragment::class.qualifiedName)
|
.fragmentClass(AutomationFragment::class.qualifiedName)
|
||||||
|
@ -197,7 +197,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
action.doAction(object : Callback() {
|
action.doAction(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
sb.append(DateUtil.timeString(DateUtil.now()))
|
sb.append(dateUtil.timeString(DateUtil.now()))
|
||||||
sb.append(" ")
|
sb.append(" ")
|
||||||
sb.append(if (result.success) "☺" else "▼")
|
sb.append(if (result.success) "☺" else "▼")
|
||||||
sb.append(" <b>")
|
sb.append(" <b>")
|
||||||
|
|
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithE
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationUserMessage
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationUserMessage
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
@ -23,6 +22,7 @@ import javax.inject.Inject
|
||||||
class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
|
|
||||||
var text = InputString(injector)
|
var text = InputString(injector)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
val notification = NotificationUserMessage(text.value)
|
val notification = NotificationUserMessage(text.value)
|
||||||
rxBus.send(EventNewNotification(notification))
|
rxBus.send(EventNewNotification(notification))
|
||||||
NSUpload.uploadError(text.value)
|
nsUpload.uploadError(text.value)
|
||||||
rxBus.send(EventRefreshOverview("ActionNotification"))
|
rxBus.send(EventRefreshOverview("ActionNotification"))
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
val result = smsCommunicatorPlugin.sendNotificationToAllNumbers(text.value)
|
val result = smsCommunicatorPlugin.sendNotificationToAllNumbers(text.value)
|
||||||
callback.result(PumpEnactResult(injector).success(result).comment(if (result) R.string.ok else R.string.danar_error))?.run()
|
callback.result(PumpEnactResult(injector).success(result).comment(if (result) R.string.ok else R.string.error))?.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toJSON(): String {
|
override fun toJSON(): String {
|
||||||
|
|
|
@ -66,15 +66,15 @@ class EditEventDialog : DialogFragmentWithDate() {
|
||||||
args.putString("trigger", event.trigger.toJSON())
|
args.putString("trigger", event.trigger.toJSON())
|
||||||
val dialog = EditTriggerDialog()
|
val dialog = EditTriggerDialog()
|
||||||
dialog.arguments = args
|
dialog.arguments = args
|
||||||
fragmentManager?.let { dialog.show(it, "EditTriggerDialog") }
|
dialog.show(childFragmentManager, "EditTriggerDialog")
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup action list view
|
// setup action list view
|
||||||
fragmentManager?.let { actionListAdapter = ActionListAdapter() }
|
actionListAdapter = ActionListAdapter()
|
||||||
automation_actionListView.layoutManager = LinearLayoutManager(context)
|
automation_actionListView.layoutManager = LinearLayoutManager(context)
|
||||||
automation_actionListView.adapter = actionListAdapter
|
automation_actionListView.adapter = actionListAdapter
|
||||||
|
|
||||||
automation_addAction.setOnClickListener { fragmentManager?.let { ChooseActionDialog().show(it, "ChooseActionDialog") } }
|
automation_addAction.setOnClickListener { ChooseActionDialog().show(childFragmentManager, "ChooseActionDialog") }
|
||||||
|
|
||||||
showPreconditions()
|
showPreconditions()
|
||||||
|
|
||||||
|
@ -187,9 +187,7 @@ class EditEventDialog : DialogFragmentWithDate() {
|
||||||
args.putString("action", action.toJSON())
|
args.putString("action", action.toJSON())
|
||||||
val dialog = EditActionDialog()
|
val dialog = EditActionDialog()
|
||||||
dialog.arguments = args
|
dialog.arguments = args
|
||||||
fragmentManager?.let {
|
dialog.show(childFragmentManager, "EditActionDialog")
|
||||||
dialog.show(it, "EditActionDialog")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.findViewById<ImageView>(R.id.automation_iconTrash).setOnClickListener {
|
view.findViewById<ImageView>(R.id.automation_iconTrash).setOnClickListener {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.widget.LinearLayout
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.inject.Inject
|
||||||
class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
|
class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
var value: Long = DateUtil.now()
|
var value: Long = DateUtil.now()
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
val dateButton = TextView(root.context)
|
val dateButton = TextView(root.context)
|
||||||
val timeButton = TextView(root.context)
|
val timeButton = TextView(root.context)
|
||||||
dateButton.text = DateUtil.dateString(value)
|
dateButton.text = DateUtil.dateString(value)
|
||||||
timeButton.text = DateUtil.timeString(value)
|
timeButton.text = dateUtil.timeString(value)
|
||||||
|
|
||||||
// create an OnDateSetListener
|
// create an OnDateSetListener
|
||||||
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
|
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
|
||||||
|
@ -63,7 +64,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
cal.set(Calendar.MINUTE, minute)
|
cal.set(Calendar.MINUTE, minute)
|
||||||
cal.set(Calendar.SECOND, 0) // randomize seconds to prevent creating record of the same time, if user choose time manually
|
cal.set(Calendar.SECOND, 0) // randomize seconds to prevent creating record of the same time, if user choose time manually
|
||||||
value = cal.timeInMillis
|
value = cal.timeInMillis
|
||||||
timeButton.text = DateUtil.timeString(value)
|
timeButton.text = dateUtil.timeString(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
timeButton.setOnClickListener {
|
timeButton.setOnClickListener {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -20,17 +19,18 @@ import javax.inject.Inject
|
||||||
class InputTime(injector: HasAndroidInjector) : Element(injector) {
|
class InputTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
var value: Int = getMinSinceMidnight(DateUtil.now())
|
var value: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
|
|
||||||
override fun addToLayout(root: LinearLayout) {
|
override fun addToLayout(root: LinearLayout) {
|
||||||
val label = TextView(root.context)
|
val label = TextView(root.context)
|
||||||
val startButton = TextView(root.context)
|
val startButton = TextView(root.context)
|
||||||
startButton.text = DateUtil.timeString(toMills(value))
|
startButton.text = dateUtil.timeString(toMills(value))
|
||||||
|
|
||||||
val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
||||||
value = 60 * hour + minute
|
value = 60 * hour + minute
|
||||||
startButton.text = DateUtil.timeString(toMills(value))
|
startButton.text = dateUtil.timeString(toMills(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
startButton.setOnClickListener {
|
startButton.setOnClickListener {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -20,6 +19,7 @@ import javax.inject.Inject
|
||||||
class InputTimeRange(injector: HasAndroidInjector) : Element(injector) {
|
class InputTimeRange(injector: HasAndroidInjector) : Element(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
var start: Int = getMinSinceMidnight(DateUtil.now())
|
var start: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
var end: Int = getMinSinceMidnight(DateUtil.now())
|
var end: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
|
@ -28,13 +28,13 @@ class InputTimeRange(injector: HasAndroidInjector) : Element(injector) {
|
||||||
val label = TextView(root.context)
|
val label = TextView(root.context)
|
||||||
val startButton = TextView(root.context)
|
val startButton = TextView(root.context)
|
||||||
val endButton = TextView(root.context)
|
val endButton = TextView(root.context)
|
||||||
startButton.text = DateUtil.timeString(toMills(start))
|
startButton.text = dateUtil.timeString(toMills(start))
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
endButton.text = resourceHelper.gs(R.string.and) + " " + DateUtil.timeString(toMills(end))
|
endButton.text = resourceHelper.gs(R.string.and) + " " + dateUtil.timeString(toMills(end))
|
||||||
|
|
||||||
val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
val startTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
||||||
start = 60 * hour + minute
|
start = 60 * hour + minute
|
||||||
startButton.text = DateUtil.timeString(toMills(start))
|
startButton.text = dateUtil.timeString(toMills(start))
|
||||||
}
|
}
|
||||||
|
|
||||||
startButton.setOnClickListener {
|
startButton.setOnClickListener {
|
||||||
|
@ -51,7 +51,7 @@ class InputTimeRange(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
|
||||||
val endTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
val endTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
||||||
end = 60 * hour + minute
|
end = 60 * hour + minute
|
||||||
endButton.text = DateUtil.timeString(toMills(end))
|
endButton.text = dateUtil.timeString(toMills(end))
|
||||||
}
|
}
|
||||||
|
|
||||||
endButton.setOnClickListener {
|
endButton.setOnClickListener {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged
|
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone
|
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone
|
||||||
|
|
|
@ -13,11 +13,13 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
val days = InputWeekDay(injector)
|
val days = InputWeekDay(injector)
|
||||||
val time = InputTime(injector)
|
val time = InputTime(injector)
|
||||||
|
|
||||||
|
@ -27,9 +29,9 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
System.arraycopy(triggerRecurringTime.days.weekdays, 0, days.weekdays, 0, triggerRecurringTime.days.weekdays.size)
|
System.arraycopy(triggerRecurringTime.days.weekdays, 0, days.weekdays, 0, triggerRecurringTime.days.weekdays.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun time(minutes:Int): TriggerRecurringTime {
|
fun time(minutes: Int): TriggerRecurringTime {
|
||||||
time.value = minutes
|
time.value = minutes
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -85,7 +87,7 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
sb.append(resourceHelper.gs(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(i)).shortName))
|
sb.append(resourceHelper.gs(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(i)).shortName))
|
||||||
}
|
}
|
||||||
sb.append(" ")
|
sb.append(" ")
|
||||||
sb.append(DateUtil.timeString(toMills(time.value)))
|
sb.append(dateUtil.timeString(toMills(time.value)))
|
||||||
return if (counter == 0) resourceHelper.gs(R.string.never) else sb.toString()
|
return if (counter == 0) resourceHelper.gs(R.string.never) else sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.google.common.base.Optional
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
||||||
|
|
|
@ -12,8 +12,11 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
|
class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
var time = InputDateTime(injector)
|
var time = InputDateTime(injector)
|
||||||
|
|
||||||
constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) {
|
constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) {
|
||||||
|
@ -57,7 +60,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
override fun friendlyName(): Int = R.string.time
|
override fun friendlyName(): Int = R.string.time
|
||||||
|
|
||||||
override fun friendlyDescription(): String =
|
override fun friendlyDescription(): String =
|
||||||
resourceHelper.gs(R.string.atspecifiedtime, DateUtil.dateAndTimeString(time.value))
|
resourceHelper.gs(R.string.atspecifiedtime, dateUtil.dateAndTimeString(time.value))
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,14 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetInt
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetInt
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
// Trigger for time range ( from 10:00AM till 13:00PM )
|
// Trigger for time range ( from 10:00AM till 13:00PM )
|
||||||
class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
|
class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
// in minutes since midnight 60 means 1AM
|
// in minutes since midnight 60 means 1AM
|
||||||
var range = InputTimeRange(injector)
|
var range = InputTimeRange(injector)
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
range.end = triggerTimeRange.range.end
|
range.end = triggerTimeRange.range.end
|
||||||
}
|
}
|
||||||
|
|
||||||
fun period(start: Int, end:Int) : TriggerTimeRange {
|
fun period(start: Int, end: Int): TriggerTimeRange {
|
||||||
this.range.start = start
|
this.range.start = start
|
||||||
this.range.end = end
|
this.range.end = end
|
||||||
return this
|
return this
|
||||||
|
@ -70,7 +72,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
override fun friendlyName(): Int = R.string.time_range
|
override fun friendlyName(): Int = R.string.time_range
|
||||||
|
|
||||||
override fun friendlyDescription(): String =
|
override fun friendlyDescription(): String =
|
||||||
resourceHelper.gs(R.string.timerange_value, DateUtil.timeString(toMills(range.start)), DateUtil.timeString(toMills(range.end)))
|
resourceHelper.gs(R.string.timerange_value, dateUtil.timeString(toMills(range.start)), dateUtil.timeString(toMills(range.end)))
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputStrin
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
||||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver
|
|
||||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.careportal
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import dagger.android.support.DaggerFragment
|
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
|
||||||
import kotlinx.android.synthetic.main.careportal_fragment.*
|
|
||||||
import kotlinx.android.synthetic.main.careportal_stats_fragment.*
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
|
||||||
@Inject lateinit var statusLightHandler: StatusLightHandler
|
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.careportal_fragment, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
careportal_bgcheck.setOnClickListener(this)
|
|
||||||
careportal_announcement.setOnClickListener(this)
|
|
||||||
careportal_cgmsensorinsert.setOnClickListener(this)
|
|
||||||
careportal_cgmsensorstart.setOnClickListener(this)
|
|
||||||
careportal_combobolus.setOnClickListener(this)
|
|
||||||
careportal_correctionbolus.setOnClickListener(this)
|
|
||||||
careportal_carbscorrection.setOnClickListener(this)
|
|
||||||
careportal_exercise.setOnClickListener(this)
|
|
||||||
careportal_insulincartridgechange.setOnClickListener(this)
|
|
||||||
careportal_pumpbatterychange.setOnClickListener(this)
|
|
||||||
careportal_mealbolus.setOnClickListener(this)
|
|
||||||
careportal_note.setOnClickListener(this)
|
|
||||||
careportal_profileswitch.setOnClickListener(this)
|
|
||||||
careportal_pumpsitechange.setOnClickListener(this)
|
|
||||||
careportal_question.setOnClickListener(this)
|
|
||||||
careportal_snackbolus.setOnClickListener(this)
|
|
||||||
careportal_tempbasalend.setOnClickListener(this)
|
|
||||||
careportal_tempbasalstart.setOnClickListener(this)
|
|
||||||
careportal_openapsoffline.setOnClickListener(this)
|
|
||||||
careportal_temporarytarget.setOnClickListener(this)
|
|
||||||
|
|
||||||
val profileStore = activePlugin.activeProfileInterface.profile
|
|
||||||
if (profileStore == null) {
|
|
||||||
profileview_noprofile.visibility = View.VISIBLE
|
|
||||||
careportal_buttons.visibility = View.GONE
|
|
||||||
} else {
|
|
||||||
profileview_noprofile.visibility = View.GONE
|
|
||||||
careportal_buttons.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
disposable.add(rxBus
|
|
||||||
.toObservable(EventCareportalEventChange::class.java)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe({ updateGUI() }) { fabricPrivacy.logException(it) }
|
|
||||||
)
|
|
||||||
updateGUI()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
disposable.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(view: View) {
|
|
||||||
val BGCHECK = OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck).date().bg()
|
|
||||||
val SNACKBOLUS = OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus).date().bg().insulin().carbs().prebolus()
|
|
||||||
val MEALBOLUS = OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus).date().bg().insulin().carbs().prebolus()
|
|
||||||
val CORRECTIONBOLUS = OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus).date().bg().insulin().carbs().prebolus()
|
|
||||||
val CARBCORRECTION = OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection).date().bg().carbs()
|
|
||||||
val COMBOBOLUS = OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus).date().bg().insulin().carbs().prebolus().duration().split()
|
|
||||||
val ANNOUNCEMENT = OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement).date().bg()
|
|
||||||
val NOTE = OptionsToShow(R.id.careportal_note, R.string.careportal_note).date().bg().duration()
|
|
||||||
val QUESTION = OptionsToShow(R.id.careportal_question, R.string.careportal_question).date().bg()
|
|
||||||
val EXERCISE = OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise).date().duration()
|
|
||||||
val SITECHANGE = OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange).date().bg()
|
|
||||||
val SENSORSTART = OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart).date().bg()
|
|
||||||
val SENSORCHANGE = OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert).date().bg()
|
|
||||||
val INSULINCHANGE = OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange).date().bg()
|
|
||||||
val PUMPBATTERYCHANGE = OptionsToShow(R.id.careportal_pumpbatterychange, R.string.careportal_pumpbatterychange).date().bg()
|
|
||||||
val TEMPBASALSTART = OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart).date().bg().duration().percent().absolute()
|
|
||||||
val TEMPBASALEND = OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend).date().bg()
|
|
||||||
val PROFILESWITCH = OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch).date().duration().profile()
|
|
||||||
val OPENAPSOFFLINE = OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline).date().duration()
|
|
||||||
val TEMPTARGET = OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget).date().duration().tempTarget()
|
|
||||||
|
|
||||||
val newDialog = NewNSTreatmentDialog()
|
|
||||||
when (view.id) {
|
|
||||||
R.id.careportal_bgcheck -> newDialog.setOptions(BGCHECK, R.string.careportal_bgcheck)
|
|
||||||
R.id.careportal_announcement -> newDialog.setOptions(ANNOUNCEMENT, R.string.careportal_announcement)
|
|
||||||
R.id.careportal_cgmsensorinsert -> newDialog.setOptions(SENSORCHANGE, R.string.careportal_cgmsensorinsert)
|
|
||||||
R.id.careportal_cgmsensorstart -> newDialog.setOptions(SENSORSTART, R.string.careportal_cgmsensorstart)
|
|
||||||
R.id.careportal_combobolus -> newDialog.setOptions(COMBOBOLUS, R.string.careportal_combobolus)
|
|
||||||
R.id.careportal_correctionbolus -> newDialog.setOptions(CORRECTIONBOLUS, R.string.careportal_correctionbolus)
|
|
||||||
R.id.careportal_carbscorrection -> newDialog.setOptions(CARBCORRECTION, R.string.careportal_carbscorrection)
|
|
||||||
R.id.careportal_exercise -> newDialog.setOptions(EXERCISE, R.string.careportal_exercise)
|
|
||||||
R.id.careportal_insulincartridgechange -> newDialog.setOptions(INSULINCHANGE, R.string.careportal_insulincartridgechange)
|
|
||||||
R.id.careportal_pumpbatterychange -> newDialog.setOptions(PUMPBATTERYCHANGE, R.string.careportal_pumpbatterychange)
|
|
||||||
R.id.careportal_mealbolus -> newDialog.setOptions(MEALBOLUS, R.string.careportal_mealbolus)
|
|
||||||
R.id.careportal_note -> newDialog.setOptions(NOTE, R.string.careportal_note)
|
|
||||||
R.id.careportal_profileswitch -> newDialog.setOptions(PROFILESWITCH, R.string.careportal_profileswitch)
|
|
||||||
R.id.careportal_pumpsitechange -> newDialog.setOptions(SITECHANGE, R.string.careportal_pumpsitechange)
|
|
||||||
R.id.careportal_question -> newDialog.setOptions(QUESTION, R.string.careportal_question)
|
|
||||||
R.id.careportal_snackbolus -> newDialog.setOptions(SNACKBOLUS, R.string.careportal_snackbolus)
|
|
||||||
R.id.careportal_tempbasalstart -> newDialog.setOptions(TEMPBASALSTART, R.string.careportal_tempbasalstart)
|
|
||||||
R.id.careportal_tempbasalend -> newDialog.setOptions(TEMPBASALEND, R.string.careportal_tempbasalend)
|
|
||||||
R.id.careportal_openapsoffline -> newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline)
|
|
||||||
R.id.careportal_temporarytarget -> newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget)
|
|
||||||
}
|
|
||||||
fragmentManager?.let {
|
|
||||||
NewNSTreatmentDialog().show(it, "CareportalFragment")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateGUI() {
|
|
||||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.careportal
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.Config
|
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class CareportalPlugin @Inject constructor(
|
|
||||||
injector: HasAndroidInjector,
|
|
||||||
aapsLogger: AAPSLogger,
|
|
||||||
resourceHelper: ResourceHelper
|
|
||||||
) : PluginBase(PluginDescription()
|
|
||||||
.mainType(PluginType.GENERAL)
|
|
||||||
.fragmentClass(CareportalFragment::class.java.name)
|
|
||||||
.pluginName(R.string.careportal)
|
|
||||||
.shortName(R.string.careportal_shortname)
|
|
||||||
.visibleByDefault(Config.NSCLIENT)
|
|
||||||
.enableByDefault(Config.NSCLIENT)
|
|
||||||
.description(R.string.description_careportal),
|
|
||||||
aapsLogger, resourceHelper, injector
|
|
||||||
)
|
|
|
@ -1,738 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.careportal.Dialogs;
|
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.StringRes;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
|
||||||
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import dagger.android.support.DaggerDialogFragment;
|
|
||||||
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.data.ProfileStore;
|
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
|
||||||
import info.nightscout.androidaps.utils.Translator;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
|
|
||||||
public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
|
|
||||||
@Inject HasAndroidInjector injector;
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
|
||||||
@Inject DefaultValueHelper defaultValueHelper;
|
|
||||||
@Inject ProfileFunction profileFunction;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
|
||||||
@Inject ConstraintChecker constraintChecker;
|
|
||||||
@Inject SP sp;
|
|
||||||
@Inject ActivePluginProvider activePlugin;
|
|
||||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
|
||||||
@Inject HardLimits hardLimits;
|
|
||||||
@Inject Translator translator;
|
|
||||||
|
|
||||||
private static OptionsToShow options;
|
|
||||||
private static @StringRes int event;
|
|
||||||
|
|
||||||
private Profile profile;
|
|
||||||
public ProfileStore profileStore;
|
|
||||||
|
|
||||||
TextView eventTypeText;
|
|
||||||
LinearLayout layoutPercent;
|
|
||||||
LinearLayout layoutAbsolute;
|
|
||||||
LinearLayout layoutReuse;
|
|
||||||
|
|
||||||
|
|
||||||
TextView dateButton;
|
|
||||||
TextView timeButton;
|
|
||||||
|
|
||||||
TextView bgUnitsView;
|
|
||||||
RadioButton meterRadioButton;
|
|
||||||
RadioButton sensorRadioButton;
|
|
||||||
RadioButton otherRadioButton;
|
|
||||||
EditText notesEdit;
|
|
||||||
Spinner profileSpinner;
|
|
||||||
Spinner reasonSpinner;
|
|
||||||
Button reuseButton;
|
|
||||||
|
|
||||||
NumberPicker editBg;
|
|
||||||
NumberPicker editCarbs;
|
|
||||||
NumberPicker editInsulin;
|
|
||||||
NumberPicker editSplit;
|
|
||||||
NumberPicker editDuration;
|
|
||||||
NumberPicker editPercent;
|
|
||||||
NumberPicker editAbsolute;
|
|
||||||
NumberPicker editCarbTime;
|
|
||||||
NumberPicker editTemptarget;
|
|
||||||
NumberPicker editPercentage;
|
|
||||||
NumberPicker editTimeshift;
|
|
||||||
|
|
||||||
Date eventTime;
|
|
||||||
|
|
||||||
private static Integer seconds = null;
|
|
||||||
|
|
||||||
public NewNSTreatmentDialog setOptions(OptionsToShow options, int event) {
|
|
||||||
this.options = options;
|
|
||||||
this.event = event;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewNSTreatmentDialog() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
if (seconds == null) {
|
|
||||||
seconds = Double.valueOf(Math.random() * 59).intValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
if (options == null) return null;
|
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|
||||||
setCancelable(true);
|
|
||||||
getDialog().setCanceledOnTouchOutside(false);
|
|
||||||
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
|
||||||
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
|
||||||
|
|
||||||
layoutPercent = view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
|
||||||
layoutAbsolute = view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
|
||||||
|
|
||||||
layoutReuse = view.findViewById(R.id.careportal_newnstreatment_reuse_layout);
|
|
||||||
|
|
||||||
eventTypeText = view.findViewById(R.id.careportal_newnstreatment_eventtype);
|
|
||||||
eventTypeText.setText(event);
|
|
||||||
bgUnitsView = view.findViewById(R.id.careportal_newnstreatment_bgunits);
|
|
||||||
meterRadioButton = view.findViewById(R.id.careportal_newnstreatment_meter);
|
|
||||||
sensorRadioButton = view.findViewById(R.id.careportal_newnstreatment_sensor);
|
|
||||||
otherRadioButton = view.findViewById(R.id.careportal_newnstreatment_other);
|
|
||||||
profileSpinner = view.findViewById(R.id.careportal_newnstreatment_profile);
|
|
||||||
|
|
||||||
reuseButton = view.findViewById(R.id.careportal_newnstreatment_reusebutton);
|
|
||||||
|
|
||||||
notesEdit = view.findViewById(R.id.careportal_newnstreatment_notes);
|
|
||||||
|
|
||||||
reasonSpinner = view.findViewById(R.id.careportal_newnstreatment_temptarget_reason);
|
|
||||||
|
|
||||||
eventTime = new Date();
|
|
||||||
dateButton = view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
|
||||||
timeButton = view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
|
||||||
dateButton.setText(DateUtil.dateString(eventTime));
|
|
||||||
timeButton.setText(DateUtil.timeString(eventTime));
|
|
||||||
dateButton.setOnClickListener(this);
|
|
||||||
timeButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
|
||||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
|
||||||
|
|
||||||
// profile
|
|
||||||
profile = profileFunction.getProfile();
|
|
||||||
profileStore = activePlugin.getActiveProfileInterface().getProfile();
|
|
||||||
if (profileStore == null) {
|
|
||||||
if (options.eventType == R.id.careportal_profileswitch) {
|
|
||||||
aapsLogger.error("Profile switch called but plugin doesn't contain valid profile");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ArrayList<CharSequence> profileList;
|
|
||||||
profileList = profileStore.getProfileList();
|
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
|
||||||
R.layout.spinner_centered, profileList);
|
|
||||||
profileSpinner.setAdapter(adapter);
|
|
||||||
// set selected to actual profile
|
|
||||||
for (int p = 0; p < profileList.size(); p++) {
|
|
||||||
if (profileList.get(p).equals(profileFunction.getProfileName(false)))
|
|
||||||
profileSpinner.setSelection(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Double bg = Profile.fromMgdlToUnits(new GlucoseStatus(injector).getGlucoseStatusData() != null ? new GlucoseStatus(injector).getGlucoseStatusData().glucose : 0d, profileFunction.getUnits());
|
|
||||||
|
|
||||||
// temp target
|
|
||||||
final List<String> reasonList = Lists.newArrayList(
|
|
||||||
resourceHelper.gs(R.string.manual),
|
|
||||||
resourceHelper.gs(R.string.eatingsoon),
|
|
||||||
resourceHelper.gs(R.string.activity),
|
|
||||||
resourceHelper.gs(R.string.hypo));
|
|
||||||
ArrayAdapter<String> adapterReason = new ArrayAdapter<>(getContext(),
|
|
||||||
R.layout.spinner_centered, reasonList);
|
|
||||||
reasonSpinner.setAdapter(adapterReason);
|
|
||||||
reasonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
double defaultDuration;
|
|
||||||
double defaultTarget;
|
|
||||||
if (profile != null && editTemptarget.getValue().equals(bg)) {
|
|
||||||
defaultTarget = bg;
|
|
||||||
} else {
|
|
||||||
//prevent changes on screen rotate
|
|
||||||
defaultTarget = editTemptarget.getValue();
|
|
||||||
}
|
|
||||||
boolean erase = false;
|
|
||||||
|
|
||||||
if (resourceHelper.gs(R.string.eatingsoon).equals(reasonList.get(position))) {
|
|
||||||
defaultDuration = defaultValueHelper.determineEatingSoonTTDuration();
|
|
||||||
defaultTarget = defaultValueHelper.determineEatingSoonTT();
|
|
||||||
} else if (resourceHelper.gs(R.string.activity).equals(reasonList.get(position))) {
|
|
||||||
defaultDuration = defaultValueHelper.determineActivityTTDuration();
|
|
||||||
defaultTarget = defaultValueHelper.determineActivityTT();
|
|
||||||
} else if (resourceHelper.gs(R.string.hypo).equals(reasonList.get(position))) {
|
|
||||||
defaultDuration = defaultValueHelper.determineHypoTTDuration();
|
|
||||||
defaultTarget = defaultValueHelper.determineHypoTT();
|
|
||||||
} else if (editDuration.getValue() != 0) {
|
|
||||||
defaultDuration = editDuration.getValue();
|
|
||||||
} else {
|
|
||||||
defaultDuration = 0;
|
|
||||||
erase = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defaultTarget != 0 || erase) {
|
|
||||||
editTemptarget.setValue(defaultTarget);
|
|
||||||
}
|
|
||||||
if (defaultDuration != 0) {
|
|
||||||
editDuration.setValue(defaultDuration);
|
|
||||||
} else if (erase) {
|
|
||||||
editDuration.setValue(0d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// bg
|
|
||||||
bgUnitsView.setText(profileFunction.getUnits());
|
|
||||||
|
|
||||||
TextWatcher bgTextWatcher = new TextWatcher() {
|
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
editBg = view.findViewById(R.id.careportal_newnstreatment_bginput);
|
|
||||||
editTemptarget = view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
|
||||||
if (profile == null) {
|
|
||||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
|
||||||
editTemptarget.setParams(Constants.MIN_TT_MGDL, Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
|
||||||
} else if (profileFunction.getUnits().equals(Constants.MMOL)) {
|
|
||||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
|
||||||
editTemptarget.setParams(Constants.MIN_TT_MMOL, Constants.MIN_TT_MMOL, Constants.MAX_TT_MMOL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
|
||||||
} else {
|
|
||||||
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
|
||||||
editTemptarget.setParams(Constants.MIN_TT_MGDL, Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
}
|
|
||||||
|
|
||||||
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
||||||
double bg1 = Profile.fromMgdlToUnits(new GlucoseStatus(injector).getGlucoseStatusData() != null ? new GlucoseStatus(injector).getGlucoseStatusData().glucose : 0d, profileFunction.getUnits());
|
|
||||||
if (savedInstanceState != null && savedInstanceState.getDouble("editBg") != bg1) {
|
|
||||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
|
||||||
} else {
|
|
||||||
editBg.setValue(bg1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Integer maxCarbs = constraintChecker.getMaxCarbsAllowed().value();
|
|
||||||
editCarbs = view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
Double maxInsulin = constraintChecker.getMaxBolusAllowed().value();
|
|
||||||
editInsulin = view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
editSplit = view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
|
||||||
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok));
|
|
||||||
editDuration = view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
|
||||||
editDuration.setParams(0d, 0d, Constants.MAX_PROFILE_SWITCH_DURATION, 10d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
TextWatcher percentTextWatcher = new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
|
||||||
int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start,
|
|
||||||
int before, int count) {
|
|
||||||
layoutPercent.setVisibility(View.VISIBLE);
|
|
||||||
layoutAbsolute.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Integer maxPercent = 200;
|
|
||||||
if (profile != null)
|
|
||||||
maxPercent = constraintChecker.getMaxBasalPercentAllowed(profile).value();
|
|
||||||
editPercent = view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
|
||||||
editPercent.setParams(0d, -100d, (double) maxPercent, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok), percentTextWatcher);
|
|
||||||
|
|
||||||
TextWatcher absoluteTextWatcher = new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
|
||||||
int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start,
|
|
||||||
int before, int count) {
|
|
||||||
layoutPercent.setVisibility(View.GONE);
|
|
||||||
layoutAbsolute.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Double maxAbsolute = hardLimits.maxBasal();
|
|
||||||
if (profile != null)
|
|
||||||
maxAbsolute = constraintChecker.getMaxBasalAllowed(profile).value();
|
|
||||||
editAbsolute = view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
|
||||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, view.findViewById(R.id.ok), absoluteTextWatcher);
|
|
||||||
|
|
||||||
editCarbTime = view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
editPercentage = view.findViewById(R.id.careportal_newnstreatment_percentage);
|
|
||||||
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
editTimeshift = view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
|
||||||
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
|
||||||
|
|
||||||
ProfileSwitch ps = treatmentsPlugin.getProfileSwitchFromHistory(DateUtil.now());
|
|
||||||
if (ps != null && ps.isCPP) {
|
|
||||||
final int percentage = ps.percentage;
|
|
||||||
final int timeshift = ps.timeshift;
|
|
||||||
reuseButton.setText(reuseButton.getText() + " " + percentage + "% " + timeshift + "h");
|
|
||||||
reuseButton.setOnClickListener(v -> {
|
|
||||||
editPercentage.setValue((double) percentage);
|
|
||||||
editTimeshift.setValue((double) timeshift);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (ps == null) {
|
|
||||||
options.duration = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_eventtime_layout), options.date);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_bg_layout), options.bg);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_bgsource_layout), options.bg);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_insulin_layout), options.insulin);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_carbs_layout), options.carbs);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_split_layout), options.split);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_duration_layout), options.duration);
|
|
||||||
showOrHide(layoutPercent, options.percent);
|
|
||||||
showOrHide(layoutAbsolute, options.absolute);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_carbtime_layout), options.prebolus);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_percentage_layout), options.profile);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_timeshift_layout), options.profile);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
|
|
||||||
showOrHide(view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
|
||||||
|
|
||||||
setCancelable(true);
|
|
||||||
getDialog().setCanceledOnTouchOutside(false);
|
|
||||||
//recovering state if there is something
|
|
||||||
// only numberPickers and editTexts
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
|
||||||
editTemptarget.setValue(savedInstanceState.getDouble("editTemptarget"));
|
|
||||||
notesEdit.setText(savedInstanceState.getString("notesEdit"));
|
|
||||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
|
||||||
editCarbs.setValue(savedInstanceState.getDouble("editCarbs"));
|
|
||||||
editInsulin.setValue(savedInstanceState.getDouble("editInsulin"));
|
|
||||||
editDuration.setValue(savedInstanceState.getDouble("editDuration"));
|
|
||||||
editPercent.setValue(savedInstanceState.getDouble("editPercent"));
|
|
||||||
editAbsolute.setValue(savedInstanceState.getDouble("editAbsolute"));
|
|
||||||
editCarbTime.setValue(savedInstanceState.getDouble("editCarbTime"));
|
|
||||||
editPercentage.setValue(savedInstanceState.getDouble("editPercentage"));
|
|
||||||
editTimeshift.setValue(savedInstanceState.getDouble("editTimeshift"));
|
|
||||||
// time and date
|
|
||||||
dateButton.setText(savedInstanceState.getString("dateButton"));
|
|
||||||
timeButton.setText(savedInstanceState.getString("timeButton"));
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(eventTime);
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.careportal_newnstreatment_eventdate:
|
|
||||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
|
||||||
this,
|
|
||||||
calendar.get(Calendar.YEAR),
|
|
||||||
calendar.get(Calendar.MONTH),
|
|
||||||
calendar.get(Calendar.DAY_OF_MONTH)
|
|
||||||
);
|
|
||||||
dpd.setThemeDark(true);
|
|
||||||
dpd.dismissOnPause(true);
|
|
||||||
dpd.show(getActivity().getSupportFragmentManager(), "Datepickerdialog");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_newnstreatment_eventtime:
|
|
||||||
TimePickerDialog tpd = TimePickerDialog.newInstance(
|
|
||||||
this,
|
|
||||||
calendar.get(Calendar.HOUR_OF_DAY),
|
|
||||||
calendar.get(Calendar.MINUTE),
|
|
||||||
DateFormat.is24HourFormat(getContext())
|
|
||||||
);
|
|
||||||
tpd.setThemeDark(true);
|
|
||||||
tpd.dismissOnPause(true);
|
|
||||||
tpd.show(getActivity().getSupportFragmentManager(), "Timepickerdialog");
|
|
||||||
break;
|
|
||||||
case R.id.ok:
|
|
||||||
confirmNSTreatmentCreation();
|
|
||||||
dismiss();
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
dismiss();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showOrHide(ViewGroup layout, boolean visible) {
|
|
||||||
if (visible) layout.setVisibility(View.VISIBLE);
|
|
||||||
else layout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBGforDateTime() {
|
|
||||||
long millis = eventTime.getTime() - (150 * 1000L); // 2,5 * 60 * 1000
|
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(millis, true);
|
|
||||||
if ((data.size() > 0) &&
|
|
||||||
(data.get(0).date > millis - 7 * 60 * 1000L) &&
|
|
||||||
(data.get(0).date < millis + 7 * 60 * 1000L)) {
|
|
||||||
editBg.setValue(Profile.fromMgdlToUnits(data.get(0).value, profileFunction.getUnits()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
|
||||||
eventTime.setYear(year - 1900);
|
|
||||||
eventTime.setMonth(monthOfYear);
|
|
||||||
eventTime.setDate(dayOfMonth);
|
|
||||||
dateButton.setText(DateUtil.dateString(eventTime));
|
|
||||||
updateBGforDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
|
|
||||||
eventTime.setHours(hourOfDay);
|
|
||||||
eventTime.setMinutes(minute);
|
|
||||||
eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually
|
|
||||||
timeButton.setText(DateUtil.timeString(eventTime));
|
|
||||||
updateBGforDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSONObject gatherData() {
|
|
||||||
String enteredBy = sp.getString("careportal_enteredby", "");
|
|
||||||
JSONObject data = new JSONObject();
|
|
||||||
try {
|
|
||||||
boolean allowZeroDuration = false;
|
|
||||||
data.put("created_at", DateUtil.toISOString(eventTime));
|
|
||||||
switch (options.eventType) {
|
|
||||||
case R.id.careportal_bgcheck:
|
|
||||||
data.put("eventType", CareportalEvent.BGCHECK);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_announcement:
|
|
||||||
data.put("eventType", CareportalEvent.ANNOUNCEMENT);
|
|
||||||
data.put("isAnnouncement", true);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_cgmsensorinsert:
|
|
||||||
data.put("eventType", CareportalEvent.SENSORCHANGE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_cgmsensorstart:
|
|
||||||
data.put("eventType", "Sensor Start");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_combobolus:
|
|
||||||
data.put("splitNow", SafeParse.stringToDouble(editSplit.getText()));
|
|
||||||
data.put("splitExt", 100 - SafeParse.stringToDouble(editSplit.getText()));
|
|
||||||
data.put("eventType", CareportalEvent.COMBOBOLUS);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_correctionbolus:
|
|
||||||
data.put("eventType", "Correction Bolus");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_carbscorrection:
|
|
||||||
data.put("eventType", "Carb Correction");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_exercise:
|
|
||||||
data.put("eventType", CareportalEvent.EXERCISE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_insulincartridgechange:
|
|
||||||
data.put("eventType", CareportalEvent.INSULINCHANGE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_pumpbatterychange:
|
|
||||||
data.put("eventType", CareportalEvent.PUMPBATTERYCHANGE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_mealbolus:
|
|
||||||
data.put("eventType", "Meal Bolus");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_note:
|
|
||||||
data.put("eventType", CareportalEvent.NOTE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_profileswitch:
|
|
||||||
data.put("eventType", CareportalEvent.PROFILESWITCH);
|
|
||||||
allowZeroDuration = true;
|
|
||||||
break;
|
|
||||||
case R.id.careportal_pumpsitechange:
|
|
||||||
data.put("eventType", CareportalEvent.SITECHANGE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_question:
|
|
||||||
data.put("eventType", CareportalEvent.QUESTION);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_snackbolus:
|
|
||||||
data.put("eventType", "Snack Bolus");
|
|
||||||
break;
|
|
||||||
case R.id.careportal_tempbasalstart:
|
|
||||||
data.put("eventType", CareportalEvent.TEMPBASAL);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_tempbasalend:
|
|
||||||
data.put("eventType", CareportalEvent.TEMPBASAL);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_openapsoffline:
|
|
||||||
data.put("eventType", CareportalEvent.OPENAPSOFFLINE);
|
|
||||||
break;
|
|
||||||
case R.id.careportal_temporarytarget:
|
|
||||||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
|
||||||
if (!reasonSpinner.getSelectedItem().toString().equals(""))
|
|
||||||
data.put("reason", reasonSpinner.getSelectedItem().toString());
|
|
||||||
if (SafeParse.stringToDouble(editTemptarget.getText()) != 0d) {
|
|
||||||
data.put("targetBottom", SafeParse.stringToDouble(editTemptarget.getText()));
|
|
||||||
data.put("targetTop", SafeParse.stringToDouble(editTemptarget.getText()));
|
|
||||||
}
|
|
||||||
allowZeroDuration = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (options.bg && SafeParse.stringToDouble(editBg.getText()) != 0d) {
|
|
||||||
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
|
|
||||||
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
|
|
||||||
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
|
|
||||||
if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual");
|
|
||||||
}
|
|
||||||
if (SafeParse.stringToDouble(editCarbs.getText()) != 0d)
|
|
||||||
data.put("carbs", SafeParse.stringToDouble(editCarbs.getText()));
|
|
||||||
if (SafeParse.stringToDouble(editInsulin.getText()) != 0d)
|
|
||||||
data.put("insulin", SafeParse.stringToDouble(editInsulin.getText()));
|
|
||||||
if (allowZeroDuration || SafeParse.stringToDouble(editDuration.getText()) != 0d)
|
|
||||||
data.put("duration", SafeParse.stringToDouble(editDuration.getText()));
|
|
||||||
if (layoutPercent.getVisibility() != View.GONE)
|
|
||||||
data.put("percent", SafeParse.stringToDouble(editPercent.getText()));
|
|
||||||
if (layoutAbsolute.getVisibility() != View.GONE)
|
|
||||||
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
|
|
||||||
if (options.profile && profileSpinner.getSelectedItem() != null)
|
|
||||||
data.put("profile", profileSpinner.getSelectedItem().toString());
|
|
||||||
if (options.profile)
|
|
||||||
data.put("percentage", SafeParse.stringToInt(editPercentage.getText()));
|
|
||||||
if (options.profile)
|
|
||||||
data.put("timeshift", SafeParse.stringToInt(editTimeshift.getText()));
|
|
||||||
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
|
|
||||||
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
|
||||||
if (!notesEdit.getText().toString().equals(""))
|
|
||||||
data.put("notes", notesEdit.getText().toString());
|
|
||||||
data.put("units", profileFunction.getUnits());
|
|
||||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
|
||||||
if (options.eventType == R.id.careportal_combobolus) {
|
|
||||||
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
|
||||||
data.put("enteredinsulin", enteredInsulin);
|
|
||||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editSplit.getText()) / 100);
|
|
||||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
aapsLogger.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildConfirmText(JSONObject data) {
|
|
||||||
String ret = "";
|
|
||||||
// if (data.has("eventType")) {
|
|
||||||
// ret += resourceHelper.gs(R.string.careportal_newnstreatment_eventtype);
|
|
||||||
// ret += ": ";
|
|
||||||
// ret += Translator.translate(JsonHelper.safeGetString(data, "eventType", ""));
|
|
||||||
// ret += "\n";
|
|
||||||
// }
|
|
||||||
if (data.has("glucose")) {
|
|
||||||
ret += resourceHelper.gs(R.string.treatments_wizard_bg_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "glucose", "");
|
|
||||||
ret += " " + profileFunction.getUnits() + "\n";
|
|
||||||
}
|
|
||||||
if (data.has("glucoseType")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype);
|
|
||||||
ret += ": ";
|
|
||||||
ret += translator.translate(JsonHelper.safeGetString(data, "glucoseType", ""));
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
if (data.has("carbs")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_carbs_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "carbs", "");
|
|
||||||
ret += " g\n";
|
|
||||||
}
|
|
||||||
if (data.has("insulin")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_insulin_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "insulin", "");
|
|
||||||
ret += " U\n";
|
|
||||||
}
|
|
||||||
if (data.has("duration")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_duration_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "duration", "");
|
|
||||||
ret += " min\n";
|
|
||||||
}
|
|
||||||
if (data.has("percent")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_percent_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "percent", "");
|
|
||||||
ret += " %\n";
|
|
||||||
}
|
|
||||||
if (data.has("absolute")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_absolute_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "absolute", "");
|
|
||||||
ret += " U/h\n";
|
|
||||||
}
|
|
||||||
if (data.has("preBolus")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_carbtime_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "preBolus", "");
|
|
||||||
ret += " min\n";
|
|
||||||
}
|
|
||||||
if (data.has("notes")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_notes_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "notes", "");
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
if (data.has("profile")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_profile_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "profile", "");
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
if (data.has("percentage")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_percentage_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "percentage", "");
|
|
||||||
ret += " %\n";
|
|
||||||
}
|
|
||||||
if (data.has("timeshift")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_timeshift_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "timeshift", "");
|
|
||||||
ret += " h\n";
|
|
||||||
}
|
|
||||||
if (data.has("targetBottom") && data.has("targetTop")) {
|
|
||||||
ret += resourceHelper.gs(R.string.target_range);
|
|
||||||
ret += " ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "targetBottom", "");
|
|
||||||
ret += " - ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "targetTop", "");
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
if (data.has("created_at")) {
|
|
||||||
ret += resourceHelper.gs(R.string.event_time_label);
|
|
||||||
ret += ": ";
|
|
||||||
ret += DateUtil.dateAndTimeString(eventTime);
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
if (data.has("enteredBy")) {
|
|
||||||
ret += resourceHelper.gs(R.string.careportal_newnstreatment_enteredby_title);
|
|
||||||
ret += ": ";
|
|
||||||
ret += JsonHelper.safeGetObject(data, "enteredBy", "");
|
|
||||||
ret += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void confirmNSTreatmentCreation() {
|
|
||||||
final JSONObject data = gatherData();
|
|
||||||
OKDialog.showConfirmation(getContext(), translator.translate(JsonHelper.safeGetString(data, "eventType", resourceHelper.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> NSUpload.createNSTreatment(data, profileStore, profileFunction, eventTime.getTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
|
||||||
savedInstanceState.putString("notesEdit", notesEdit.getText().toString());
|
|
||||||
savedInstanceState.putString("dateButton", dateButton.getText().toString());
|
|
||||||
savedInstanceState.putString("timeButton", timeButton.getText().toString());
|
|
||||||
savedInstanceState.putDouble("editBg", editBg.getValue());
|
|
||||||
savedInstanceState.putDouble("editCarbs", editCarbs.getValue());
|
|
||||||
savedInstanceState.putDouble("editInsulin", editInsulin.getValue());
|
|
||||||
savedInstanceState.putDouble("editDuration", editDuration.getValue());
|
|
||||||
savedInstanceState.putDouble("editPercent", editPercent.getValue());
|
|
||||||
savedInstanceState.putDouble("editAbsolute", editAbsolute.getValue());
|
|
||||||
savedInstanceState.putDouble("editCarbTime", editCarbTime.getValue());
|
|
||||||
savedInstanceState.putDouble("editTemptarget", editTemptarget.getValue());
|
|
||||||
savedInstanceState.putDouble("editPercentage", editPercentage.getValue());
|
|
||||||
savedInstanceState.putDouble("editTimeshift", editTimeshift.getValue());
|
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.careportal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 05.11.2016.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class OptionsToShow {
|
|
||||||
public int eventType;
|
|
||||||
public int eventName;
|
|
||||||
public boolean date;
|
|
||||||
public boolean bg;
|
|
||||||
public boolean insulin;
|
|
||||||
public boolean carbs;
|
|
||||||
public boolean prebolus;
|
|
||||||
public boolean duration;
|
|
||||||
public boolean percent;
|
|
||||||
public boolean absolute;
|
|
||||||
public boolean profile;
|
|
||||||
public boolean split;
|
|
||||||
public boolean tempTarget;
|
|
||||||
|
|
||||||
public OptionsToShow(int eventType, int eventName) {
|
|
||||||
this.eventType = eventType;
|
|
||||||
this.eventName = eventName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow date() {
|
|
||||||
date = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow bg() {
|
|
||||||
bg = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow insulin() {
|
|
||||||
insulin = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow carbs() {
|
|
||||||
carbs = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow prebolus() {
|
|
||||||
prebolus = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow duration() {
|
|
||||||
duration = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow percent() {
|
|
||||||
percent = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow absolute() {
|
|
||||||
absolute = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow profile() {
|
|
||||||
profile = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow split() {
|
|
||||||
split = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionsToShow tempTarget() {
|
|
||||||
tempTarget = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,16 +14,12 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile
|
import info.nightscout.androidaps.events.EventNewBasalProfile
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange
|
import info.nightscout.androidaps.events.EventTempBasalChange
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange
|
import info.nightscout.androidaps.events.EventTreatmentChange
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
|
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
|
@ -53,8 +49,9 @@ class DataBroadcastPlugin @Inject constructor(
|
||||||
private val nsDeviceStatus: NSDeviceStatus,
|
private val nsDeviceStatus: NSDeviceStatus,
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
private val activePlugin: ActivePluginProvider,
|
private val activePlugin: ActivePluginProvider,
|
||||||
private var receiverStatusStore: ReceiverStatusStore
|
private var receiverStatusStore: ReceiverStatusStore,
|
||||||
|
private val config: Config,
|
||||||
|
private val databaseHelper: DatabaseHelperInterface
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -131,7 +128,7 @@ class DataBroadcastPlugin @Inject constructor(
|
||||||
bundle.putDouble("glucoseMgdl", lastBG.value) // last BG in mgdl
|
bundle.putDouble("glucoseMgdl", lastBG.value) // last BG in mgdl
|
||||||
bundle.putLong("glucoseTimeStamp", lastBG.date) // timestamp
|
bundle.putLong("glucoseTimeStamp", lastBG.date) // timestamp
|
||||||
bundle.putString("units", profileFunction.getUnits()) // units used in AAPS "mg/dl" or "mmol"
|
bundle.putString("units", profileFunction.getUnits()) // units used in AAPS "mg/dl" or "mmol"
|
||||||
bundle.putString("slopeArrow", lastBG.directionToSymbol()) // direction arrow as string
|
bundle.putString("slopeArrow", lastBG.directionToSymbol(databaseHelper)) // direction arrow as string
|
||||||
bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl
|
bundle.putDouble("deltaMgdl", glucoseStatus.delta) // bg delta in mgdl
|
||||||
bundle.putDouble("avgDeltaMgdl", glucoseStatus.avgdelta) // average bg delta
|
bundle.putDouble("avgDeltaMgdl", glucoseStatus.avgdelta) // average bg delta
|
||||||
bundle.putDouble("high", defaultValueHelper.determineHighLine()) // predefined top value of in range (green area)
|
bundle.putDouble("high", defaultValueHelper.determineHighLine()) // predefined top value of in range (green area)
|
||||||
|
@ -158,7 +155,7 @@ class DataBroadcastPlugin @Inject constructor(
|
||||||
bundle.putInt("phoneBattery", receiverStatusStore.batteryLevel)
|
bundle.putInt("phoneBattery", receiverStatusStore.batteryLevel)
|
||||||
bundle.putInt("rigBattery", nsDeviceStatus.uploaderStatus.replace("%", "").trim { it <= ' ' }.toInt())
|
bundle.putInt("rigBattery", nsDeviceStatus.uploaderStatus.replace("%", "").trim { it <= ' ' }.toInt())
|
||||||
|
|
||||||
if (Config.APS && loopPlugin.lastRun?.lastTBREnact != 0L) { //we are AndroidAPS
|
if (config.APS && loopPlugin.lastRun?.lastTBREnact != 0L) { //we are AndroidAPS
|
||||||
bundle.putLong("suggestedTimeStamp", loopPlugin.lastRun?.lastAPSRun ?: -1L)
|
bundle.putLong("suggestedTimeStamp", loopPlugin.lastRun?.lastAPSRun ?: -1L)
|
||||||
bundle.putString("suggested", loopPlugin.lastRun?.request?.json().toString())
|
bundle.putString("suggested", loopPlugin.lastRun?.request?.json().toString())
|
||||||
if (loopPlugin.lastRun?.tbrSetByPump != null && loopPlugin.lastRun?.tbrSetByPump?.enacted == true) {
|
if (loopPlugin.lastRun?.tbrSetByPump != null && loopPlugin.lastRun?.tbrSetByPump?.enacted == true) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var foodPlugin: FoodPlugin
|
@Inject lateinit var foodPlugin: FoodPlugin
|
||||||
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private lateinit var unfiltered: List<Food>
|
private lateinit var unfiltered: List<Food>
|
||||||
|
@ -58,7 +59,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
food_category.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
food_category.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
fillSubcategories()
|
fillSubcategories()
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
food_subcategory.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
food_subcategory.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int ->
|
showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int ->
|
||||||
if (food._id != null && food._id != "") {
|
if (food._id != null && food._id != "") {
|
||||||
NSUpload.removeFoodFromNS(food._id)
|
nsUpload.removeFoodFromNS(food._id)
|
||||||
}
|
}
|
||||||
foodPlugin.service?.delete(food)
|
foodPlugin.service?.delete(food)
|
||||||
}, null)
|
}, null)
|
||||||
|
|
|
@ -28,6 +28,6 @@ class FoodPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
service = FoodService()
|
service = FoodService(injector)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,8 +15,6 @@ import com.j256.ormlite.table.TableUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -26,14 +24,17 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.ICallback;
|
import info.nightscout.androidaps.db.ICallback;
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
||||||
import info.nightscout.androidaps.events.EventNsFood;
|
import info.nightscout.androidaps.events.EventNsFood;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
@ -43,16 +44,20 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
private Logger log = StacktraceLoggerWrapper.getLogger(L.DATAFOOD);
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
||||||
|
|
||||||
public FoodService() {
|
public FoodService(HasAndroidInjector injector) {
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
onCreate();
|
onCreate();
|
||||||
dbInitialize();
|
dbInitialize();
|
||||||
disposable.add(RxBus.Companion.getINSTANCE()
|
disposable.add(rxBus
|
||||||
.toObservable(EventNsFood.class)
|
.toObservable(EventNsFood.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -62,7 +67,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
this.createFoodFromJsonIfNotExists(array);
|
this.createFoodFromJsonIfNotExists(array);
|
||||||
else
|
else
|
||||||
this.deleteNS(array);
|
this.deleteNS(array);
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
return DaoManager.createDao(this.getConnectionSource(), Food.class);
|
return DaoManager.createDao(this.getConnectionSource(), Food.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Cannot create Dao for Food.class");
|
aapsLogger.error("Cannot create Dao for Food.class");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,18 +103,16 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.info(LTag.DATAFOOD, "onCreate");
|
||||||
log.info("onCreate");
|
|
||||||
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't create database", e);
|
aapsLogger.error("Can't create database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.info(LTag.DATAFOOD, "onUpgrade");
|
||||||
log.info("onUpgrade");
|
|
||||||
// this.resetFood();
|
// this.resetFood();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +125,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
TableUtils.dropTable(this.getConnectionSource(), Food.class, true);
|
TableUtils.dropTable(this.getConnectionSource(), Food.class, true);
|
||||||
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
scheduleFoodChange();
|
scheduleFoodChange();
|
||||||
}
|
}
|
||||||
|
@ -147,9 +150,8 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
|
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.debug(LTag.DATAFOOD, "Firing EventFoodChange");
|
||||||
log.debug("Firing EventFoodChange");
|
rxBus.send(event);
|
||||||
RxBus.Companion.getINSTANCE().send(event);
|
|
||||||
callback.setPost(null);
|
callback.setPost(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +185,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
try {
|
try {
|
||||||
return this.getDao().queryForAll();
|
return this.getDao().queryForAll();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -208,7 +210,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
Food food = Food.createFromJson(json);
|
Food food = Food.createFromJson(json);
|
||||||
this.createFoodFromJsonIfNotExists(food);
|
this.createFoodFromJsonIfNotExists(food);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +222,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
this.createFoodFromJsonIfNotExists(food);
|
this.createFoodFromJsonIfNotExists(food);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +235,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
String _id = json.getString("_id");
|
String _id = json.getString("_id");
|
||||||
this.deleteByNSId(_id);
|
this.deleteByNSId(_id);
|
||||||
} catch (JSONException | SQLException e) {
|
} catch (JSONException | SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +246,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
this.deleteNS(json);
|
this.deleteNS(json);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +260,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void deleteByNSId(String _id) throws SQLException {
|
public void deleteByNSId(String _id) throws SQLException {
|
||||||
Food stored = this.findByNSId(_id);
|
Food stored = this.findByNSId(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.debug(LTag.DATAFOOD, "Removing Food record from database: " + stored.toString());
|
||||||
log.debug("Removing Food record from database: " + stored.toString());
|
|
||||||
this.delete(stored);
|
this.delete(stored);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
this.getDao().delete(food);
|
this.getDao().delete(food);
|
||||||
this.scheduleFoodChange();
|
this.scheduleFoodChange();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,10 +313,9 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void createOrUpdate(Food food) {
|
public void createOrUpdate(Food food) {
|
||||||
try {
|
try {
|
||||||
this.getDao().createOrUpdate(food);
|
this.getDao().createOrUpdate(food);
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.debug(LTag.DATAFOOD, "Created or Updated: " + food.toString());
|
||||||
log.debug("Created or Updated: " + food.toString());
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unable to createOrUpdate Food", e);
|
aapsLogger.error("Unable to createOrUpdate Food", e);
|
||||||
}
|
}
|
||||||
this.scheduleFoodChange();
|
this.scheduleFoodChange();
|
||||||
}
|
}
|
||||||
|
@ -323,10 +323,9 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void create(Food food) {
|
public void create(Food food) {
|
||||||
try {
|
try {
|
||||||
this.getDao().create(food);
|
this.getDao().create(food);
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
aapsLogger.debug(LTag.DATAFOOD, "New record: " + food.toString());
|
||||||
log.debug("New record: " + food.toString());
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unable to create Food", e);
|
aapsLogger.error("Unable to create Food", e);
|
||||||
}
|
}
|
||||||
this.scheduleFoodChange();
|
this.scheduleFoodChange();
|
||||||
}
|
}
|
||||||
|
@ -346,7 +345,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@ import android.bluetooth.BluetoothAdapter
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import androidx.activity.invoke
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||||
|
@ -20,11 +20,10 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.PrefImportSummaryDialog
|
import info.nightscout.androidaps.utils.alertDialogs.PrefImportSummaryDialog
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.TwoMessagesAlertDialog
|
import info.nightscout.androidaps.utils.alertDialogs.TwoMessagesAlertDialog
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.WarningDialog
|
import info.nightscout.androidaps.utils.alertDialogs.WarningDialog
|
||||||
|
@ -32,8 +31,6 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.joda.time.DateTime
|
|
||||||
import org.joda.time.Days
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -51,37 +48,25 @@ private val PERMISSIONS_STORAGE = arrayOf(
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ImportExportPrefs @Inject constructor(
|
class ImportExportPrefs @Inject constructor(
|
||||||
private var log: AAPSLogger,
|
private var log: AAPSLogger,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val buildHelper: BuildHelper,
|
private val buildHelper: BuildHelper,
|
||||||
private val otp: OneTimePassword,
|
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val passwordCheck: PasswordCheck,
|
private val passwordCheck: PasswordCheck,
|
||||||
private val classicPrefsFormat: ClassicPrefsFormat,
|
private val classicPrefsFormat: ClassicPrefsFormat,
|
||||||
private val encryptedPrefsFormat: EncryptedPrefsFormat
|
private val encryptedPrefsFormat: EncryptedPrefsFormat,
|
||||||
|
private val prefFileList: PrefFileListProvider
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val TAG = LTag.CORE
|
val TAG = LTag.CORE
|
||||||
|
|
||||||
private val path = File(Environment.getExternalStorageDirectory().toString())
|
|
||||||
|
|
||||||
private val file = File(path, resourceHelper.gs(R.string.app_name) + "Preferences")
|
|
||||||
private val encFile = File(path, resourceHelper.gs(R.string.app_name) + "Preferences.json")
|
|
||||||
|
|
||||||
fun prefsImportFile(): File {
|
|
||||||
return if (encFile.exists()) encFile else file
|
|
||||||
}
|
|
||||||
|
|
||||||
fun prefsFileExists(): Boolean {
|
fun prefsFileExists(): Boolean {
|
||||||
return encFile.exists() || file.exists()
|
return prefFileList.listPreferenceFiles().size > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun exportSharedPreferences(f: Fragment) {
|
fun exportSharedPreferences(f: Fragment) {
|
||||||
f.activity?.let { exportSharedPreferences(it) }
|
f.activity?.let { exportSharedPreferences(it) }
|
||||||
}
|
}
|
||||||
|
@ -135,9 +120,6 @@ class ImportExportPrefs @Inject constructor(
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentDeviceModelString() =
|
|
||||||
Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.DEVICE + ")"
|
|
||||||
|
|
||||||
private fun prefsEncryptionIsDisabled() =
|
private fun prefsEncryptionIsDisabled() =
|
||||||
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
||||||
|
|
||||||
|
@ -173,36 +155,41 @@ class ImportExportPrefs @Inject constructor(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askToConfirmExport(activity: Activity, then: ((password: String) -> Unit)) {
|
private fun askToConfirmExport(activity: Activity, fileToExport: File, then: ((password: String) -> Unit)) {
|
||||||
if (!prefsEncryptionIsDisabled() && !assureMasterPasswordSet(activity, R.string.nav_export)) return
|
if (!prefsEncryptionIsDisabled() && !assureMasterPasswordSet(activity, R.string.nav_export)) return
|
||||||
|
|
||||||
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_export),
|
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_export),
|
||||||
resourceHelper.gs(R.string.export_to) + " " + encFile + " ?",
|
resourceHelper.gs(R.string.export_to) + " " + fileToExport + " ?",
|
||||||
resourceHelper.gs(R.string.password_preferences_encrypt_prompt), {
|
resourceHelper.gs(R.string.password_preferences_encrypt_prompt), {
|
||||||
askForMasterPassIfNeeded(activity, R.string.preferences_export_canceled, then)
|
askForMasterPassIfNeeded(activity, R.string.preferences_export_canceled, then)
|
||||||
}, null, R.drawable.ic_header_export)
|
}, null, R.drawable.ic_header_export)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askToConfirmImport(activity: Activity, fileToImport: File, then: ((password: String) -> Unit)) {
|
private fun askToConfirmImport(activity: Activity, fileToImport: PrefsFile, then: ((password: String) -> Unit)) {
|
||||||
|
|
||||||
if (encFile.exists()) {
|
if (fileToImport.handler == PrefsFormatsHandler.ENCRYPTED) {
|
||||||
if (!assureMasterPasswordSet(activity, R.string.nav_import)) return
|
if (!assureMasterPasswordSet(activity, R.string.nav_import)) return
|
||||||
|
|
||||||
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_import),
|
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_import),
|
||||||
resourceHelper.gs(R.string.import_from) + " " + fileToImport + " ?",
|
resourceHelper.gs(R.string.import_from) + " " + fileToImport.file + " ?",
|
||||||
resourceHelper.gs(R.string.password_preferences_decrypt_prompt), {
|
resourceHelper.gs(R.string.password_preferences_decrypt_prompt), {
|
||||||
askForMasterPass(activity, R.string.preferences_import_canceled, then)
|
askForMasterPass(activity, R.string.preferences_import_canceled, then)
|
||||||
}, null, R.drawable.ic_header_import)
|
}, null, R.drawable.ic_header_import)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nav_import),
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nav_import),
|
||||||
resourceHelper.gs(R.string.import_from) + " " + fileToImport + " ?",
|
resourceHelper.gs(R.string.import_from) + " " + fileToImport.file + " ?",
|
||||||
Runnable { then("") })
|
Runnable { then("") })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportSharedPreferences(activity: Activity) {
|
private fun exportSharedPreferences(activity: Activity) {
|
||||||
askToConfirmExport(activity) { password ->
|
|
||||||
|
prefFileList.ensureExportDirExists()
|
||||||
|
val legacyFile = prefFileList.legacyFile()
|
||||||
|
val newFile = prefFileList.newExportFile()
|
||||||
|
|
||||||
|
askToConfirmExport(activity, newFile) { password ->
|
||||||
try {
|
try {
|
||||||
val entries: MutableMap<String, String> = mutableMapOf()
|
val entries: MutableMap<String, String> = mutableMapOf()
|
||||||
for ((key, value) in sp.getAll()) {
|
for ((key, value) in sp.getAll()) {
|
||||||
|
@ -211,12 +198,14 @@ class ImportExportPrefs @Inject constructor(
|
||||||
|
|
||||||
val prefs = Prefs(entries, prepareMetadata(activity))
|
val prefs = Prefs(entries, prepareMetadata(activity))
|
||||||
|
|
||||||
classicPrefsFormat.savePreferences(file, prefs)
|
if (BuildConfig.DEBUG && buildHelper.isEngineeringMode()) {
|
||||||
encryptedPrefsFormat.savePreferences(encFile, prefs, password)
|
classicPrefsFormat.savePreferences(legacyFile, prefs)
|
||||||
|
}
|
||||||
|
encryptedPrefsFormat.savePreferences(newFile, prefs, password)
|
||||||
|
|
||||||
ToastUtils.okToast(activity, resourceHelper.gs(R.string.exported))
|
ToastUtils.okToast(activity, resourceHelper.gs(R.string.exported))
|
||||||
} catch (e: FileNotFoundException) {
|
} catch (e: FileNotFoundException) {
|
||||||
ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + encFile)
|
ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile)
|
||||||
log.error(TAG, "Unhandled exception", e)
|
log.error(TAG, "Unhandled exception", e)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
ToastUtils.errorToast(activity, e.message)
|
ToastUtils.errorToast(activity, e.message)
|
||||||
|
@ -226,21 +215,38 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importSharedPreferences(fragment: Fragment) {
|
fun importSharedPreferences(fragment: Fragment) {
|
||||||
fragment.activity?.let { importSharedPreferences(it) }
|
fragment.activity?.let { fragmentAct ->
|
||||||
|
val callForPrefFile = fragmentAct.registerForActivityResult(PrefsFileContract()) {
|
||||||
|
it?.let {
|
||||||
|
importSharedPreferences(fragmentAct, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callForPrefFile.invoke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importSharedPreferences(activity: Activity) {
|
fun importSharedPreferences(activity: FragmentActivity) {
|
||||||
|
val callForPrefFile = activity.registerForActivityResult(PrefsFileContract()) {
|
||||||
|
it?.let {
|
||||||
|
importSharedPreferences(activity, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callForPrefFile.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
val importFile = prefsImportFile()
|
private fun importSharedPreferences(activity: Activity, importFile: PrefsFile) {
|
||||||
|
|
||||||
askToConfirmImport(activity, importFile) { password ->
|
askToConfirmImport(activity, importFile) { password ->
|
||||||
|
|
||||||
val format: PrefsFormat = if (encFile.exists()) encryptedPrefsFormat else classicPrefsFormat
|
val format: PrefsFormat = when (importFile.handler) {
|
||||||
|
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat
|
||||||
|
PrefsFormatsHandler.ENCRYPTED -> encryptedPrefsFormat
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val prefs = format.loadPreferences(importFile, password)
|
val prefs = format.loadPreferences(importFile.file, password)
|
||||||
prefs.metadata = checkMetadata(prefs.metadata)
|
prefs.metadata = prefFileList.checkMetadata(prefs.metadata)
|
||||||
|
|
||||||
// import is OK when we do not have errors (warnings are allowed)
|
// import is OK when we do not have errors (warnings are allowed)
|
||||||
val importOk = checkIfImportIsOk(prefs)
|
val importOk = checkIfImportIsOk(prefs)
|
||||||
|
@ -276,45 +282,6 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check metadata for known issues, change their status and add info with explanations
|
|
||||||
private fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> {
|
|
||||||
val meta = metadata.toMutableMap()
|
|
||||||
|
|
||||||
meta[PrefsMetadataKey.AAPS_FLAVOUR]?.let { flavour ->
|
|
||||||
val flavourOfPrefs = flavour.value
|
|
||||||
if (flavour.value != BuildConfig.FLAVOR) {
|
|
||||||
flavour.status = PrefsStatus.WARN
|
|
||||||
flavour.info = resourceHelper.gs(R.string.metadata_warning_different_flavour, flavourOfPrefs, BuildConfig.FLAVOR)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
meta[PrefsMetadataKey.DEVICE_MODEL]?.let { model ->
|
|
||||||
if (model.value != getCurrentDeviceModelString()) {
|
|
||||||
model.status = PrefsStatus.WARN
|
|
||||||
model.info = resourceHelper.gs(R.string.metadata_warning_different_device)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
|
|
||||||
try {
|
|
||||||
val date1 = DateTime.parse(createdAt.value);
|
|
||||||
val date2 = DateTime.now()
|
|
||||||
|
|
||||||
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).getDays()
|
|
||||||
|
|
||||||
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
|
|
||||||
createdAt.status = PrefsStatus.WARN
|
|
||||||
createdAt.info = resourceHelper.gs(R.string.metadata_warning_old_export, daysOld.toString())
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
createdAt.status = PrefsStatus.WARN
|
|
||||||
createdAt.info = resourceHelper.gs(R.string.metadata_warning_date_format)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return meta
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkIfImportIsOk(prefs: Prefs): Boolean {
|
private fun checkIfImportIsOk(prefs: Prefs): Boolean {
|
||||||
var importOk = true
|
var importOk = true
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance;
|
package info.nightscout.androidaps.plugins.general.maintenance;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides serveral methods for log-handling (eg. sending logs as emails).
|
* This class provides serveral methods for log-handling (eg. sending logs as emails).
|
||||||
*/
|
*/
|
||||||
public class LoggerUtils {
|
public class LoggerUtils {
|
||||||
|
|
||||||
private static final Logger LOGGER = StacktraceLoggerWrapper.getLogger(L.CORE);
|
|
||||||
|
|
||||||
public static String SUFFIX = ".log.zip";
|
public static String SUFFIX = ".log.zip";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
|
@ -34,7 +33,8 @@ class MaintenancePlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val nsSettingsStatus: NSSettingsStatus,
|
private val nsSettingsStatus: NSSettingsStatus,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val buildHelper: BuildHelper
|
private val buildHelper: BuildHelper,
|
||||||
|
private val config: Config
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(MaintenanceFragment::class.java.name)
|
.fragmentClass(MaintenanceFragment::class.java.name)
|
||||||
|
@ -171,7 +171,7 @@ class MaintenancePlugin @Inject constructor(
|
||||||
builder.append("you have to do it manually)" + System.lineSeparator())
|
builder.append("you have to do it manually)" + System.lineSeparator())
|
||||||
builder.append("-------------------------------------------------------" + System.lineSeparator())
|
builder.append("-------------------------------------------------------" + System.lineSeparator())
|
||||||
builder.append(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION + System.lineSeparator())
|
builder.append(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION + System.lineSeparator())
|
||||||
if (Config.NSCLIENT) builder.append("NSCLIENT" + System.lineSeparator())
|
if (config.NSCLIENT) builder.append("NSCLIENT" + System.lineSeparator())
|
||||||
builder.append("Build: " + BuildConfig.BUILDVERSION + System.lineSeparator())
|
builder.append("Build: " + BuildConfig.BUILDVERSION + System.lineSeparator())
|
||||||
builder.append("Remote: " + BuildConfig.REMOTE + System.lineSeparator())
|
builder.append("Remote: " + BuildConfig.REMOTE + System.lineSeparator())
|
||||||
builder.append("Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + System.lineSeparator())
|
builder.append("Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + System.lineSeparator())
|
||||||
|
|
|
@ -0,0 +1,219 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.maintenance
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Environment
|
||||||
|
import android.os.Parcelable
|
||||||
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
|
import info.nightscout.androidaps.BuildConfig
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
import kotlinx.android.parcel.RawValue
|
||||||
|
import org.joda.time.DateTime
|
||||||
|
import org.joda.time.Days
|
||||||
|
import org.joda.time.Hours
|
||||||
|
import org.joda.time.LocalDateTime
|
||||||
|
import org.joda.time.format.DateTimeFormat
|
||||||
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
enum class PrefsImportDir {
|
||||||
|
ROOT_DIR,
|
||||||
|
AAPS_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class PrefsFile(
|
||||||
|
val file: File,
|
||||||
|
val baseDir: File,
|
||||||
|
val dirKind: PrefsImportDir,
|
||||||
|
val handler: PrefsFormatsHandler,
|
||||||
|
|
||||||
|
// metadata here is used only for list display
|
||||||
|
val metadata: @RawValue Map<PrefsMetadataKey, PrefMetadata>
|
||||||
|
) : Parcelable
|
||||||
|
|
||||||
|
class PrefsFileContract : ActivityResultContract<Void, PrefsFile>() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val OUTPUT_PARAM = "prefs_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun parseResult(resultCode: Int, intent: Intent?): PrefsFile? {
|
||||||
|
return when (resultCode) {
|
||||||
|
Activity.RESULT_OK -> intent?.getParcelableExtra(OUTPUT_PARAM)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createIntent(context: Context, input: Void?): Intent {
|
||||||
|
return Intent(context, PrefImportListActivity::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentDeviceModelString() =
|
||||||
|
Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.DEVICE + ")"
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class PrefFileListProvider @Inject constructor(
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val classicPrefsFormat: ClassicPrefsFormat,
|
||||||
|
private val encryptedPrefsFormat: EncryptedPrefsFormat,
|
||||||
|
private val storage: Storage,
|
||||||
|
private val versionCheckerUtils: VersionCheckerUtils
|
||||||
|
) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val path = File(Environment.getExternalStorageDirectory().toString())
|
||||||
|
private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
|
||||||
|
private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function tries to list possible preference files from main SDCard root dir and AAPS/preferences dir
|
||||||
|
* and tries to do quick assessment for preferences format plausibility.
|
||||||
|
* It does NOT load full metadata or is 100% accurate - it tries to do QUICK detection, based on:
|
||||||
|
* - file name and extension
|
||||||
|
* - predicted file contents
|
||||||
|
*/
|
||||||
|
fun listPreferenceFiles(loadMetadata: Boolean = false): MutableList<PrefsFile> {
|
||||||
|
val prefFiles = mutableListOf<PrefsFile>()
|
||||||
|
|
||||||
|
// searching rood dir for legacy files
|
||||||
|
path.walk().maxDepth(1).filter { it.isFile && (it.name.endsWith(".json") || it.name.contains("Preferences")) }.forEach {
|
||||||
|
val contents = storage.getFileContents(it)
|
||||||
|
val detectedNew = encryptedPrefsFormat.isPreferencesFile(it, contents)
|
||||||
|
val detectedOld = !detectedNew && classicPrefsFormat.isPreferencesFile(it, contents)
|
||||||
|
if (detectedNew || detectedOld) {
|
||||||
|
val formatHandler = if (detectedNew) PrefsFormatsHandler.ENCRYPTED else PrefsFormatsHandler.CLASSIC
|
||||||
|
prefFiles.add(PrefsFile(it, path, PrefsImportDir.ROOT_DIR, formatHandler, metadataFor(loadMetadata, formatHandler, contents)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// searching dedicated dir, only for new JSON format
|
||||||
|
aapsPath.walk().filter { it.isFile && it.name.endsWith(".json") }.forEach {
|
||||||
|
val contents = storage.getFileContents(it)
|
||||||
|
if (encryptedPrefsFormat.isPreferencesFile(it, contents)) {
|
||||||
|
prefFiles.add(PrefsFile(it, aapsPath, PrefsImportDir.AAPS_DIR, PrefsFormatsHandler.ENCRYPTED, metadataFor(loadMetadata, PrefsFormatsHandler.ENCRYPTED, contents)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we sort only if we have metadata to be used for that
|
||||||
|
if (loadMetadata) {
|
||||||
|
prefFiles.sortWith(
|
||||||
|
compareByDescending<PrefsFile> { it.handler }
|
||||||
|
.thenBy { it.metadata[PrefsMetadataKey.AAPS_FLAVOUR]?.status }
|
||||||
|
.thenByDescending { it.metadata[PrefsMetadataKey.CREATED_AT]?.value }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun metadataFor(loadMetadata: Boolean, formatHandler: PrefsFormatsHandler, contents: String): PrefMetadataMap {
|
||||||
|
if (!loadMetadata) {
|
||||||
|
return mapOf()
|
||||||
|
}
|
||||||
|
return checkMetadata(when (formatHandler) {
|
||||||
|
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat.loadMetadata(contents)
|
||||||
|
PrefsFormatsHandler.ENCRYPTED -> encryptedPrefsFormat.loadMetadata(contents)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun legacyFile(): File {
|
||||||
|
return File(path, resourceHelper.gs(R.string.app_name) + "Preferences")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ensureExportDirExists() {
|
||||||
|
if (!aapsPath.exists()) {
|
||||||
|
aapsPath.mkdirs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun newExportFile(): File {
|
||||||
|
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
|
||||||
|
return File(aapsPath, timeLocal + "_" + BuildConfig.FLAVOR + ".json")
|
||||||
|
}
|
||||||
|
|
||||||
|
// check metadata for known issues, change their status and add info with explanations
|
||||||
|
fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> {
|
||||||
|
val meta = metadata.toMutableMap()
|
||||||
|
|
||||||
|
meta[PrefsMetadataKey.AAPS_FLAVOUR]?.let { flavour ->
|
||||||
|
val flavourOfPrefs = flavour.value
|
||||||
|
if (flavour.value != BuildConfig.FLAVOR) {
|
||||||
|
flavour.status = PrefsStatus.WARN
|
||||||
|
flavour.info = resourceHelper.gs(R.string.metadata_warning_different_flavour, flavourOfPrefs, BuildConfig.FLAVOR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
meta[PrefsMetadataKey.DEVICE_MODEL]?.let { model ->
|
||||||
|
if (model.value != getCurrentDeviceModelString()) {
|
||||||
|
model.status = PrefsStatus.WARN
|
||||||
|
model.info = resourceHelper.gs(R.string.metadata_warning_different_device)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
|
||||||
|
try {
|
||||||
|
val date1 = DateTime.parse(createdAt.value);
|
||||||
|
val date2 = DateTime.now()
|
||||||
|
|
||||||
|
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).getDays()
|
||||||
|
|
||||||
|
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
|
||||||
|
createdAt.status = PrefsStatus.WARN
|
||||||
|
createdAt.info = resourceHelper.gs(R.string.metadata_warning_old_export, daysOld.toString())
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
createdAt.status = PrefsStatus.WARN
|
||||||
|
createdAt.info = resourceHelper.gs(R.string.metadata_warning_date_format)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
meta[PrefsMetadataKey.AAPS_VERSION]?.let { version ->
|
||||||
|
val currentAppVer = versionCheckerUtils.versionDigits(BuildConfig.VERSION_NAME)
|
||||||
|
val metadataVer = versionCheckerUtils.versionDigits(version.value)
|
||||||
|
|
||||||
|
if ((currentAppVer.size >= 2) && (metadataVer.size >= 2) && (Math.abs(currentAppVer[1] - metadataVer[1]) > 1)) {
|
||||||
|
version.status = PrefsStatus.WARN
|
||||||
|
version.info = resourceHelper.gs(R.string.metadata_warning_different_version)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((currentAppVer.isNotEmpty()) && (metadataVer.isNotEmpty()) && (currentAppVer[0] != metadataVer[0])) {
|
||||||
|
version.status = PrefsStatus.WARN
|
||||||
|
version.info = resourceHelper.gs(R.string.metadata_urgent_different_version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta
|
||||||
|
}
|
||||||
|
|
||||||
|
fun formatExportedAgo(utcTime: String): String {
|
||||||
|
val refTime = DateTime.now()
|
||||||
|
val itTime = DateTime.parse(utcTime)
|
||||||
|
val days = Days.daysBetween(itTime, refTime).days
|
||||||
|
val hours = Hours.hoursBetween(itTime, refTime).hours
|
||||||
|
|
||||||
|
return if (hours == 0) {
|
||||||
|
resourceHelper.gs(R.string.exported_less_than_hour_ago)
|
||||||
|
} else if ((hours < 24) && (hours > 0)) {
|
||||||
|
resourceHelper.gs(R.string.exported_ago, resourceHelper.gq(R.plurals.objective_hours, hours, hours))
|
||||||
|
} else if ((days < IMPORT_AGE_NOT_YET_OLD_DAYS) && (days > 0)) {
|
||||||
|
resourceHelper.gs(R.string.exported_ago, resourceHelper.gq(R.plurals.objective_days, days, days))
|
||||||
|
} else {
|
||||||
|
resourceHelper.gs(R.string.exported_at, utcTime.substring(0, 10))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,9 +9,12 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import kotlinx.android.synthetic.main.activity_logsetting.*
|
import kotlinx.android.synthetic.main.activity_logsetting.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LogSettingActivity : NoSplashAppCompatActivity() {
|
class LogSettingActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
|
@Inject lateinit var l :L
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_logsetting)
|
setContentView(R.layout.activity_logsetting)
|
||||||
|
@ -19,7 +22,7 @@ class LogSettingActivity : NoSplashAppCompatActivity() {
|
||||||
createViewsForSettings()
|
createViewsForSettings()
|
||||||
|
|
||||||
logsettings_reset.setOnClickListener {
|
logsettings_reset.setOnClickListener {
|
||||||
L.resetToDefaults()
|
l.resetToDefaults()
|
||||||
createViewsForSettings()
|
createViewsForSettings()
|
||||||
}
|
}
|
||||||
ok.setOnClickListener { finish() }
|
ok.setOnClickListener { finish() }
|
||||||
|
@ -27,7 +30,7 @@ class LogSettingActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
private fun createViewsForSettings() {
|
private fun createViewsForSettings() {
|
||||||
logsettings_placeholder.removeAllViews()
|
logsettings_placeholder.removeAllViews()
|
||||||
for (element in L.getLogElements()) {
|
for (element in l.getLogElements()) {
|
||||||
val logViewHolder = LogViewHolder(element)
|
val logViewHolder = LogViewHolder(element)
|
||||||
logsettings_placeholder.addView(logViewHolder.baseView)
|
logsettings_placeholder.addView(logViewHolder.baseView)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.maintenance.activities
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import dagger.android.support.DaggerAppCompatActivity
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFile
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsFormatsHandler
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsStatus
|
||||||
|
import info.nightscout.androidaps.utils.LocaleHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import kotlinx.android.synthetic.main.maintenance_importlist_activity.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class PrefImportListActivity : DaggerAppCompatActivity() {
|
||||||
|
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var prefFileListProvider: PrefFileListProvider
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setTheme(R.style.AppTheme)
|
||||||
|
setContentView(R.layout.maintenance_importlist_activity)
|
||||||
|
|
||||||
|
title = resourceHelper.gs(R.string.preferences_import_list_title)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowTitleEnabled(true)
|
||||||
|
|
||||||
|
importlist_recyclerview.layoutManager = LinearLayoutManager(this)
|
||||||
|
importlist_recyclerview.adapter = RecyclerViewAdapter(prefFileListProvider.listPreferenceFiles(loadMetadata = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class RecyclerViewAdapter internal constructor(private var prefFileList: List<PrefsFile>) : RecyclerView.Adapter<RecyclerViewAdapter.PrefFileViewHolder>() {
|
||||||
|
|
||||||
|
inner class PrefFileViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
var fileName: TextView = itemView.findViewById(R.id.filelist_name)
|
||||||
|
var fileDir: TextView = itemView.findViewById(R.id.filelist_dir)
|
||||||
|
var metaDateTime: TextView = itemView.findViewById(R.id.meta_date_time)
|
||||||
|
var metaDeviceName: TextView = itemView.findViewById(R.id.meta_device_name)
|
||||||
|
var metaAppVersion: TextView = itemView.findViewById(R.id.meta_app_version)
|
||||||
|
var metaVariantFormat: TextView = itemView.findViewById(R.id.meta_variant_format)
|
||||||
|
|
||||||
|
var metalineName: View = itemView.findViewById(R.id.metaline_name)
|
||||||
|
var metaDateTimeIcon: View = itemView.findViewById(R.id.meta_date_time_icon)
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemView.isClickable = true
|
||||||
|
itemView.setOnClickListener {
|
||||||
|
val prefFile = fileName.tag as PrefsFile
|
||||||
|
val i = Intent()
|
||||||
|
|
||||||
|
i.putExtra(PrefsFileContract.OUTPUT_PARAM, prefFile)
|
||||||
|
setResult(Activity.RESULT_OK, i)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PrefFileViewHolder {
|
||||||
|
val v = LayoutInflater.from(parent.context).inflate(R.layout.maintenance_importlist_item, parent, false)
|
||||||
|
return PrefFileViewHolder(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
return prefFileList.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: PrefFileViewHolder, position: Int) {
|
||||||
|
val prefFile = prefFileList[position]
|
||||||
|
holder.fileName.text = prefFile.file.name
|
||||||
|
holder.fileName.tag = prefFile
|
||||||
|
|
||||||
|
holder.fileDir.text = resourceHelper.gs(R.string.in_directory, prefFile.file.parentFile.absolutePath)
|
||||||
|
|
||||||
|
val visible = if (prefFile.handler == PrefsFormatsHandler.CLASSIC) View.GONE else View.VISIBLE
|
||||||
|
holder.metalineName.visibility = visible
|
||||||
|
holder.metaDateTimeIcon.visibility = visible
|
||||||
|
holder.metaAppVersion.visibility = visible
|
||||||
|
|
||||||
|
if (prefFile.handler == PrefsFormatsHandler.CLASSIC) {
|
||||||
|
holder.metaVariantFormat.text = resourceHelper.gs(R.string.metadata_format_old)
|
||||||
|
holder.metaVariantFormat.setTextColor(resourceHelper.gc(R.color.metadataTextWarning))
|
||||||
|
holder.metaDateTime.text = " "
|
||||||
|
} else {
|
||||||
|
|
||||||
|
prefFile.metadata[PrefsMetadataKey.AAPS_FLAVOUR]?.let {
|
||||||
|
holder.metaVariantFormat.text = it.value
|
||||||
|
val color = if (it.status == PrefsStatus.OK) R.color.metadataOk else R.color.metadataTextWarning
|
||||||
|
holder.metaVariantFormat.setTextColor(resourceHelper.gc(color))
|
||||||
|
}
|
||||||
|
|
||||||
|
prefFile.metadata[PrefsMetadataKey.CREATED_AT]?.let {
|
||||||
|
holder.metaDateTime.text = prefFileListProvider.formatExportedAgo(it.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
prefFile.metadata[PrefsMetadataKey.AAPS_VERSION]?.let {
|
||||||
|
holder.metaAppVersion.text = it.value
|
||||||
|
val color = if (it.status == PrefsStatus.OK) R.color.metadataOk else R.color.metadataTextWarning
|
||||||
|
holder.metaAppVersion.setTextColor(resourceHelper.gc(color))
|
||||||
|
}
|
||||||
|
|
||||||
|
prefFile.metadata[PrefsMetadataKey.DEVICE_NAME]?.let {
|
||||||
|
holder.metaDeviceName.text = it.value
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == android.R.id.home) {
|
||||||
|
finish()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun attachBaseContext(newBase: Context) {
|
||||||
|
super.attachBaseContext(LocaleHelper.wrap(newBase))
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance.formats
|
package info.nightscout.androidaps.plugins.general.maintenance.formats
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
|
@ -19,6 +20,11 @@ class ClassicPrefsFormat @Inject constructor(
|
||||||
val FORMAT_KEY = "aaps_old"
|
val FORMAT_KEY = "aaps_old"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isPreferencesFile(file: File, preloadedContents: String?): Boolean {
|
||||||
|
val contents = preloadedContents ?: storage.getFileContents(file)
|
||||||
|
return contents.contains("units::" + Constants.MGDL) || contents.contains("units::" + Constants.MMOL)
|
||||||
|
}
|
||||||
|
|
||||||
override fun savePreferences(file: File, prefs: Prefs, masterPassword: String?) {
|
override fun savePreferences(file: File, prefs: Prefs, masterPassword: String?) {
|
||||||
try {
|
try {
|
||||||
val contents = prefs.values.entries.joinToString("\n") { entry ->
|
val contents = prefs.values.entries.joinToString("\n") { entry ->
|
||||||
|
@ -35,7 +41,6 @@ class ClassicPrefsFormat @Inject constructor(
|
||||||
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
||||||
var lineParts: Array<String>
|
var lineParts: Array<String>
|
||||||
val entries: MutableMap<String, String> = mutableMapOf()
|
val entries: MutableMap<String, String> = mutableMapOf()
|
||||||
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = mutableMapOf()
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val rawLines = storage.getFileContents(file).split("\n")
|
val rawLines = storage.getFileContents(file).split("\n")
|
||||||
|
@ -46,9 +51,7 @@ class ClassicPrefsFormat @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(FORMAT_KEY, PrefsStatus.WARN, resourceHelper.gs(R.string.metadata_warning_outdated_format))
|
return Prefs(entries, loadMetadata())
|
||||||
|
|
||||||
return Prefs(entries, metadata)
|
|
||||||
|
|
||||||
} catch (e: FileNotFoundException) {
|
} catch (e: FileNotFoundException) {
|
||||||
throw PrefFileNotFoundError(file.absolutePath)
|
throw PrefFileNotFoundError(file.absolutePath)
|
||||||
|
@ -57,4 +60,10 @@ class ClassicPrefsFormat @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun loadMetadata(contents: String?): PrefMetadataMap {
|
||||||
|
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = mutableMapOf()
|
||||||
|
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(FORMAT_KEY, PrefsStatus.WARN, resourceHelper.gs(R.string.metadata_warning_outdated_format))
|
||||||
|
return metadata
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,10 +2,10 @@ package info.nightscout.androidaps.plugins.general.maintenance.formats
|
||||||
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
import info.nightscout.androidaps.utils.CryptoUtil
|
||||||
import info.nightscout.androidaps.utils.hexStringToByteArray
|
import info.nightscout.androidaps.utils.extensions.hexStringToByteArray
|
||||||
|
import info.nightscout.androidaps.utils.extensions.toHex
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
import info.nightscout.androidaps.utils.toHex
|
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -27,6 +27,16 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
val FORMAT_KEY_NOENC = "aaps_structured"
|
val FORMAT_KEY_NOENC = "aaps_structured"
|
||||||
|
|
||||||
private val KEY_CONSCIENCE = "if you remove/change this, please make sure you know the consequences!"
|
private val KEY_CONSCIENCE = "if you remove/change this, please make sure you know the consequences!"
|
||||||
|
private val FORMAT_TEST_REGEX = Regex("(\\\"format\\\"\\s*\\:\\s*\\\"aaps_[^\"]*\\\")")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isPreferencesFile(file: File, preloadedContents: String?): Boolean {
|
||||||
|
return if (file.absolutePath.endsWith(".json")) {
|
||||||
|
val contents = preloadedContents ?: storage.getFileContents(file)
|
||||||
|
FORMAT_TEST_REGEX.containsMatchIn(contents)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun savePreferences(file: File, prefs: Prefs, masterPassword: String?) {
|
override fun savePreferences(file: File, prefs: Prefs, masterPassword: String?) {
|
||||||
|
@ -45,13 +55,13 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
|
|
||||||
for ((metaKey, metaEntry) in prefs.metadata) {
|
for ((metaKey, metaEntry) in prefs.metadata) {
|
||||||
if (metaKey == PrefsMetadataKey.FILE_FORMAT)
|
if (metaKey == PrefsMetadataKey.FILE_FORMAT)
|
||||||
continue;
|
continue
|
||||||
if (metaKey == PrefsMetadataKey.ENCRYPTION)
|
if (metaKey == PrefsMetadataKey.ENCRYPTION)
|
||||||
continue;
|
continue
|
||||||
meta.put(metaKey.key, metaEntry.value)
|
meta.put(metaKey.key, metaEntry.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
container.put(PrefsMetadataKey.FILE_FORMAT.key, if (encrypted) FORMAT_KEY_ENC else FORMAT_KEY_NOENC);
|
container.put(PrefsMetadataKey.FILE_FORMAT.key, if (encrypted) FORMAT_KEY_ENC else FORMAT_KEY_NOENC)
|
||||||
container.put("metadata", meta)
|
container.put("metadata", meta)
|
||||||
|
|
||||||
val security = JSONObject()
|
val security = JSONObject()
|
||||||
|
@ -97,7 +107,6 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
||||||
|
|
||||||
val entries: MutableMap<String, String> = mutableMapOf()
|
val entries: MutableMap<String, String> = mutableMapOf()
|
||||||
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = mutableMapOf()
|
|
||||||
val issues = LinkedList<String>()
|
val issues = LinkedList<String>()
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -105,25 +114,11 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
val fileContents = jsonBody.replace(Regex("(?is)(\\\"file_hash\\\"\\s*\\:\\s*\\\")([^\"]*)(\\\")"), "$1--to-be-calculated--$3")
|
val fileContents = jsonBody.replace(Regex("(?is)(\\\"file_hash\\\"\\s*\\:\\s*\\\")([^\"]*)(\\\")"), "$1--to-be-calculated--$3")
|
||||||
val calculatedFileHash = cryptoUtil.hmac256(fileContents, KEY_CONSCIENCE)
|
val calculatedFileHash = cryptoUtil.hmac256(fileContents, KEY_CONSCIENCE)
|
||||||
val container = JSONObject(jsonBody)
|
val container = JSONObject(jsonBody)
|
||||||
|
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = loadMetadata(container)
|
||||||
|
|
||||||
if (container.has(PrefsMetadataKey.FILE_FORMAT.key) && container.has("security") && container.has("content") && container.has("metadata")) {
|
if (container.has(PrefsMetadataKey.FILE_FORMAT.key) && container.has("security") && container.has("content")) {
|
||||||
val fileFormat = container.getString(PrefsMetadataKey.FILE_FORMAT.key)
|
val fileFormat = container.getString(PrefsMetadataKey.FILE_FORMAT.key)
|
||||||
|
|
||||||
if ((fileFormat != FORMAT_KEY_ENC) && (fileFormat != FORMAT_KEY_NOENC)) {
|
|
||||||
throw PrefFormatError("Unsupported file format: " + fileFormat)
|
|
||||||
}
|
|
||||||
|
|
||||||
val meta = container.getJSONObject("metadata")
|
|
||||||
val security = container.getJSONObject("security")
|
val security = container.getJSONObject("security")
|
||||||
|
|
||||||
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(fileFormat, PrefsStatus.OK)
|
|
||||||
for (key in meta.keys()) {
|
|
||||||
val metaKey = PrefsMetadataKey.fromKey(key)
|
|
||||||
if (metaKey != null) {
|
|
||||||
metadata[metaKey] = PrefMetadata(meta.getString(key), PrefsStatus.OK)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val encrypted = fileFormat == FORMAT_KEY_ENC
|
val encrypted = fileFormat == FORMAT_KEY_ENC
|
||||||
var secure: PrefsStatus = PrefsStatus.OK
|
var secure: PrefsStatus = PrefsStatus.OK
|
||||||
var decryptedOk = false
|
var decryptedOk = false
|
||||||
|
@ -208,8 +203,6 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata[PrefsMetadataKey.ENCRYPTION] = PrefMetadata(encryptionDescStr, secure, issuesStr)
|
metadata[PrefsMetadataKey.ENCRYPTION] = PrefMetadata(encryptionDescStr, secure, issuesStr)
|
||||||
} else {
|
|
||||||
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Prefs(entries, metadata)
|
return Prefs(entries, metadata)
|
||||||
|
@ -223,4 +216,35 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun loadMetadata(contents: String?): PrefMetadataMap {
|
||||||
|
contents?.let {
|
||||||
|
val container = JSONObject(contents)
|
||||||
|
return loadMetadata(container)
|
||||||
|
}
|
||||||
|
return mutableMapOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadMetadata(container: JSONObject): MutableMap<PrefsMetadataKey, PrefMetadata> {
|
||||||
|
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = mutableMapOf()
|
||||||
|
if (container.has(PrefsMetadataKey.FILE_FORMAT.key) && container.has("security") && container.has("content") && container.has("metadata")) {
|
||||||
|
val fileFormat = container.getString(PrefsMetadataKey.FILE_FORMAT.key)
|
||||||
|
if ((fileFormat != FORMAT_KEY_ENC) && (fileFormat != FORMAT_KEY_NOENC)) {
|
||||||
|
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.metadata_format_other), PrefsStatus.ERROR)
|
||||||
|
} else {
|
||||||
|
val meta = container.getJSONObject("metadata")
|
||||||
|
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(fileFormat, PrefsStatus.OK)
|
||||||
|
for (key in meta.keys()) {
|
||||||
|
val metaKey = PrefsMetadataKey.fromKey(key)
|
||||||
|
if (metaKey != null) {
|
||||||
|
metadata[metaKey] = PrefMetadata(meta.getString(key), PrefsStatus.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance.formats
|
package info.nightscout.androidaps.plugins.general.maintenance.formats
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Parcelable
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
enum class PrefsMetadataKey(val key: String, @DrawableRes val icon:Int, @StringRes val label:Int) {
|
enum class PrefsMetadataKey(val key: String, @DrawableRes val icon: Int, @StringRes val label: Int) {
|
||||||
|
|
||||||
FILE_FORMAT("format", R.drawable.ic_meta_format, R.string.metadata_label_format),
|
FILE_FORMAT("format", R.drawable.ic_meta_format, R.string.metadata_label_format),
|
||||||
CREATED_AT("created_at", R.drawable.ic_meta_date, R.string.metadata_label_created_at),
|
CREATED_AT("created_at", R.drawable.ic_meta_date, R.string.metadata_label_created_at),
|
||||||
|
@ -33,16 +35,15 @@ enum class PrefsMetadataKey(val key: String, @DrawableRes val icon:Int, @StringR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun formatForDisplay(context: Context, value:String): String {
|
fun formatForDisplay(context: Context, value: String): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
FILE_FORMAT -> when (value) {
|
FILE_FORMAT -> when (value) {
|
||||||
ClassicPrefsFormat.FORMAT_KEY -> context.getString(R.string.metadata_format_old)
|
ClassicPrefsFormat.FORMAT_KEY -> context.getString(R.string.metadata_format_old)
|
||||||
EncryptedPrefsFormat.FORMAT_KEY_ENC -> context.getString(R.string.metadata_format_new)
|
EncryptedPrefsFormat.FORMAT_KEY_ENC -> context.getString(R.string.metadata_format_new)
|
||||||
EncryptedPrefsFormat.FORMAT_KEY_NOENC -> context.getString(R.string.metadata_format_debug)
|
EncryptedPrefsFormat.FORMAT_KEY_NOENC -> context.getString(R.string.metadata_format_debug)
|
||||||
else -> context.getString(R.string.metadata_format_other)
|
else -> context.getString(R.string.metadata_format_other)
|
||||||
}
|
}
|
||||||
CREATED_AT -> value.replace("T", " ").replace("Z", " (UTC)")
|
CREATED_AT -> value.replace("T", " ").replace("Z", " (UTC)")
|
||||||
else -> value
|
else -> value
|
||||||
|
@ -51,16 +52,21 @@ enum class PrefsMetadataKey(val key: String, @DrawableRes val icon:Int, @StringR
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class PrefMetadata(var value : String, var status : PrefsStatus, var info : String? = null)
|
@Parcelize
|
||||||
|
data class PrefMetadata(var value: String, var status: PrefsStatus, var info: String? = null) : Parcelable
|
||||||
|
|
||||||
data class Prefs(val values : Map<String, String>, var metadata : Map<PrefsMetadataKey, PrefMetadata>)
|
typealias PrefMetadataMap = Map<PrefsMetadataKey, PrefMetadata>
|
||||||
|
|
||||||
|
data class Prefs(val values: Map<String, String>, var metadata: PrefMetadataMap)
|
||||||
|
|
||||||
interface PrefsFormat {
|
interface PrefsFormat {
|
||||||
fun savePreferences(file: File, prefs: Prefs, masterPassword: String? = null)
|
fun savePreferences(file: File, prefs: Prefs, masterPassword: String? = null)
|
||||||
fun loadPreferences(file: File, masterPassword: String? = null) : Prefs
|
fun loadPreferences(file: File, masterPassword: String? = null): Prefs
|
||||||
|
fun loadMetadata(contents: String? = null): PrefMetadataMap
|
||||||
|
fun isPreferencesFile(file: File, preloadedContents: String? = null): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class PrefsStatus(@DrawableRes val icon:Int) {
|
enum class PrefsStatus(@DrawableRes val icon: Int) {
|
||||||
OK(R.drawable.ic_meta_ok),
|
OK(R.drawable.ic_meta_ok),
|
||||||
WARN(R.drawable.ic_meta_warning),
|
WARN(R.drawable.ic_meta_warning),
|
||||||
ERROR(R.drawable.ic_meta_error),
|
ERROR(R.drawable.ic_meta_error),
|
||||||
|
@ -68,6 +74,11 @@ enum class PrefsStatus(@DrawableRes val icon:Int) {
|
||||||
DISABLED(R.drawable.ic_meta_error)
|
DISABLED(R.drawable.ic_meta_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class PrefsFormatsHandler {
|
||||||
|
CLASSIC,
|
||||||
|
ENCRYPTED
|
||||||
|
}
|
||||||
|
|
||||||
class PrefFileNotFoundError(message: String) : Exception(message)
|
class PrefFileNotFoundError(message: String) : Exception(message)
|
||||||
class PrefIOError(message: String) : Exception(message)
|
class PrefIOError(message: String) : Exception(message)
|
||||||
class PrefFormatError(message: String) : Exception(message)
|
class PrefFormatError(message: String) : Exception(message)
|
||||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientN
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.HtmlHelper;
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
@ -33,6 +34,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject UploadQueue uploadQueue;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
@ -119,13 +121,13 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> {
|
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> {
|
||||||
UploadQueue.clearQueue();
|
uploadQueue.clearQueue();
|
||||||
updateGui();
|
updateGui();
|
||||||
fabricPrivacy.logCustom("NSClientClearQueue");
|
fabricPrivacy.logCustom("NSClientClearQueue");
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
rxBus.send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList()));
|
rxBus.send(new EventNSClientNewLog("QUEUE", uploadQueue.textList()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +156,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
}
|
}
|
||||||
urlTextView.setText(nsClientPlugin.url());
|
urlTextView.setText(nsClientPlugin.url());
|
||||||
Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
Spanned queuetext = HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + uploadQueue.size() + "</b>");
|
||||||
queueTextView.setText(queuetext);
|
queueTextView.setText(queuetext);
|
||||||
statusTextView.setText(nsClientPlugin.status);
|
statusTextView.setText(nsClientPlugin.status);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue