Merge branch 'dev' of github.com:MilosKozak/AndroidAPS into carbs-required
This commit is contained in:
commit
c9cf2cbae4
585 changed files with 5471 additions and 4884 deletions
|
@ -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'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,6 +158,7 @@ android {
|
||||||
}
|
}
|
||||||
firebaseDisable {
|
firebaseDisable {
|
||||||
System.setProperty("disableFirebase", "true")
|
System.setProperty("disableFirebase", "true")
|
||||||
|
ext.enableCrashlytics = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
@ -242,12 +241,14 @@ allprojects {
|
||||||
dependencies {
|
dependencies {
|
||||||
wearApp project(':wear')
|
wearApp project(':wear')
|
||||||
|
|
||||||
|
implementation project(':core')
|
||||||
|
|
||||||
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,7 +261,10 @@ 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 'com.wdullaer:materialdatetimepicker:4.2.3'
|
||||||
|
|
||||||
|
@ -271,12 +275,11 @@ 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(name: "com.atech-software.android.library.wizardpager-1.1.1", ext: "aar")
|
||||||
|
|
||||||
|
@ -288,28 +291,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"
|
||||||
|
@ -330,24 +333,24 @@ 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'
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,10 @@ 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
|
||||||
|
@ -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
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".plugins.pump.danaRS.activities.PairingHelperActivity" />
|
<activity android:name=".plugins.pump.danaRS.activities.PairingHelperActivity" />
|
||||||
|
<activity android:name=".plugins.general.maintenance.activities.PrefImportListActivity" />
|
||||||
<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" />
|
||||||
|
@ -302,6 +303,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) }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,14 +14,19 @@ import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
|
|
||||||
import net.danlew.android.joda.JodaTimeAndroid;
|
import net.danlew.android.joda.JodaTimeAndroid;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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.BgReading;
|
||||||
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.DatabaseHelperInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
@ -40,7 +45,7 @@ import info.nightscout.androidaps.utils.ActivityMonitor;
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
public class MainApp extends DaggerApplication {
|
public class MainApp extends DaggerApplication implements DatabaseHelperInterface {
|
||||||
|
|
||||||
static MainApp sInstance;
|
static MainApp sInstance;
|
||||||
private static Resources sResources;
|
private static Resources sResources;
|
||||||
|
@ -57,6 +62,8 @@ public class MainApp extends DaggerApplication {
|
||||||
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
||||||
@Inject List<PluginBase> plugins;
|
@Inject List<PluginBase> plugins;
|
||||||
|
|
||||||
|
@Inject StaticInjector staticInjector; // TODO remove , fake only to initialize
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
@ -166,4 +173,8 @@ public class MainApp extends DaggerApplication {
|
||||||
keepAliveManager.cancelAlarm(this);
|
keepAliveManager.cancelAlarm(this);
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||||
|
return getDbHelper().getAllBgreadingsDataFromTime(mills, ascending);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ 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.careportal.CareportalPlugin
|
||||||
|
@ -41,6 +41,7 @@ import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
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.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
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
|
||||||
|
@ -66,6 +67,7 @@ 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
|
||||||
|
@ -100,6 +102,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
|
||||||
|
@ -160,20 +163,20 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(poctechPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(glimpPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(careportalPlugin, 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 +282,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
|
||||||
|
|
|
@ -39,7 +39,7 @@ 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.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.pump.danaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.NonOverlappingIntervals;
|
import info.nightscout.androidaps.data.NonOverlappingIntervals;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
|
@ -47,10 +47,9 @@ import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
||||||
|
@ -61,6 +60,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
import info.nightscout.androidaps.utils.PercentageSplitter;
|
import info.nightscout.androidaps.utils.PercentageSplitter;
|
||||||
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,7 +72,7 @@ import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
* direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service.
|
* direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service.
|
||||||
*/
|
*/
|
||||||
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
|
||||||
|
|
||||||
public static final String DATABASE_NAME = "AndroidAPSDb";
|
public static final String DATABASE_NAME = "AndroidAPSDb";
|
||||||
public static final String DATABASE_BGREADINGS = "BgReadings";
|
public static final String DATABASE_BGREADINGS = "BgReadings";
|
||||||
|
@ -82,7 +82,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
||||||
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
||||||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||||
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
|
||||||
public static final String DATABASE_TDDS = "TDDs";
|
public static final String DATABASE_TDDS = "TDDs";
|
||||||
public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets";
|
public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets";
|
||||||
public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs";
|
public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs";
|
||||||
|
@ -123,7 +122,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.info("onCreate");
|
log.info("onCreate");
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
||||||
|
@ -366,7 +365,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static long roundDateToSec(long date) {
|
public static long roundDateToSec(long date) {
|
||||||
long rounded = date - date % 1000;
|
long rounded = date - date % 1000;
|
||||||
if (rounded != date)
|
if (rounded != date)
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Rounding " + date + " to " + rounded);
|
log.debug("Rounding " + date + " to " + rounded);
|
||||||
return rounded;
|
return rounded;
|
||||||
}
|
}
|
||||||
|
@ -378,17 +377,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
BgReading old = getDaoBgReadings().queryForId(bgReading.date);
|
BgReading old = getDaoBgReadings().queryForId(bgReading.date);
|
||||||
if (old == null) {
|
if (old == null) {
|
||||||
getDaoBgReadings().create(bgReading);
|
getDaoBgReadings().create(bgReading);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("BG: New record from: " + from + " " + bgReading.toString());
|
log.debug("BG: New record from: " + from + " " + bgReading.toString());
|
||||||
scheduleBgChange(bgReading);
|
scheduleBgChange(bgReading);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!old.isEqual(bgReading)) {
|
if (!old.isEqual(bgReading)) {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("BG: Similiar found: " + old.toString());
|
log.debug("BG: Similiar found: " + old.toString());
|
||||||
old.copyFrom(bgReading);
|
old.copyFrom(bgReading);
|
||||||
getDaoBgReadings().update(old);
|
getDaoBgReadings().update(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
|
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
|
||||||
scheduleBgChange(bgReading);
|
scheduleBgChange(bgReading);
|
||||||
return false;
|
return false;
|
||||||
|
@ -411,7 +410,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleBgChange(@Nullable final BgReading bgReading) {
|
private static void scheduleBgChange(@Nullable final BgReading bgReading) {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing EventNewBg");
|
log.debug("Firing EventNewBg");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewBG(bgReading));
|
RxBus.Companion.getINSTANCE().send(new EventNewBG(bgReading));
|
||||||
scheduledBgPost = null;
|
scheduledBgPost = null;
|
||||||
|
@ -640,7 +639,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().delete(old); // need to delete/create because date may change too
|
getDaoTempTargets().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(tempTarget);
|
old.copyFrom(tempTarget);
|
||||||
getDaoTempTargets().create(old);
|
getDaoTempTargets().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString());
|
log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -660,7 +659,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTempTargets().delete(old); // need to delete/create because date may change too
|
getDaoTempTargets().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(tempTarget);
|
old.copyFrom(tempTarget);
|
||||||
getDaoTempTargets().create(old);
|
getDaoTempTargets().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString());
|
log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -668,14 +667,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDaoTempTargets().create(tempTarget);
|
getDaoTempTargets().create(tempTarget);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
|
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (tempTarget.source == Source.USER) {
|
if (tempTarget.source == Source.USER) {
|
||||||
getDaoTempTargets().create(tempTarget);
|
getDaoTempTargets().create(tempTarget);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
|
log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -698,7 +697,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleTemporaryTargetChange() {
|
private static void scheduleTemporaryTargetChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing EventTempTargetChange");
|
log.debug("Firing EventTempTargetChange");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventTempTargetChange());
|
RxBus.Companion.getINSTANCE().send(new EventTempTargetChange());
|
||||||
scheduledTemTargetPost = null;
|
scheduledTemTargetPost = null;
|
||||||
|
@ -824,7 +823,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery);
|
List<TemporaryBasal> trList = getDaoTemporaryBasal().query(preparedQuery);
|
||||||
if (trList.size() > 0) {
|
if (trList.size() > 0) {
|
||||||
// do nothing, pump history record cannot be changed
|
// do nothing, pump history record cannot be changed
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -842,7 +841,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
old.copyFromPump(tempBasal);
|
old.copyFromPump(tempBasal);
|
||||||
old.source = Source.PUMP;
|
old.source = Source.PUMP;
|
||||||
|
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: Updated record with Pump Data : " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: Updated record with Pump Data : " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
|
|
||||||
getDaoTemporaryBasal().update(old);
|
getDaoTemporaryBasal().update(old);
|
||||||
|
@ -854,7 +853,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
|
@ -872,7 +871,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
|
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(tempBasal);
|
old.copyFrom(tempBasal);
|
||||||
getDaoTemporaryBasal().create(old);
|
getDaoTemporaryBasal().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString());
|
log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
|
@ -895,7 +894,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
|
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(tempBasal);
|
old.copyFrom(tempBasal);
|
||||||
getDaoTemporaryBasal().create(old);
|
getDaoTemporaryBasal().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString());
|
log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
|
@ -905,7 +904,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
|
@ -913,7 +912,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
if (tempBasal.source == Source.USER) {
|
if (tempBasal.source == Source.USER) {
|
||||||
getDaoTemporaryBasal().create(tempBasal);
|
getDaoTemporaryBasal().create(tempBasal);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString());
|
||||||
updateEarliestDataChange(tempBasal.date);
|
updateEarliestDataChange(tempBasal.date);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
|
@ -970,7 +969,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleTemporaryBasalChange() {
|
private static void scheduleTemporaryBasalChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing EventTempBasalChange");
|
log.debug("Firing EventTempBasalChange");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventReloadTempBasalData());
|
RxBus.Companion.getINSTANCE().send(new EventReloadTempBasalData());
|
||||||
RxBus.Companion.getINSTANCE().send(new EventTempBasalChange());
|
RxBus.Companion.getINSTANCE().send(new EventTempBasalChange());
|
||||||
|
@ -1065,7 +1064,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void deleteTempBasalById(String _id) {
|
public void deleteTempBasalById(String _id) {
|
||||||
TemporaryBasal stored = findTempBasalById(_id);
|
TemporaryBasal stored = findTempBasalById(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString());
|
log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString());
|
||||||
delete(stored);
|
delete(stored);
|
||||||
updateEarliestDataChange(stored.date);
|
updateEarliestDataChange(stored.date);
|
||||||
|
@ -1120,7 +1119,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public boolean createOrUpdate(ExtendedBolus extendedBolus) {
|
public boolean createOrUpdate(ExtendedBolus extendedBolus) {
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
log.debug("EXTENDEDBOLUS: createOrUpdate: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
||||||
|
|
||||||
ExtendedBolus old;
|
ExtendedBolus old;
|
||||||
|
@ -1145,7 +1144,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
getDaoExtendedBolus().createOrUpdate(extendedBolus);
|
getDaoExtendedBolus().createOrUpdate(extendedBolus);
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -1159,7 +1158,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
|
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(extendedBolus);
|
old.copyFrom(extendedBolus);
|
||||||
getDaoExtendedBolus().create(old);
|
getDaoExtendedBolus().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.log());
|
log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.log());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
|
@ -1182,7 +1181,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
|
getDaoExtendedBolus().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(extendedBolus);
|
old.copyFrom(extendedBolus);
|
||||||
getDaoExtendedBolus().create(old);
|
getDaoExtendedBolus().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.log());
|
log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.log());
|
||||||
updateEarliestDataChange(oldDate);
|
updateEarliestDataChange(oldDate);
|
||||||
updateEarliestDataChange(old.date);
|
updateEarliestDataChange(old.date);
|
||||||
|
@ -1192,7 +1191,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDaoExtendedBolus().create(extendedBolus);
|
getDaoExtendedBolus().create(extendedBolus);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -1200,7 +1199,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
if (extendedBolus.source == Source.USER) {
|
if (extendedBolus.source == Source.USER) {
|
||||||
getDaoExtendedBolus().create(extendedBolus);
|
getDaoExtendedBolus().create(extendedBolus);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.log());
|
||||||
updateEarliestDataChange(extendedBolus.date);
|
updateEarliestDataChange(extendedBolus.date);
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -1249,10 +1248,26 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<ExtendedBolus>();
|
return new ArrayList<ExtendedBolus>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ExtendedBolus> getExtendedBolusDataFromTime(long from, long to, boolean ascending) {
|
||||||
|
try {
|
||||||
|
List<ExtendedBolus> extendedBoluses;
|
||||||
|
QueryBuilder<ExtendedBolus, Long> queryBuilder = getDaoExtendedBolus().queryBuilder();
|
||||||
|
queryBuilder.orderBy("date", ascending);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.between("date", from, to);
|
||||||
|
PreparedQuery<ExtendedBolus> preparedQuery = queryBuilder.prepare();
|
||||||
|
extendedBoluses = getDaoExtendedBolus().query(preparedQuery);
|
||||||
|
return extendedBoluses;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<ExtendedBolus>();
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteExtendedBolusById(String _id) {
|
public void deleteExtendedBolusById(String _id) {
|
||||||
ExtendedBolus stored = findExtendedBolusById(_id);
|
ExtendedBolus stored = findExtendedBolusById(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString());
|
log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString());
|
||||||
delete(stored);
|
delete(stored);
|
||||||
updateEarliestDataChange(stored.date);
|
updateEarliestDataChange(stored.date);
|
||||||
|
@ -1306,7 +1321,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleExtendedBolusChange() {
|
private static void scheduleExtendedBolusChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing EventExtendedBolusChange");
|
log.debug("Firing EventExtendedBolusChange");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
RxBus.Companion.getINSTANCE().send(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
|
@ -1468,11 +1483,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
CareportalEvent record = list.get(0);
|
CareportalEvent record = list.get(0);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Removing CareportalEvent record from database: " + record.toString());
|
log.debug("Removing CareportalEvent record from database: " + record.toString());
|
||||||
delete(record);
|
delete(record);
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("CareportalEvent not found database: " + _id);
|
log.debug("CareportalEvent not found database: " + _id);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -1492,12 +1507,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
careportalEvent = new CareportalEvent(MainApp.instance());
|
careportalEvent = new CareportalEvent(MainApp.instance());
|
||||||
careportalEvent.source = Source.NIGHTSCOUT;
|
careportalEvent.source = Source.NIGHTSCOUT;
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Adding CareportalEvent record to database: " + trJson.toString());
|
log.debug("Adding CareportalEvent record to database: " + trJson.toString());
|
||||||
// Record does not exists. add
|
// Record does not exists. add
|
||||||
} else if (list.size() == 1) {
|
} else if (list.size() == 1) {
|
||||||
careportalEvent = list.get(0);
|
careportalEvent = list.get(0);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Updating CareportalEvent record in database: " + trJson.toString());
|
log.debug("Updating CareportalEvent record in database: " + trJson.toString());
|
||||||
} else {
|
} else {
|
||||||
log.error("Something went wrong");
|
log.error("Something went wrong");
|
||||||
|
@ -1516,7 +1531,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleCareportalEventChange() {
|
private static void scheduleCareportalEventChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing scheduleCareportalEventChange");
|
log.debug("Firing scheduleCareportalEventChange");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventCareportalEventChange());
|
RxBus.Companion.getINSTANCE().send(new EventCareportalEventChange());
|
||||||
scheduledCareportalEventPost = null;
|
scheduledCareportalEventPost = null;
|
||||||
|
@ -1629,7 +1644,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension
|
profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension
|
||||||
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1649,7 +1664,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
getDaoProfileSwitch().delete(old); // need to delete/create because date may change too
|
||||||
old.copyFrom(profileSwitch);
|
old.copyFrom(profileSwitch);
|
||||||
getDaoProfileSwitch().create(old);
|
getDaoProfileSwitch().create(old);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1659,14 +1674,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
// look for already added percentage from NS
|
// look for already added percentage from NS
|
||||||
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
|
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (profileSwitch.source == Source.USER) {
|
if (profileSwitch.source == Source.USER) {
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1689,7 +1704,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static void scheduleProfileSwitchChange() {
|
private static void scheduleProfileSwitchChange() {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Firing EventProfileNeedsUpdate");
|
log.debug("Firing EventProfileNeedsUpdate");
|
||||||
RxBus.Companion.getINSTANCE().send(new EventReloadProfileSwitchData());
|
RxBus.Companion.getINSTANCE().send(new EventReloadProfileSwitchData());
|
||||||
RxBus.Companion.getINSTANCE().send(new EventProfileNeedsUpdate());
|
RxBus.Companion.getINSTANCE().send(new EventProfileNeedsUpdate());
|
||||||
|
@ -1741,17 +1756,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
profileSwitch.profileJson = profile.getData().toString();
|
profileSwitch.profileJson = profile.getData().toString();
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Profile switch prefilled with JSON from local store");
|
log.debug("Profile switch prefilled with JSON from local store");
|
||||||
// Update data in NS
|
// Update data in NS
|
||||||
NSUpload.updateProfileSwitch(profileSwitch);
|
NSUpload.updateProfileSwitch(profileSwitch);
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString());
|
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString());
|
log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1767,7 +1782,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void deleteProfileSwitchById(String _id) {
|
public void deleteProfileSwitchById(String _id) {
|
||||||
ProfileSwitch stored = findProfileSwitchById(_id);
|
ProfileSwitch stored = findProfileSwitchById(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(LTag.DATABASE))
|
||||||
log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString());
|
log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString());
|
||||||
delete(stored);
|
delete(stored);
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
|
@ -1886,4 +1901,52 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Copied from xDrip+
|
||||||
|
String calculateDirection(BgReading bgReading) {
|
||||||
|
// Rework to get bgreaings from internal DB and calculate on that base
|
||||||
|
|
||||||
|
List<BgReading> bgReadingsList = MainApp.getDbHelper().getAllBgreadingsDataFromTime(bgReading.date - T.mins(10).msecs(), false);
|
||||||
|
if (bgReadingsList == null || bgReadingsList.size() < 2)
|
||||||
|
return "NONE";
|
||||||
|
BgReading current = bgReadingsList.get(1);
|
||||||
|
BgReading previous = bgReadingsList.get(0);
|
||||||
|
|
||||||
|
if (bgReadingsList.get(1).date < bgReadingsList.get(0).date) {
|
||||||
|
current = bgReadingsList.get(0);
|
||||||
|
previous = bgReadingsList.get(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
double slope;
|
||||||
|
|
||||||
|
// Avoid division by 0
|
||||||
|
if (current.date == previous.date)
|
||||||
|
slope = 0;
|
||||||
|
else
|
||||||
|
slope = (previous.value - current.value) / (previous.date - current.date);
|
||||||
|
|
||||||
|
// aapsLogger.error(LTag.GLUCOSE, "Slope is :" + slope + " delta " + (previous.value - current.value) + " date difference " + (current.date - previous.date));
|
||||||
|
|
||||||
|
double slope_by_minute = slope * 60000;
|
||||||
|
String arrow = "NONE";
|
||||||
|
|
||||||
|
if (slope_by_minute <= (-3.5)) {
|
||||||
|
arrow = "DoubleDown";
|
||||||
|
} else if (slope_by_minute <= (-2)) {
|
||||||
|
arrow = "SingleDown";
|
||||||
|
} else if (slope_by_minute <= (-1)) {
|
||||||
|
arrow = "FortyFiveDown";
|
||||||
|
} else if (slope_by_minute <= (1)) {
|
||||||
|
arrow = "Flat";
|
||||||
|
} else if (slope_by_minute <= (2)) {
|
||||||
|
arrow = "FortyFiveUp";
|
||||||
|
} else if (slope_by_minute <= (3.5)) {
|
||||||
|
arrow = "SingleUp";
|
||||||
|
} else if (slope_by_minute <= (40)) {
|
||||||
|
arrow = "DoubleUp";
|
||||||
|
}
|
||||||
|
// aapsLogger.error(LTag.GLUCOSE, "Direction set to: " + arrow);
|
||||||
|
return arrow;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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
|
||||||
|
@ -48,4 +49,5 @@ abstract class ActivitiesModule {
|
||||||
@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 contributesTDDStatsActivity(): TDDStatsActivity
|
||||||
|
@ContributesAndroidInjector abstract fun contributesPrefImportListActivity(): PrefImportListActivity
|
||||||
}
|
}
|
|
@ -5,54 +5,14 @@ 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.dependencyInjection.CoreModule
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
|
||||||
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.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,
|
||||||
|
CoreModule::class,
|
||||||
ActivitiesModule::class,
|
ActivitiesModule::class,
|
||||||
FragmentsModule::class,
|
FragmentsModule::class,
|
||||||
AppModule::class,
|
AppModule::class,
|
||||||
|
@ -67,7 +27,8 @@ import javax.inject.Singleton
|
||||||
PreferencesModule::class,
|
PreferencesModule::class,
|
||||||
OverviewModule::class,
|
OverviewModule::class,
|
||||||
DataClassesModule::class,
|
DataClassesModule::class,
|
||||||
SMSModule::class
|
SMSModule::class,
|
||||||
|
UIModule::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
interface AppComponent : AndroidInjector<MainApp> {
|
interface AppComponent : AndroidInjector<MainApp> {
|
||||||
|
|
|
@ -1,88 +1,33 @@
|
||||||
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.interfaces.*
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
|
||||||
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.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.configBuilder.ProfileFunctionImplementation
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
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.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.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
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.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,
|
||||||
|
PluginsModule::class,
|
||||||
|
SkinsModule::class
|
||||||
|
])
|
||||||
open class AppModule {
|
open class AppModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideSharedPreferences(context: Context, resourceHelper: ResourceHelper): SP {
|
|
||||||
return SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), resourceHelper)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideProfileFunction(injector: HasAndroidInjector, aapsLogger: AAPSLogger, sp: SP, resourceHelper: ResourceHelper, activePlugin: ActivePluginProvider, fabricPrivacy: FabricPrivacy): ProfileFunction {
|
fun provideProfileFunction(injector: HasAndroidInjector, aapsLogger: AAPSLogger, sp: SP, resourceHelper: ResourceHelper, activePlugin: ActivePluginProvider, fabricPrivacy: FabricPrivacy): ProfileFunction {
|
||||||
|
@ -90,35 +35,18 @@ open class AppModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
fun providesPlugins(configInterface: ConfigInterface,
|
||||||
fun provideResources(mainApp: MainApp): ResourceHelper {
|
@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
|
||||||
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.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()
|
if (configInterface.NSCLIENT) plugins += nsClient.get()
|
||||||
return plugins.toList().sortedBy { it.first }.map { it.second }
|
return plugins.toList().sortedBy { it.first }.map { it.second }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +61,11 @@ 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 bindDatabaseHelperInterface(mainApp: MainApp): DatabaseHelperInterface
|
||||||
@Binds
|
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
||||||
fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
|
||||||
|
|
||||||
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||||
|
@Binds fun configInterfaceProvider(config: Config): ConfigInterface
|
||||||
|
@Binds fun treatmentInterfaceProvider(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,14 @@ 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.interfaces.ProfileStore
|
||||||
import info.nightscout.androidaps.db.BgReading
|
import info.nightscout.androidaps.db.BgReading
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
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.db.Treatment
|
||||||
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
|
||||||
|
@ -23,6 +23,7 @@ abstract class DataClassesModule {
|
||||||
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
|
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
|
||||||
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStore
|
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStore
|
||||||
|
|
||||||
|
// TODO move to Core
|
||||||
@ContributesAndroidInjector abstract fun bgReadingInjector(): BgReading
|
@ContributesAndroidInjector abstract fun bgReadingInjector(): BgReading
|
||||||
@ContributesAndroidInjector abstract fun treatmentInjector(): Treatment
|
@ContributesAndroidInjector abstract fun treatmentInjector(): Treatment
|
||||||
@ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch
|
@ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment
|
||||||
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
|
||||||
|
@ -71,6 +72,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
|
||||||
|
|
|
@ -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,9 @@
|
||||||
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.Config
|
|
||||||
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
|
||||||
|
@ -45,6 +41,7 @@ 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
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.services.DanaRv2Execution
|
||||||
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
|
||||||
|
@ -39,4 +40,5 @@ abstract class ServicesModule {
|
||||||
@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
|
||||||
|
}
|
|
@ -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
|
||||||
|
@ -170,7 +170,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 +184,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 ->
|
||||||
|
|
|
@ -15,7 +15,7 @@ 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
|
||||||
|
@ -167,7 +167,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)
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -112,7 +112,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 ->
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
private var time: Long = 0
|
private var time: Long = 0
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
||||||
Mode.RUNNING_PROFILE -> {
|
Mode.RUNNING_PROFILE -> {
|
||||||
profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject
|
profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject
|
||||||
profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName
|
profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName
|
||||||
date = DateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date
|
date = dateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date
|
||||||
?: 0)
|
?: 0)
|
||||||
profileview_datelayout.visibility = View.VISIBLE
|
profileview_datelayout.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -14,7 +14,7 @@ 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.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
|
@ -129,7 +129,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
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 ****
|
||||||
|
|
|
@ -4,12 +4,13 @@ import dagger.android.HasAndroidInjector
|
||||||
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.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
|
||||||
|
@ -27,9 +28,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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.aps.loop;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -366,7 +365,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DeviceStatus {
|
public class DeviceStatus {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
public String device = null;
|
public String device = null;
|
||||||
public JSONObject pump = null;
|
public JSONObject pump = null;
|
||||||
|
|
|
@ -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()) }
|
||||||
?: ""
|
?: ""
|
||||||
|
|
|
@ -53,7 +53,7 @@ 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.interfaces.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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
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.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.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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,25 @@ 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")
|
||||||
}
|
}
|
||||||
|
|
||||||
sp.putBoolean(R.string.key_objectiveuseactions, true)
|
sp.putBoolean(R.string.key_objectiveuseactions, true)
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,7 +29,7 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -125,9 +125,7 @@ class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
||||||
R.id.careportal_openapsoffline -> newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline)
|
R.id.careportal_openapsoffline -> newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline)
|
||||||
R.id.careportal_temporarytarget -> newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget)
|
R.id.careportal_temporarytarget -> newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget)
|
||||||
}
|
}
|
||||||
fragmentManager?.let {
|
NewNSTreatmentDialog().show(childFragmentManager, "CareportalFragment")
|
||||||
NewNSTreatmentDialog().show(it, "CareportalFragment")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateGUI() {
|
private fun updateGUI() {
|
||||||
|
|
|
@ -15,14 +15,15 @@ import javax.inject.Singleton
|
||||||
class CareportalPlugin @Inject constructor(
|
class CareportalPlugin @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(CareportalFragment::class.java.name)
|
.fragmentClass(CareportalFragment::class.java.name)
|
||||||
.pluginName(R.string.careportal)
|
.pluginName(R.string.careportal)
|
||||||
.shortName(R.string.careportal_shortname)
|
.shortName(R.string.careportal_shortname)
|
||||||
.visibleByDefault(Config.NSCLIENT)
|
.visibleByDefault(config.NSCLIENT)
|
||||||
.enableByDefault(Config.NSCLIENT)
|
.enableByDefault(config.NSCLIENT)
|
||||||
.description(R.string.description_careportal),
|
.description(R.string.description_careportal),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
)
|
)
|
|
@ -44,14 +44,14 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
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.careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
||||||
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;
|
||||||
|
@ -61,9 +61,9 @@ import info.nightscout.androidaps.utils.DefaultValueHelper;
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
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 info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
||||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||||
@Inject HardLimits hardLimits;
|
@Inject HardLimits hardLimits;
|
||||||
@Inject Translator translator;
|
@Inject Translator translator;
|
||||||
|
@Inject DateUtil dateUtil;
|
||||||
|
|
||||||
private static OptionsToShow options;
|
private static OptionsToShow options;
|
||||||
private static @StringRes int event;
|
private static @StringRes int event;
|
||||||
|
@ -168,7 +169,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
||||||
dateButton = view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
dateButton = view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
||||||
timeButton = view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
timeButton = view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
||||||
dateButton.setText(DateUtil.dateString(eventTime));
|
dateButton.setText(DateUtil.dateString(eventTime));
|
||||||
timeButton.setText(DateUtil.timeString(eventTime));
|
timeButton.setText(dateUtil.timeString(eventTime));
|
||||||
dateButton.setOnClickListener(this);
|
dateButton.setOnClickListener(this);
|
||||||
timeButton.setOnClickListener(this);
|
timeButton.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -484,7 +485,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
||||||
eventTime.setHours(hourOfDay);
|
eventTime.setHours(hourOfDay);
|
||||||
eventTime.setMinutes(minute);
|
eventTime.setMinutes(minute);
|
||||||
eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually
|
eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually
|
||||||
timeButton.setText(DateUtil.timeString(eventTime));
|
timeButton.setText(dateUtil.timeString(eventTime));
|
||||||
updateBGforDateTime();
|
updateBGforDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,7 +699,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
||||||
if (data.has("created_at")) {
|
if (data.has("created_at")) {
|
||||||
ret += resourceHelper.gs(R.string.event_time_label);
|
ret += resourceHelper.gs(R.string.event_time_label);
|
||||||
ret += ": ";
|
ret += ": ";
|
||||||
ret += DateUtil.dateAndTimeString(eventTime);
|
ret += dateUtil.dateAndTimeString(eventTime);
|
||||||
ret += "\n";
|
ret += "\n";
|
||||||
}
|
}
|
||||||
if (data.has("enteredBy")) {
|
if (data.has("enteredBy")) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ 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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -32,6 +31,7 @@ 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.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
@ -43,7 +43,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
private Logger log = StacktraceLoggerWrapper.getLogger(L.DATAFOOD);
|
private Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATAFOOD);
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
@ -98,7 +98,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.info("onCreate");
|
log.info("onCreate");
|
||||||
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -108,7 +108,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
if (L.isEnabled(L.DATAFOOD))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.info("onUpgrade");
|
log.info("onUpgrade");
|
||||||
// this.resetFood();
|
// this.resetFood();
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ 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))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.debug("Firing EventFoodChange");
|
log.debug("Firing EventFoodChange");
|
||||||
RxBus.Companion.getINSTANCE().send(event);
|
RxBus.Companion.getINSTANCE().send(event);
|
||||||
callback.setPost(null);
|
callback.setPost(null);
|
||||||
|
@ -258,7 +258,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))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.debug("Removing Food record from database: " + stored.toString());
|
log.debug("Removing Food record from database: " + stored.toString());
|
||||||
this.delete(stored);
|
this.delete(stored);
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ 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))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.debug("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);
|
log.error("Unable to createOrUpdate Food", e);
|
||||||
|
@ -323,7 +323,7 @@ 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))
|
if (L.isEnabled(LTag.DATAFOOD))
|
||||||
log.debug("New record: " + food.toString());
|
log.debug("New record: " + food.toString());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unable to create Food", e);
|
log.error("Unable to create Food", e);
|
||||||
|
|
|
@ -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
|
||||||
|
@ -22,9 +22,9 @@ 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.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 +32,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 +49,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 +121,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 +156,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 +199,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 +216,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 +283,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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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?) {
|
||||||
|
@ -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,10 +35,9 @@ 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)
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -11,7 +11,6 @@ import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -58,6 +57,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
private final Config config;
|
||||||
|
|
||||||
public Handler handler;
|
public Handler handler;
|
||||||
|
|
||||||
|
@ -81,7 +81,8 @@ public class NSClientPlugin extends PluginBase {
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
Context context,
|
Context context,
|
||||||
SP sp,
|
SP sp,
|
||||||
NsClientReceiverDelegate nsClientReceiverDelegate
|
NsClientReceiverDelegate nsClientReceiverDelegate,
|
||||||
|
Config config
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -99,8 +100,9 @@ public class NSClientPlugin extends PluginBase {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.nsClientReceiverDelegate = nsClientReceiverDelegate;
|
this.nsClientReceiverDelegate = nsClientReceiverDelegate;
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
if (Config.NSCLIENT) {
|
if (config.getNSCLIENT()) {
|
||||||
getPluginDescription().alwaysEnabled(true).visibleByDefault(true);
|
getPluginDescription().alwaysEnabled(true).visibleByDefault(true);
|
||||||
}
|
}
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
|
@ -184,7 +186,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
public void preprocessPreferences(@NotNull PreferenceFragmentCompat preferenceFragment) {
|
public void preprocessPreferences(@NotNull PreferenceFragmentCompat preferenceFragment) {
|
||||||
super.preprocessPreferences(preferenceFragment);
|
super.preprocessPreferences(preferenceFragment);
|
||||||
|
|
||||||
if (Config.NSCLIENT) {
|
if (config.getNSCLIENT()) {
|
||||||
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced));
|
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.DbRequest;
|
import info.nightscout.androidaps.db.DbRequest;
|
||||||
|
@ -35,11 +35,12 @@ import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus;
|
import info.nightscout.androidaps.plugins.aps.loop.DeviceStatus;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
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.receivers.ReceiverStatusStore;
|
import info.nightscout.androidaps.receivers.ReceiverStatusStore;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
@ -50,7 +51,7 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
* Created by mike on 26.05.2017.
|
* Created by mike on 26.05.2017.
|
||||||
*/
|
*/
|
||||||
public class NSUpload {
|
public class NSUpload {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
|
public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
|
||||||
try {
|
try {
|
||||||
|
@ -200,7 +201,7 @@ public class NSUpload {
|
||||||
deviceStatus.enacted.put("requested", requested);
|
deviceStatus.enacted.put("requested", requested);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("OpenAPS data too old to upload, sending iob only");
|
log.debug("OpenAPS data too old to upload, sending iob only");
|
||||||
IobTotal[] iob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile);
|
IobTotal[] iob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile);
|
||||||
if (iob.length > 0) {
|
if (iob.length > 0) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.j256.ormlite.dao.CloseableIterator;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@ -18,6 +17,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.DbRequest;
|
import info.nightscout.androidaps.db.DbRequest;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend;
|
||||||
|
@ -28,7 +28,7 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
* Created by mike on 21.02.2016.
|
* Created by mike on 21.02.2016.
|
||||||
*/
|
*/
|
||||||
public class UploadQueue {
|
public class UploadQueue {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
public static String status() {
|
public static String status() {
|
||||||
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
|
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
|
||||||
|
@ -48,7 +48,7 @@ public class UploadQueue {
|
||||||
|
|
||||||
public static void add(final DbRequest dbr) {
|
public static void add(final DbRequest dbr) {
|
||||||
if (SP.getBoolean(R.string.key_ns_noupload, false)) return;
|
if (SP.getBoolean(R.string.key_ns_noupload, false)) return;
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("Adding to queue: " + dbr.log());
|
log.debug("Adding to queue: " + dbr.log());
|
||||||
try {
|
try {
|
||||||
MainApp.getDbHelper().create(dbr);
|
MainApp.getDbHelper().create(dbr);
|
||||||
|
@ -62,10 +62,10 @@ public class UploadQueue {
|
||||||
startService();
|
startService();
|
||||||
if (NSClientService.handler != null) {
|
if (NSClientService.handler != null) {
|
||||||
NSClientService.handler.post(() -> {
|
NSClientService.handler.post(() -> {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("ClearQueue");
|
log.debug("ClearQueue");
|
||||||
MainApp.getDbHelper().deleteAllDbRequests();
|
MainApp.getDbHelper().deleteAllDbRequests();
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug(status());
|
log.debug(status());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class UploadQueue {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
|
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("Removed item from UploadQueue. " + UploadQueue.status());
|
log.debug("Removed item from UploadQueue. " + UploadQueue.status());
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -100,7 +100,7 @@ public class UploadQueue {
|
||||||
if (NSClientService.handler != null) {
|
if (NSClientService.handler != null) {
|
||||||
NSClientService.handler.post(() -> {
|
NSClientService.handler.post(() -> {
|
||||||
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
|
log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
|
@ -16,7 +16,7 @@ import io.socket.client.Ack;
|
||||||
* Created by mike on 29.12.2015.
|
* Created by mike on 29.12.2015.
|
||||||
*/
|
*/
|
||||||
public class NSAddAck extends Event implements Ack {
|
public class NSAddAck extends Event implements Ack {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
public String _id = null;
|
public String _id = null;
|
||||||
public String nsClientID = null;
|
public String nsClientID = null;
|
||||||
public JSONObject json = null;
|
public JSONObject json = null;
|
||||||
|
@ -48,7 +48,7 @@ public class NSAddAck extends Event implements Ack {
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNSClientRestart());
|
RxBus.Companion.getINSTANCE().send(new EventNSClientRestart());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("DBACCESS " + response.getString("result"));
|
log.debug("DBACCESS " + response.getString("result"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import io.socket.client.Ack;
|
import io.socket.client.Ack;
|
||||||
|
@ -15,12 +14,13 @@ import io.socket.client.Ack;
|
||||||
* Created by mike on 21.02.2016.
|
* Created by mike on 21.02.2016.
|
||||||
*/
|
*/
|
||||||
public class NSUpdateAck extends Event implements Ack {
|
public class NSUpdateAck extends Event implements Ack {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
public boolean result = false;
|
public boolean result = false;
|
||||||
public String _id;
|
public String _id;
|
||||||
public String action;
|
public String action;
|
||||||
public void call(Object...args) {
|
|
||||||
JSONObject response = (JSONObject)args[0];
|
public void call(Object... args) {
|
||||||
|
JSONObject response = (JSONObject) args[0];
|
||||||
if (response.has("result"))
|
if (response.has("result"))
|
||||||
try {
|
try {
|
||||||
if (response.getString("result").equals("success"))
|
if (response.getString("result").equals("success"))
|
||||||
|
|
|
@ -115,7 +115,8 @@ class NSSettingsStatus @Inject constructor(
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val defaultValueHelper: DefaultValueHelper,
|
private val defaultValueHelper: DefaultValueHelper,
|
||||||
private val sp: SP
|
private val sp: SP,
|
||||||
|
private val config: Config
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var nightscoutVersionName = ""
|
var nightscoutVersionName = ""
|
||||||
|
@ -126,7 +127,7 @@ class NSSettingsStatus @Inject constructor(
|
||||||
fun handleNewData(nightscoutVersionName: String, nightscoutVersionCode: Int, status: JSONObject) {
|
fun handleNewData(nightscoutVersionName: String, nightscoutVersionCode: Int, status: JSONObject) {
|
||||||
this.nightscoutVersionName = nightscoutVersionName
|
this.nightscoutVersionName = nightscoutVersionName
|
||||||
aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: $nightscoutVersionName")
|
aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: $nightscoutVersionName")
|
||||||
if (nightscoutVersionCode < Config.SUPPORTEDNSVERSION) {
|
if (nightscoutVersionCode < config.SUPPORTEDNSVERSION) {
|
||||||
val notification = Notification(Notification.OLD_NS, resourceHelper.gs(R.string.unsupportednsversion), Notification.NORMAL)
|
val notification = Notification(Notification.OLD_NS, resourceHelper.gs(R.string.unsupportednsversion), Notification.NORMAL)
|
||||||
rxBus.send(EventNewNotification(notification))
|
rxBus.send(EventNewNotification(notification))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.general.nsclient.data;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
|
|
||||||
public class NSTreatment {
|
public class NSTreatment {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
private JSONObject data;
|
private JSONObject data;
|
||||||
private String action = null; // "update", "remove" or null (add)
|
private String action = null; // "update", "remove" or null (add)
|
||||||
|
@ -82,15 +81,47 @@ public class NSTreatment {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAction() { return action; }
|
public String getAction() {
|
||||||
public JSONObject getData() { return data; }
|
return action;
|
||||||
public String get_id() { return getStringOrNull("_id"); }
|
}
|
||||||
public String getEnteredBy() { return getStringOrNull("enteredBy"); }
|
|
||||||
public String getEventType() { return getStringOrNull("eventType"); }
|
public JSONObject getData() {
|
||||||
public Integer getHapp_id() { return getIntegerOrNull("happ_id"); }
|
return data;
|
||||||
public Integer getDuration() { return getIntegerOrNull("duration"); }
|
}
|
||||||
public Integer getMgdl() { return getIntegerOrNull("mgdl"); }
|
|
||||||
public Double getAbsolute() { return getDoubleOrNull("absolute"); }
|
public String get_id() {
|
||||||
public Long getMills() { return getLongOrNull("mills"); }
|
return getStringOrNull("_id");
|
||||||
public Date getCreated_at() { return getDateOrNull("created_at"); }
|
}
|
||||||
|
|
||||||
|
public String getEnteredBy() {
|
||||||
|
return getStringOrNull("enteredBy");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventType() {
|
||||||
|
return getStringOrNull("eventType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHapp_id() {
|
||||||
|
return getIntegerOrNull("happ_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDuration() {
|
||||||
|
return getIntegerOrNull("duration");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMgdl() {
|
||||||
|
return getIntegerOrNull("mgdl");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAbsolute() {
|
||||||
|
return getDoubleOrNull("absolute");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMills() {
|
||||||
|
return getLongOrNull("mills");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated_at() {
|
||||||
|
return getDateOrNull("created_at");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ 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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -31,11 +30,10 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.DaggerService;
|
import dagger.android.DaggerService;
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.DbRequest;
|
import info.nightscout.androidaps.db.DbRequest;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
|
@ -91,8 +89,10 @@ public class NSClientService extends DaggerService {
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject NSClientPlugin nsClientPlugin;
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
@Inject BuildHelper buildHelper;
|
@Inject BuildHelper buildHelper;
|
||||||
|
@Inject Config config;
|
||||||
|
@Inject DateUtil dateUtil;
|
||||||
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.NSCLIENT);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
static public PowerManager.WakeLock mWakeLock;
|
static public PowerManager.WakeLock mWakeLock;
|
||||||
|
@ -178,7 +178,7 @@ public class NSClientService extends DaggerService {
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("EventAppExit received");
|
log.debug("EventAppExit received");
|
||||||
destroy();
|
destroy();
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
@ -367,7 +367,7 @@ public class NSClientService extends DaggerService {
|
||||||
private Emitter.Listener onDisconnect = new Emitter.Listener() {
|
private Emitter.Listener onDisconnect = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("disconnect reason: {}", args);
|
log.debug("disconnect reason: {}", args);
|
||||||
rxBus.send(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
|
rxBus.send(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ public class NSClientService extends DaggerService {
|
||||||
nsSettingsStatus.setData(status);
|
nsSettingsStatus.setData(status);
|
||||||
|
|
||||||
if (!status.has("versionNum")) {
|
if (!status.has("versionNum")) {
|
||||||
if (status.getInt("versionNum") < Config.SUPPORTEDNSVERSION) {
|
if (status.getInt("versionNum") < config.getSUPPORTEDNSVERSION()) {
|
||||||
rxBus.send(new EventNSClientNewLog("ERROR", "Unsupported Nightscout version !!!!"));
|
rxBus.send(new EventNSClientNewLog("ERROR", "Unsupported Nightscout version !!!!"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -722,7 +722,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
handleNewSgv(sgvs, isDelta);
|
handleNewSgv(sgvs, isDelta);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData)));
|
rxBus.send(new EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData)));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ public class NSClientService extends DaggerService {
|
||||||
if (mSocket == null || !mSocket.connected()) return;
|
if (mSocket == null || !mSocket.connected()) return;
|
||||||
|
|
||||||
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
|
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
|
||||||
if (L.isEnabled(L.NSCLIENT))
|
if (L.isEnabled(LTag.NSCLIENT))
|
||||||
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,15 @@ import info.nightscout.androidaps.dialogs.WizardDialog
|
||||||
import info.nightscout.androidaps.events.*
|
import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
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.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
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.data.NSDeviceStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
|
||||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
|
@ -57,6 +58,7 @@ import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
||||||
import info.nightscout.androidaps.plugins.source.XdripPlugin
|
import info.nightscout.androidaps.plugins.source.XdripPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.skins.SkinProvider
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
|
@ -64,41 +66,33 @@ 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.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.*
|
import kotlinx.android.synthetic.main.overview_buttons_layout.*
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_canulaage
|
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_carbsbutton
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_insulinage
|
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_insulinbutton
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_reservoirlevel
|
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_quickwizardbutton
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_sensorage
|
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_treatmentbutton
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_pbage
|
import kotlinx.android.synthetic.main.overview_buttons_layout.overview_wizardbutton
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.careportal_batterylevel
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_activeprofile
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_apsmode
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_arrow
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_basebasal
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_bg
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_bggraph
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_carbsbutton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_chartMenuButton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_cob
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_extendedbolus
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_insulinbutton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_iob
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_iobcalculationprogess
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_iobgraph
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_looplayout
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_notifications
|
import kotlinx.android.synthetic.main.overview_fragment.overview_notifications
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_pumpstatus
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_pumpstatuslayout
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_quickwizardbutton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_sensitivity
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_temptarget
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_treatmentbutton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_wizardbutton
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment_nsclient_tablet.*
|
import kotlinx.android.synthetic.main.overview_fragment_nsclient_tablet.*
|
||||||
|
import kotlinx.android.synthetic.main.overview_graphs_layout.overview_bggraph
|
||||||
|
import kotlinx.android.synthetic.main.overview_graphs_layout.overview_chartMenuButton
|
||||||
|
import kotlinx.android.synthetic.main.overview_graphs_layout.overview_iobcalculationprogess
|
||||||
|
import kotlinx.android.synthetic.main.overview_graphs_layout.overview_iobgraph
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.*
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_arrow
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_basebasal
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_bg
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_cob
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_extendedbolus
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_iob
|
||||||
|
import kotlinx.android.synthetic.main.overview_info_layout.overview_sensitivity
|
||||||
|
import kotlinx.android.synthetic.main.overview_loop_pumpstatus_layout.*
|
||||||
|
import kotlinx.android.synthetic.main.overview_statuslights_layout.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -140,6 +134,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var overviewMenus: OverviewMenus
|
@Inject lateinit var overviewMenus: OverviewMenus
|
||||||
|
@Inject lateinit var skinProvider: SkinProvider
|
||||||
|
@Inject lateinit var config: Config
|
||||||
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -170,19 +168,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
||||||
val landscape = screenHeight < screenWidth
|
val landscape = screenHeight < screenWidth
|
||||||
|
|
||||||
return when {
|
return inflater.inflate(skinProvider.activeSkin().overviewLayout(landscape, resourceHelper.gb(R.bool.isTablet), smallHeight), container, false)
|
||||||
resourceHelper.gb(R.bool.isTablet) && Config.NSCLIENT ->
|
|
||||||
inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false)
|
|
||||||
|
|
||||||
Config.NSCLIENT ->
|
|
||||||
inflater.inflate(R.layout.overview_fragment_nsclient, container, false)
|
|
||||||
|
|
||||||
smallHeight || landscape ->
|
|
||||||
inflater.inflate(R.layout.overview_fragment_landscape, container, false)
|
|
||||||
|
|
||||||
else ->
|
|
||||||
inflater.inflate(R.layout.overview_fragment, container, false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -226,7 +212,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
super.onPause()
|
super.onPause()
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
loopHandler.removeCallbacksAndMessages(null)
|
loopHandler.removeCallbacksAndMessages(null)
|
||||||
overview_apsmode?.let { unregisterForContextMenu(it) }
|
overview_apsmode_llayout?.let { unregisterForContextMenu(it) }
|
||||||
overview_activeprofile?.let { unregisterForContextMenu(it) }
|
overview_activeprofile?.let { unregisterForContextMenu(it) }
|
||||||
overview_temptarget?.let { unregisterForContextMenu(it) }
|
overview_temptarget?.let { unregisterForContextMenu(it) }
|
||||||
}
|
}
|
||||||
|
@ -300,7 +286,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L)
|
loopHandler.postDelayed(refreshLoop, 60 * 1000L)
|
||||||
|
|
||||||
overview_apsmode?.let { registerForContextMenu(overview_apsmode) }
|
overview_apsmode_llayout?.let { registerForContextMenu(overview_apsmode) }
|
||||||
overview_activeprofile?.let { registerForContextMenu(it) }
|
overview_activeprofile?.let { registerForContextMenu(it) }
|
||||||
overview_temptarget?.let { registerForContextMenu(it) }
|
overview_temptarget?.let { registerForContextMenu(it) }
|
||||||
updateGUI("onResume")
|
updateGUI("onResume")
|
||||||
|
@ -312,26 +298,20 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onContextItemSelected(item: MenuItem): Boolean {
|
override fun onContextItemSelected(item: MenuItem): Boolean {
|
||||||
val manager = fragmentManager
|
return if (overviewMenus.onContextItemSelected(item, childFragmentManager)) true else super.onContextItemSelected(item)
|
||||||
return if (manager != null && overviewMenus.onContextItemSelected(item, manager)) true else super.onContextItemSelected(item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val manager = fragmentManager ?: return
|
|
||||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||||
// https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction
|
// https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction
|
||||||
if (manager.isStateSaved) return
|
if (childFragmentManager.isStateSaved) return
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { TreatmentDialog().show(manager, "Overview") })
|
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { TreatmentDialog().show(childFragmentManager, "Overview") }))
|
||||||
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { WizardDialog().show(manager, "Overview") })
|
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { WizardDialog().show(childFragmentManager, "Overview") }))
|
||||||
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { InsulinDialog().show(manager, "Overview") })
|
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { InsulinDialog().show(childFragmentManager, "Overview") }))
|
||||||
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { onClickQuickWizard() })
|
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { onClickQuickWizard() }))
|
||||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { CarbsDialog().show(manager, "Overview") })
|
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { CarbsDialog().show(childFragmentManager, "Overview") }))
|
||||||
|
|
||||||
R.id.overview_pumpstatus -> {
|
|
||||||
if (activePlugin.activePump.isSuspended || !activePlugin.activePump.isInitialized) commandQueue.readStatus("RefreshClicked", null)
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.overview_cgmbutton -> {
|
R.id.overview_cgmbutton -> {
|
||||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
||||||
|
@ -346,7 +326,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
R.id.overview_calibrationbutton -> {
|
R.id.overview_calibrationbutton -> {
|
||||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) {
|
if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) {
|
||||||
CalibrationDialog().show(manager, "CalibrationDialog")
|
CalibrationDialog().show(childFragmentManager, "CalibrationDialog")
|
||||||
} else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) {
|
} else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) {
|
||||||
try {
|
try {
|
||||||
dexcomPlugin.findDexcomPackageName()?.let {
|
dexcomPlugin.findDexcomPackageName()?.let {
|
||||||
|
@ -534,7 +514,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
fun updateGUI(from: String) {
|
fun updateGUI(from: String) {
|
||||||
aapsLogger.debug("UpdateGUI from $from")
|
aapsLogger.debug("UpdateGUI from $from")
|
||||||
|
|
||||||
overview_time?.text = DateUtil.timeString(Date())
|
overview_time?.text = dateUtil.timeString(Date())
|
||||||
|
|
||||||
if (!profileFunction.isProfileValid("Overview")) {
|
if (!profileFunction.isProfileValid("Overview")) {
|
||||||
overview_pumpstatus?.setText(R.string.noprofileset)
|
overview_pumpstatus?.setText(R.string.noprofileset)
|
||||||
|
@ -565,14 +545,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
overview_bg?.text = lastBG.valueToUnitsToString(units)
|
overview_bg?.text = lastBG.valueToUnitsToString(units)
|
||||||
overview_bg?.setTextColor(color)
|
overview_bg?.setTextColor(color)
|
||||||
overview_arrow?.text = lastBG.directionToSymbol()
|
overview_arrow?.text = lastBG.directionToSymbol(databaseHelper)
|
||||||
overview_arrow?.setTextColor(color)
|
overview_arrow?.setTextColor(color)
|
||||||
|
|
||||||
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
if (glucoseStatus != null) {
|
if (glucoseStatus != null) {
|
||||||
overview_delta?.text = "Δ ${Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)} $units"
|
overview_delta?.text = "Δ ${Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)}"
|
||||||
overview_deltashort?.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)
|
overview_deltashort?.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)
|
||||||
overview_avgdelta?.text = "øΔ15m: ${Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units)}\nøΔ40m: ${Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)}"
|
overview_avgdelta?.text = "Δ15m: ${Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units)}\nΔ40m: ${Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)}"
|
||||||
} else {
|
} else {
|
||||||
overview_delta?.text = "Δ " + resourceHelper.gs(R.string.notavailable)
|
overview_delta?.text = "Δ " + resourceHelper.gs(R.string.notavailable)
|
||||||
overview_deltashort?.text = "---"
|
overview_deltashort?.text = "---"
|
||||||
|
@ -594,56 +574,75 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
val closedLoopEnabled = constraintChecker.isClosedLoopAllowed()
|
val closedLoopEnabled = constraintChecker.isClosedLoopAllowed()
|
||||||
|
|
||||||
// open loop mode
|
// open loop mode
|
||||||
if (Config.APS && pump.pumpDescription.isTempBasalCapable) {
|
if (config.APS && pump.pumpDescription.isTempBasalCapable) {
|
||||||
overview_apsmode?.visibility = View.VISIBLE
|
overview_apsmode?.visibility = View.VISIBLE
|
||||||
when {
|
when {
|
||||||
loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus -> {
|
loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> {
|
||||||
overview_apsmode?.text = String.format(resourceHelper.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend())
|
overview_apsmode.setImageResource(R.drawable.loop_superbolus)
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
//overview_apsmode_text?.text = String.format(resourceHelper.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend())
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
||||||
}
|
}
|
||||||
|
|
||||||
loopPlugin.isDisconnected -> {
|
loopPlugin.isDisconnected -> {
|
||||||
overview_apsmode?.text = String.format(resourceHelper.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend())
|
overview_apsmode.setImageResource(R.drawable.loop_disconnected)
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonCritical))
|
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextCritical))
|
// overview_apsmode_text?.text = String.format(resourceHelper.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend())
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonCritical))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextCritical))
|
||||||
}
|
}
|
||||||
|
|
||||||
loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended -> {
|
loopPlugin.isEnabled() && loopPlugin.isSuspended -> {
|
||||||
overview_apsmode?.text = String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
overview_apsmode.setImageResource(R.drawable.loop_paused)
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
// overview_apsmode_text?.text = String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
||||||
}
|
}
|
||||||
|
|
||||||
pump.isSuspended -> {
|
pump.isSuspended -> {
|
||||||
overview_apsmode?.text = resourceHelper.gs(R.string.pumpsuspended)
|
overview_apsmode.setImageResource(R.drawable.loop_paused)
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
overview_apsmode_text?.text = ""
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
// overview_apsmode_text?.text = resourceHelper.gs(R.string.pumpsuspended)
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
||||||
}
|
}
|
||||||
|
|
||||||
loopPlugin.isEnabled(PluginType.LOOP) -> {
|
loopPlugin.isEnabled() && closedLoopEnabled.value() && loopPlugin.isLGS -> {
|
||||||
val isLGS = loopPlugin.isLGS
|
overview_apsmode.setImageResource(R.drawable.loop_lgs)
|
||||||
overview_apsmode?.text =
|
overview_apsmode_text?.text = ""
|
||||||
if (closedLoopEnabled.value())
|
// overview_apsmode_text?.text = resourceHelper.gs(R.string.closedloop)
|
||||||
if (isLGS)
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
||||||
resourceHelper.gs(R.string.lgs)
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||||
else
|
}
|
||||||
resourceHelper.gs(R.string.closedloop)
|
|
||||||
else
|
|
||||||
resourceHelper.gs(R.string.openloop)
|
|
||||||
|
|
||||||
overview_apsmode?.setBackgroundColor(if (isLGS) resourceHelper.gc(R.color.ribbonUnusual) else resourceHelper.gc(R.color.ribbonDefault))
|
loopPlugin.isEnabled() && closedLoopEnabled.value() -> {
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
overview_apsmode.setImageResource(R.drawable.loop_closed)
|
||||||
|
overview_apsmode_text?.text = ""
|
||||||
|
// overview_apsmode_text?.text = resourceHelper.gs(R.string.closedloop)
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||||
|
}
|
||||||
|
|
||||||
|
loopPlugin.isEnabled() && !closedLoopEnabled.value() -> {
|
||||||
|
overview_apsmode.setImageResource(R.drawable.loop_open)
|
||||||
|
overview_apsmode_text?.text = ""
|
||||||
|
// overview_apsmode_text?.text = resourceHelper.gs(R.string.openloop)
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
overview_apsmode?.text = resourceHelper.gs(R.string.disabledloop)
|
overview_apsmode.setImageResource(R.drawable.loop_disabled)
|
||||||
overview_apsmode?.setBackgroundColor(resourceHelper.gc(R.color.ribbonCritical))
|
overview_apsmode_text?.text = ""
|
||||||
overview_apsmode?.setTextColor(resourceHelper.gc(R.color.ribbonTextCritical))
|
// overview_apsmode_text?.text = resourceHelper.gs(R.string.disabledloop)
|
||||||
|
// overview_apsmode_text?.setBackgroundColor(resourceHelper.gc(R.color.ribbonCritical))
|
||||||
|
// overview_apsmode_text?.setTextColor(resourceHelper.gc(R.color.ribbonTextCritical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
overview_apsmode?.visibility = View.GONE
|
overview_apsmode_text?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
|
@ -660,9 +659,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
// Basal, TBR
|
// Basal, TBR
|
||||||
val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis())
|
val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis())
|
||||||
overview_basebasal?.text = activeTemp?.let { if (resourceHelper.shortTextMode()) "T: " + activeTemp.toStringVeryShort() else activeTemp.toStringFull() }
|
overview_basebasal?.text = activeTemp?.let { if (resourceHelper.shortTextMode()) "T:" + activeTemp.toStringVeryShort() else activeTemp.toStringFull() }
|
||||||
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)
|
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)
|
||||||
overview_basebasal?.setOnClickListener {
|
overview_basal_llayout?.setOnClickListener {
|
||||||
var fullText = "${resourceHelper.gs(R.string.pump_basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}"
|
var fullText = "${resourceHelper.gs(R.string.pump_basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}"
|
||||||
if (activeTemp != null)
|
if (activeTemp != null)
|
||||||
fullText += "\n" + resourceHelper.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull()
|
fullText += "\n" + resourceHelper.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull()
|
||||||
|
@ -672,6 +671,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
overview_basebasal?.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) }
|
overview_basebasal?.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) }
|
||||||
?: resourceHelper.gc(R.color.defaulttextcolor))
|
?: resourceHelper.gc(R.color.defaulttextcolor))
|
||||||
|
overview_basebasal_icon.setImageResource(if (activeTemp != null) R.drawable.icon_cp_basal_start else R.drawable.icon_cp_basal_end)
|
||||||
|
|
||||||
// Extended bolus
|
// Extended bolus
|
||||||
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||||
|
@ -684,7 +684,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())
|
OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
overview_extended_llayout?.visibility = (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses).toVisibility()
|
||||||
|
|
||||||
|
// Active profile
|
||||||
overview_activeprofile?.text = profileFunction.getProfileNameWithDuration()
|
overview_activeprofile?.text = profileFunction.getProfileNameWithDuration()
|
||||||
if (profile.percentage != 100 || profile.timeshift != 0) {
|
if (profile.percentage != 100 || profile.timeshift != 0) {
|
||||||
overview_activeprofile?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
overview_activeprofile?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
||||||
|
@ -702,23 +704,15 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
|
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
|
||||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||||
overview_iob?.text = when {
|
overview_iob?.text = when {
|
||||||
resourceHelper.shortTextMode() -> {
|
resourceHelper.shortTextMode() ->
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
|
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gb(R.bool.isTablet) -> {
|
else ->
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + " (" +
|
|
||||||
resourceHelper.gs(R.string.bolus) + ": " + resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob) +
|
|
||||||
resourceHelper.gs(R.string.basal) + ": " + resourceHelper.gs(R.string.formatinsulinunits, basalIob.basaliob) + ")"
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + " (" +
|
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + " (" +
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob) + "/" +
|
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob) + "/" +
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, basalIob.basaliob) + ")"
|
resourceHelper.gs(R.string.formatinsulinunits, basalIob.basaliob) + ")"
|
||||||
}
|
}
|
||||||
}
|
overview_iob_llayout?.setOnClickListener {
|
||||||
overview_iob?.setOnClickListener {
|
|
||||||
activity?.let {
|
activity?.let {
|
||||||
OKDialog.show(it, resourceHelper.gs(R.string.iob),
|
OKDialog.show(it, resourceHelper.gs(R.string.iob),
|
||||||
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + "\n" +
|
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + "\n" +
|
||||||
|
@ -729,29 +723,29 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status lights
|
// Status lights
|
||||||
overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || Config.NSCLIENT).toVisibility()
|
overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
|
||||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
|
||||||
|
|
||||||
// cob
|
// cob
|
||||||
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
|
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
|
||||||
val cobInfo = iobCobCalculatorPlugin.getCobInfo(false, "Overview COB")
|
val cobInfo = iobCobCalculatorPlugin.getCobInfo(false, "Overview COB")
|
||||||
if (cobInfo.displayCob != null) {
|
if (cobInfo.displayCob != null) {
|
||||||
cobText = DecimalFormatter.to0Decimal(cobInfo.displayCob)
|
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
|
||||||
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
|
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
|
||||||
}
|
}
|
||||||
overview_cob?.text = cobText
|
overview_cob?.text = cobText
|
||||||
|
|
||||||
val lastRun = loopPlugin.lastRun
|
val lastRun = loopPlugin.lastRun
|
||||||
|
|
||||||
if (Config.APS && lastRun?.constraintsProcessed != null && lastRun?.constraintsProcessed.carbsReq > 0) {
|
// if (config.APS && lastRun?.constraintsProcessed != null && lastRun?.constraintsProcessed.carbsReq > 0) {
|
||||||
overview_cob_required.visibility = View.VISIBLE
|
// overview_cob_required.visibility = View.VISIBLE
|
||||||
var carbsRequiredString: String = String.format(resourceHelper.gs(R.string.overview_carbs_required), lastRun?.constraintsProcessed?.carbsReq, lastRun?.constraintsProcessed?.carbsReqWithin)
|
// var carbsRequiredString: String = String.format(resourceHelper.gs(R.string.overview_carbs_required), lastRun?.constraintsProcessed?.carbsReq, lastRun?.constraintsProcessed?.carbsReqWithin)
|
||||||
overview_cob_required.text = carbsRequiredString
|
// overview_cob_required.text = carbsRequiredString
|
||||||
} else {
|
// } else {
|
||||||
overview_cob_required.visibility = View.GONE
|
// overview_cob_required.visibility = View.GONE
|
||||||
}
|
// }
|
||||||
|
|
||||||
val predictionsAvailable = if (Config.APS) lastRun?.request?.hasPredictions == true else Config.NSCLIENT
|
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
||||||
|
|
||||||
// pump status from ns
|
// pump status from ns
|
||||||
overview_pump?.text = nsDeviceStatus.pumpStatus
|
overview_pump?.text = nsDeviceStatus.pumpStatus
|
||||||
|
@ -766,9 +760,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
overview_uploader?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.uploader), nsDeviceStatus.extendedUploaderStatus) } }
|
overview_uploader?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.uploader), nsDeviceStatus.extendedUploaderStatus) } }
|
||||||
|
|
||||||
// Sensitivity
|
// Sensitivity
|
||||||
|
overview_sensitivity?.text =
|
||||||
iobCobCalculatorPlugin.getLastAutosensData("Overview")?.let { autosensData ->
|
iobCobCalculatorPlugin.getLastAutosensData("Overview")?.let { autosensData ->
|
||||||
overview_sensitivity?.text = String.format(Locale.ENGLISH, "%.0f%%", autosensData.autosensResult.ratio * 100)
|
String.format(Locale.ENGLISH, "%.0f%%", autosensData.autosensResult.ratio * 100)
|
||||||
}
|
} ?: ""
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
@ -789,7 +784,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
val toTime: Long
|
val toTime: Long
|
||||||
val fromTime: Long
|
val fromTime: Long
|
||||||
val endTime: Long
|
val endTime: Long
|
||||||
val apsResult = if (Config.APS) lastRun?.constraintsProcessed else NSDeviceStatus.getAPSResult(injector)
|
val apsResult = if (config.APS) lastRun?.constraintsProcessed else NSDeviceStatus.getAPSResult(injector)
|
||||||
if (predictionsAvailable && apsResult != null && overviewMenus.setting[0][OverviewMenus.CharType.PRE.ordinal]) {
|
if (predictionsAvailable && apsResult != null && overviewMenus.setting[0][OverviewMenus.CharType.PRE.ordinal]) {
|
||||||
var predHours = (ceil(apsResult.latestPredictionsTime - System.currentTimeMillis().toDouble()) / (60 * 60 * 1000)).toInt()
|
var predHours = (ceil(apsResult.latestPredictionsTime - System.currentTimeMillis().toDouble()) / (60 * 60 * 1000)).toInt()
|
||||||
predHours = min(2, predHours)
|
predHours = min(2, predHours)
|
||||||
|
|
|
@ -15,7 +15,6 @@ import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
@ -34,7 +33,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
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.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.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
|
@ -42,7 +41,6 @@ import info.nightscout.androidaps.utils.ToastUtils
|
||||||
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 java.lang.reflect.Type
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -59,7 +57,8 @@ class OverviewMenus @Inject constructor(
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val commandQueue: CommandQueueProvider,
|
private val commandQueue: CommandQueueProvider,
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
private val loopPlugin: LoopPlugin
|
private val loopPlugin: LoopPlugin,
|
||||||
|
private val config: Config
|
||||||
) {
|
) {
|
||||||
|
|
||||||
enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean) {
|
enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean) {
|
||||||
|
@ -117,8 +116,8 @@ class OverviewMenus @Inject constructor(
|
||||||
|
|
||||||
chartButton.setOnClickListener { v: View ->
|
chartButton.setOnClickListener { v: View ->
|
||||||
val predictionsAvailable: Boolean = when {
|
val predictionsAvailable: Boolean = when {
|
||||||
Config.APS -> loopPlugin.lastRun?.request?.hasPredictions ?: false
|
config.APS -> loopPlugin.lastRun?.request?.hasPredictions ?: false
|
||||||
Config.NSCLIENT -> true
|
config.NSCLIENT -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
val popup = PopupMenu(v.context, v)
|
val popup = PopupMenu(v.context, v)
|
||||||
|
|
|
@ -20,7 +20,8 @@ class StatusLightHandler @Inject constructor(
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val activePlugin: ActivePluginProvider,
|
private val activePlugin: ActivePluginProvider,
|
||||||
private val warnColors: WarnColors
|
private val warnColors: WarnColors,
|
||||||
|
private val config: Config
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,9 +33,9 @@ class StatusLightHandler @Inject constructor(
|
||||||
handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
|
handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
|
||||||
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
||||||
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
||||||
if (!Config.NSCLIENT)
|
if (!config.NSCLIENT)
|
||||||
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
||||||
if (!Config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
|
if (!config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
|
||||||
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
|
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue